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: Chen Hanxiao <chenhx.fnst@fujitsu.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
                break;
        case Opt_lock:
                if (result.negated) {
+                       ctx->lock_status = NFS_LOCK_NOLOCK;
                        ctx->flags |= NFS_MOUNT_NONLM;
                        ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
                } else {
+                       ctx->lock_status = NFS_LOCK_LOCK;
                        ctx->flags &= ~NFS_MOUNT_NONLM;
                        ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
                }
 
        unsigned short          protofamily;
        unsigned short          mountfamily;
        bool                    has_sec_mnt_opts;
+       int                     lock_status;
 
        struct {
                union {
        } 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 ?              \
        errorf(fc, fmt, ## __VA_ARGS__) :                       \
        ({ dprintk(fmt "\n", ## __VA_ARGS__); }))
 
        rpc_authflavor_t authlist[NFS_MAX_SECFLAVORS];
        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);
        if (status)
                return ERR_PTR(status);