-1

Is there any way I can speed up chmod on an NFS server?

I am running chmod on a number of files each time a script is run. It is almost immediate when run locally, but when targeting the NFS server it takes 10-20 minutes.

NOTE: This is on Solaris.

closed as too broad by Rui F Ribeiro, Jeff Schaller, steve, slm Jul 10 '18 at 8:05

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is this Solaris on both server and client? Is this NFSv4? How many files are affected for 10 minutes? – schily Jul 9 '18 at 7:05
  • Without any technical details about the health of your network and Solaris side configuration, we are not able to give you meaningful answers. – Rui F Ribeiro Jul 9 '18 at 7:42
2

Suggestion #1

My first suspicion would be around how it's mounted on your system where you're executing the commands. Take a look at the mount command as well as the showmount -e to see how it's being exported to your system.

Suggestion #2

The next thing I'd do is investigate the actual command you're running with strace and see which function it's taking the longest on.

For example:

$ strace -s 2000 chmod u+w afile
execve("/bin/chmod", ["chmod", "u+w", "afile"], [/* 27 vars */]) = 0
brk(NULL)                               = 0x1143000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fad70431000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=33236, ...}) = 0
mmap(NULL, 33236, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fad70428000
close(3)                                = 0
...
...
arch_prctl(ARCH_SET_FS, 0x7fad70425740) = 0
mprotect(0x7fad70206000, 16384, PROT_READ) = 0
mprotect(0x60c000, 4096, PROT_READ)     = 0
mprotect(0x7fad70432000, 4096, PROT_READ) = 0
munmap(0x7fad70428000, 33236)           = 0
brk(NULL)                               = 0x1143000
brk(0x1164000)                          = 0x1164000
brk(NULL)                               = 0x1164000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fad6991b000
close(3)                                = 0
umask(0)                                = 022
stat("afile", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
fchmodat(AT_FDCWD, "afile", 0644)       = 0
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

I think the equivalent on Solaris is truss, but hopefully you get the suggestion.

Suggestion #3

Which NFS protocol is this? NFSv3 or v4? There's several options related to both that can impact overall performance, I'd investigate those, based on your situation.

For example:
  • Make sure that your /etc/exports file is exporting the shares with async and not sync, for example.

    /export/raid0/home      192.168.*/24(rw,secure,no_root_squash,async,wdelay)
    

    Make sure the mount option, async, is included on the clients as well.

  • Also make sure that the server is relieved of having to update atime on the inodes for the files you're accessing.

Here's a list from nixcraft that highlights many of the options that I've tuned in the past:

Recommended NFS Tuning Options For the Mount Command

  • noacl: Disables Access Control List (ACL) processing.
  • nocto: Suppress the retrieval of new attributes when creating a file.
  • rsize: The number of bytes NFS uses when reading files from an NFS server. The rsize is negotiated between the server and client to determine the largest block size that both can support. The value specified by this option is the maximum size that could be used; however, the actual size used may be smaller. Note: Setting this size to a value less than the largest supported block size will adversely affect performance.
  • wsize: The number of bytes NFS uses when writing files to an NFS server. The wsize is negotiated between the server and client to determine the largest block size that both can support. The value specified by this option is the maximum size that could be used; however, the actual size used may be smaller. Note: Setting this size to a value less than the largest supported block size will adversely affect performance.
  • noatime: Setting this value disables the NFS server from updating the inodes access time. As most applications do not necessarily need this value, you can safely disable this updating.
  • nodiratime: Setting this value disables the NFS server from updating the directory access time. This is the directory equivalent setting of noatime.
  • noac: Disable all forms of attribute caching entirely. This extracts a significant performance penalty but it allows two different NFS clients to get reasonable results when both clients are actively writing to a common export on the server.

References

Not the answer you're looking for? Browse other questions tagged or ask your own question.