Commit bf95f82e authored by Chen Hanxiao's avatar Chen Hanxiao Committed by Trond Myklebust

NFS: make sure lock/nolock overriding local_lock mount option

Currently, mount option lock/nolock and local_lock option
may override NFS_MOUNT_LOCAL_FLOCK NFS_MOUNT_LOCAL_FCNTL flags
when passing in different order:

mount -o vers=3,local_lock=all,lock:
	local_lock=none

mount -o vers=3,lock,local_lock=all:
	local_lock=all

This patch will let lock/nolock override local_lock option
as nfs(5) suggested.
Signed-off-by: default avatarChen Hanxiao <chenhx.fnst@fujitsu.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 7c6c5249
...@@ -600,9 +600,11 @@ static int nfs_fs_context_parse_param(struct fs_context *fc, ...@@ -600,9 +600,11 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
break; break;
case Opt_lock: case Opt_lock:
if (result.negated) { if (result.negated) {
ctx->lock_status = NFS_LOCK_NOLOCK;
ctx->flags |= NFS_MOUNT_NONLM; ctx->flags |= NFS_MOUNT_NONLM;
ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
} else { } else {
ctx->lock_status = NFS_LOCK_LOCK;
ctx->flags &= ~NFS_MOUNT_NONLM; ctx->flags &= ~NFS_MOUNT_NONLM;
ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
} }
......
...@@ -112,6 +112,7 @@ struct nfs_fs_context { ...@@ -112,6 +112,7 @@ struct nfs_fs_context {
unsigned short protofamily; unsigned short protofamily;
unsigned short mountfamily; unsigned short mountfamily;
bool has_sec_mnt_opts; bool has_sec_mnt_opts;
int lock_status;
struct { struct {
union { union {
...@@ -153,6 +154,12 @@ struct nfs_fs_context { ...@@ -153,6 +154,12 @@ struct nfs_fs_context {
} clone_data; } clone_data;
}; };
enum nfs_lock_status {
NFS_LOCK_NOT_SET = 0,
NFS_LOCK_LOCK = 1,
NFS_LOCK_NOLOCK = 2,
};
#define nfs_errorf(fc, fmt, ...) ((fc)->log.log ? \ #define nfs_errorf(fc, fmt, ...) ((fc)->log.log ? \
errorf(fc, fmt, ## __VA_ARGS__) : \ errorf(fc, fmt, ## __VA_ARGS__) : \
({ dprintk(fmt "\n", ## __VA_ARGS__); })) ({ dprintk(fmt "\n", ## __VA_ARGS__); }))
......
...@@ -901,6 +901,16 @@ static struct nfs_server *nfs_try_mount_request(struct fs_context *fc) ...@@ -901,6 +901,16 @@ static struct nfs_server *nfs_try_mount_request(struct fs_context *fc)
rpc_authflavor_t authlist[NFS_MAX_SECFLAVORS]; rpc_authflavor_t authlist[NFS_MAX_SECFLAVORS];
unsigned int authlist_len = ARRAY_SIZE(authlist); unsigned int authlist_len = ARRAY_SIZE(authlist);
/* make sure 'nolock'/'lock' override the 'local_lock' mount option */
if (ctx->lock_status) {
if (ctx->lock_status == NFS_LOCK_NOLOCK) {
ctx->flags |= NFS_MOUNT_NONLM;
ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
} else {
ctx->flags &= ~NFS_MOUNT_NONLM;
ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
}
}
status = nfs_request_mount(fc, ctx->mntfh, authlist, &authlist_len); status = nfs_request_mount(fc, ctx->mntfh, authlist, &authlist_len);
if (status) if (status)
return ERR_PTR(status); return ERR_PTR(status);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment