1

I have a dataset on my NAS (TrueNAS) which I share to a Linux system via NFS (v4) and my Windows PC via SMB (v3). This works fine, however when I change a file on my PC it takes between 20 seconds up to 2 minutes for it to appear on my Linux server where it has to be instant for my purpose. It does, however, updates immediately on the NAS. Using CIFS on my Linux server is not desirable.

Command I use for mounting on Linux:

sudo mount -t nfs xxx.xxx.xx.x:/mnt/storage1/data /mnt/data 

Please note that while the option lookupcache=none may improve things it is not a good solution for my use case as this slows everything down so much I rather wait for the 2min sync.

Does anyone has any suggestions on how to improve this?

EDIT:

Output of mount on the linux client:

xxx.xxx.xx.x:/mnt/storage1/data on /mnt/data type nfs4 (rw,relatime,sync,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=xxx.xxx.xx.xx,local_lock=none,addr=xxx.xxx.xx.x) 

Output of cat /etc/*release* on linux client:

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=24.04 DISTRIB_CODENAME=noble DISTRIB_DESCRIPTION="Ubuntu 24.04.3 LTS" PRETTY_NAME="Ubuntu 24.04.3 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.3 LTS (Noble Numbat)" VERSION_CODENAME=noble ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=noble LOGO=ubuntu-logo 

(Relevant) Output of mount on TrueNAS:

storage1/data on /mnt/storage1/data type zfs (rw,noatime,xattr,posixacl,casesensitive) 

Output of cat /etc/*release* on TrueNAS:

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" 

exportfs -s TrueNAS:

/mnt/storage1/data *(sync,wdelay,hide,no_subtree_check,anonuid=3000,anongid=3000,sec=sys,rw,secure,root_squash,all_squash) 
6
  • are you saying TrueNAS is the nfs-server; you have a linux server as an nfs-client which is then also running samba-server that allows for modification of the share coming from the TrueNAS to be read/written from a windowsPC ? Commented Nov 6 at 17:49
  • I would check for async being present as the mount option of the Linux nfs-client / samba-server; if so I think changing that to sync might fix it; you would find that happening via running mount on the nfs-client and see what that reports for mount options Commented Nov 6 at 17:51
  • @ron Well, TrueNas is the nfs-server but also the smb server. They both point to the same dataset. The linux server is the nfs-client and the windows pc the smb client. I changed to sync as it was set to async but unfortunately that did not make a difference.. Commented Nov 6 at 18:55
  • I use synology, and do not have this sort of problem when using NFS from it to RHEL-8 linux. If you update your thing with as much detail as possible i could probably identify the problem - show the output of 'mount' from nfs-client (linux server) as well as cat /etc/*release*; same for the TrueNas and exportfs -s if you can get a linux terminal in that Commented Nov 6 at 21:11
  • What kind of files are you modifying, what sizes of files are we looking at, what's the actual write speed on the CIFS share from the windows box (i.e. check w/ iotop) rather than local caching. Commented Nov 7 at 3:26

1 Answer 1

0

from your description - a Linux Server as an NFS client mounting from the Ubuntu TrueNas, for which this nfs client does not see updated files on the mounted share, I believe that comes down to NFS client side mount caching.

NFS vers=4.2 {the latest} uses client side (mount) caching by default... to improve performance by reducing the need for constant network round trips to the server.

You would want to look up these mount options, which I am not familiar enough with to tell you which specifically is best so you'll have to play around and test and try putting whichever into effect on your Linux server (the nfs-client).

And be sure to do a mount to validate by seeing those options are in effect.

Response from web search on NFS 4.2 mount caching options

  • acregmin=n: Sets the minimum time (in seconds) that the client caches attributes for regular files. Defaults to 3 seconds.
  • acregmax=n: Sets the maximum time (in seconds) that the client caches attributes for regular files. Defaults to 60 seconds.
  • acdirmax=n: Sets the maximum time (in seconds) that the client caches attributes for directories. Defaults to 60 seconds.
  • actimeo=n: A shortcut to set acregmin, acregmax, acdirmin, and acdirmax to the same value
  • lookupcache
  • cachefilesd
  • noac

so I think looking into these NFS mount options regarding caching is the where the solution lies to the problem you described.

Client-Side Mount Options to Prevent Caching:

noac (No Attribute Caching): This option disables the caching of file attributes (like modification time, size, permissions) on the client. Every operation that requires attribute information will query the server for the latest data, ensuring attribute coherence among multiple clients.

lookupcache=none: This option disables the caching of directory entry lookups. The client will not cache the existence of files or directories and will always query the server for this information, ensuring the most up-to-date view of the directory structure.

actimeo=0: This option sets all attribute cache timeouts (for regular files and directories) to zero, effectively disabling attribute caching entirely. This is a more aggressive approach than just noac.

Data Coherence vs. Performance: The decision to disable caching involves a trade-off between ensuring immediate data coherence across all clients and maintaining optimal performance. Choose the appropriate options based on the specific requirements of your application and environment.

Performance Impact: Disabling client-side caching significantly increases network traffic and server load, as every operation requiring cached information will result in a network round trip. This can lead to a noticeable performance degradation, especially in environments with high file access rates.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.