Skip to contentSkip to conversation

nfs: introduce mount option '-olocal_lock' to make locks local (try++)

PATCH In review Suresh Jayaraman 2 participants 6 messages Sep 20, 2010 – Sep 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs: introduce mount option '-olocal_lock' to make locks local (try++)

Changes since last post:

- NFS_MOUNT_NONLM definition remains unmodified as legacy binary mount interface uses it
- Fixed an Oops in _nfs4_do_setlk() found during NFSv4 reboot recovery
- Rebased against Trond's nfs-2.6.git (nfs-for-2.6.37 branch)

Thanks,
Suresh Jayaraman

From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] nfs: introduce mount option '-olocal_lock' to make locks local

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.

---
 fs/nfs/client.c           |    6 +++-
 fs/nfs/file.c             |   45 +++++++++++++++++++++++++++-----------
 fs/nfs/super.c            |   53 ++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/nfs_mount.h |    3 ++
 4 files changed, 91 insertions(+), 16 deletions(-)
fs/nfs/client.c +4 -2
index 4e7df2a..5f01f42 100644
@@ -635,7 +635,8 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
  */
 static void nfs_destroy_server(struct nfs_server *server)
 {
-	if (!(server->flags & NFS_MOUNT_NONLM))
+	if (!(server->flags & NFS_MOUNT_LOCAL_FLOCK) ||
+			!(server->flags & NFS_MOUNT_LOCAL_FCNTL))
 		nlmclnt_done(server->nlm_host);
 }
 
@@ -657,7 +658,8 @@ static int nfs_start_lockd(struct nfs_server *server)
 
 	if (nlm_init.nfs_version > 3)
 		return 0;
-	if (server->flags & NFS_MOUNT_NONLM)
+	if ((server->flags & NFS_MOUNT_LOCAL_FLOCK) &&
+			(server->flags & NFS_MOUNT_LOCAL_FCNTL))
 		return 0;
 
 	switch (clp->cl_proto) {
fs/nfs/file.c +32 -13

119 lines not on this page · raw message

fs/nfs/super.c +52 -1

92 lines not on this page · raw message

include/linux/nfs_mount.h +3 -0
index 5d59ae8..576bddd 100644
@@ -71,4 +71,7 @@ struct nfs_mount_data {
 #define NFS_MOUNT_NORESVPORT		0x40000
 #define NFS_MOUNT_LEGACY_INTERFACE	0x80000
 
+#define NFS_MOUNT_LOCAL_FLOCK	0x100000
+#define NFS_MOUNT_LOCAL_FCNTL	0x200000
+
 #endif
#1 lore raw
Quoted 10 lines · Suresh Jayaraman

Changes since last post:

- NFS_MOUNT_NONLM definition remains unmodified as legacy binary mount interface uses it
- Fixed an Oops in _nfs4_do_setlk() found during NFSv4 reboot recovery
- Rebased against Trond's nfs-2.6.git (nfs-for-2.6.37 branch)

Thanks,
Suresh Jayaraman

Suresh,

This still appears to break the binary mount interface. You need something in nfs_validate_mount_data() to convert the NFS_MOUNT_NONLM flag into (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL).

Cheers
Trond

#2 lore raw
Quoted 12 lines · Trond Myklebust
Quoted 10 lines · Suresh Jayaraman

Changes since last post:

- NFS_MOUNT_NONLM definition remains unmodified as legacy binary mount interface uses it
- Fixed an Oops in _nfs4_do_setlk() found during NFSv4 reboot recovery
- Rebased against Trond's nfs-2.6.git (nfs-for-2.6.37 branch)

Thanks,
Suresh Jayaraman

Quoted 6 lines

Suresh,

This still appears to break the binary mount interface. You need something in nfs_validate_mount_data() to convert the NFS_MOUNT_NONLM flag into (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL).

Good catch, thanks. Here's the fixed version (haven't tested it as I don't find a simple way to test it and it looks obvious):

From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] nfs: introduce mount option '-olocal_lock' to make locks local (try++)

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.

---
 fs/nfs/client.c           |    6 +++-
 fs/nfs/file.c             |   45 ++++++++++++++++++++++++----------
 fs/nfs/super.c            |   59 ++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/nfs_mount.h |    3 ++
 4 files changed, 97 insertions(+), 16 deletions(-)
fs/nfs/client.c +4 -2
index 4e7df2a..5f01f42 100644
@@ -635,7 +635,8 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
  */
 static void nfs_destroy_server(struct nfs_server *server)
 {
-	if (!(server->flags & NFS_MOUNT_NONLM))
+	if (!(server->flags & NFS_MOUNT_LOCAL_FLOCK) ||
+			!(server->flags & NFS_MOUNT_LOCAL_FCNTL))
 		nlmclnt_done(server->nlm_host);
 }
 
@@ -657,7 +658,8 @@ static int nfs_start_lockd(struct nfs_server *server)
 
 	if (nlm_init.nfs_version > 3)
 		return 0;
-	if (server->flags & NFS_MOUNT_NONLM)
+	if ((server->flags & NFS_MOUNT_LOCAL_FLOCK) &&
+			(server->flags & NFS_MOUNT_LOCAL_FCNTL))
 		return 0;
 
 	switch (clp->cl_proto) {
fs/nfs/file.c +32 -13

119 lines not on this page · raw message

fs/nfs/super.c +58 -1

104 lines not on this page · raw message

include/linux/nfs_mount.h +3 -0
index 5d59ae8..576bddd 100644
@@ -71,4 +71,7 @@ struct nfs_mount_data {
 #define NFS_MOUNT_NORESVPORT		0x40000
 #define NFS_MOUNT_LEGACY_INTERFACE	0x80000
 
+#define NFS_MOUNT_LOCAL_FLOCK	0x100000
+#define NFS_MOUNT_LOCAL_FCNTL	0x200000
+
 #endif
#3 lore raw
Quoted 15 lines · Suresh Jayaraman
Quoted 14 lines · Trond Myklebust
Quoted 10 lines · Suresh Jayaraman

Changes since last post:

- NFS_MOUNT_NONLM definition remains unmodified as legacy binary mount interface uses it
- Fixed an Oops in _nfs4_do_setlk() found during NFSv4 reboot recovery
- Rebased against Trond's nfs-2.6.git (nfs-for-2.6.37 branch)

Thanks,
Suresh Jayaraman

Suresh,

Quoted 7 lines
Quoted 4 lines

This still appears to break the binary mount interface. You need something in nfs_validate_mount_data() to convert the NFS_MOUNT_NONLM flag into (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL).

Good catch, thanks. Here's the fixed version (haven't tested it as I don't find a simple way to test it and it looks obvious):

Hi Suresh,

This one looks good to me.

Thanks!
Trond

#4 lore raw
Quoted 24 lines · Trond Myklebust
Quoted 15 lines · Suresh Jayaraman
Quoted 14 lines · Trond Myklebust
Quoted 10 lines · Suresh Jayaraman

Changes since last post:

- NFS_MOUNT_NONLM definition remains unmodified as legacy binary mount interface uses it
- Fixed an Oops in _nfs4_do_setlk() found during NFSv4 reboot recovery
- Rebased against Trond's nfs-2.6.git (nfs-for-2.6.37 branch)

Thanks,
Suresh Jayaraman

Suresh,

Quoted 7 lines
Quoted 4 lines

This still appears to break the binary mount interface. You need something in nfs_validate_mount_data() to convert the NFS_MOUNT_NONLM flag into (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL).

Good catch, thanks. Here's the fixed version (haven't tested it as I don't find a simple way to test it and it looks obvious):

Quoted 6 lines

Hi Suresh,

This one looks good to me.

Thanks!
Trond

Hmm... One thing to note: it would be nice to display the 'local_lock' status in /proc/mounts. That can be applied as a separate patch, though.

Cheers
Trond

#5 lore raw
Quoted 27 lines · Trond Myklebust
Quoted 26 lines · Trond Myklebust
Quoted 15 lines · Suresh Jayaraman
Quoted 14 lines · Trond Myklebust
Quoted 10 lines · Suresh Jayaraman

Changes since last post:

- NFS_MOUNT_NONLM definition remains unmodified as legacy binary mount interface uses it
- Fixed an Oops in _nfs4_do_setlk() found during NFSv4 reboot recovery
- Rebased against Trond's nfs-2.6.git (nfs-for-2.6.37 branch)

Thanks,
Suresh Jayaraman

Suresh,

Quoted 7 lines
Quoted 4 lines

This still appears to break the binary mount interface. You need something in nfs_validate_mount_data() to convert the NFS_MOUNT_NONLM flag into (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL).

Good catch, thanks. Here's the fixed version (haven't tested it as I don't find a simple way to test it and it looks obvious):

Hi Suresh,

Quoted 8 lines
Quoted 4 lines

This one looks good to me.

Thanks!
Trond

Hmm... One thing to note: it would be nice to display the 'local_lock' status in /proc/mounts. That can be applied as a separate patch, though.

Sounds good. I sent a separate patch for doing that.

The man page needs to be updated too. I'll write the nfs-utils patch for doing it and send it.

Thanks,

Signature · 1 line
Suresh Jayaraman