• Suresh Jayaraman's avatar
    nfs: introduce mount option '-olocal_lock' to make locks local · 5eebde23
    Suresh Jayaraman authored
    NFS clients since 2.6.12 support flock locks by emulating fcntl byte-range
    locks. Due to this, some windows applications which seem to use both flock
    (share mode lock mapped as flock by Samba) and fcntl locks sequentially on
    the same file, can't lock as they falsely assume the file is already locked.
    The problem was reported on a setup with windows clients accessing excel files
    on a Samba exported share which is originally a NFS mount from a NetApp filer.
    
    Older NFS clients (< 2.6.12) did not see this problem as flock locks were
    considered local. To support legacy flock behavior, this patch adds a mount
    option "-olocal_lock=" which can take the following values:
    
       'none'  		- Neither flock locks nor POSIX locks are local
       'flock' 		- flock locks are local
       'posix' 		- fcntl/POSIX locks are local
       'all'		- Both flock locks and POSIX locks are local
    
    Testing:
    
       - This patch was tested by using -olocal_lock option with different values
         and the NLM calls were noted from the network packet captured.
    
         'none'  - NLM calls were seen during both flock() and fcntl(), flock lock
       	       was granted, fcntl was denied
         'flock' - no NLM calls for flock(), NLM call was seen for fcntl(),
       	       granted
         'posix' - NLM call was seen for flock() - granted, no NLM call for fcntl()
         'all'   - no NLM calls were seen during both flock() and fcntl()
    
       - No bugs were seen during NFSv4 locking/unlocking in general and NFSv4
         reboot recovery.
    
    Cc: Neil Brown <neilb@suse.de>
    Signed-off-by: default avatarSuresh Jayaraman <sjayaraman@suse.de>
    Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
    5eebde23
nfs_mount.h 2.29 KB