]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lockd: Prepare share helpers for xdrgen conversion
authorChuck Lever <chuck.lever@oracle.com>
Tue, 17 Feb 2026 22:07:14 +0000 (17:07 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Mar 2026 01:25:09 +0000 (21:25 -0400)
In order to convert the NLMv4 server-side XDR functions to use
xdrgen, the internal share helpers need to be decoupled from the
NLMv3-specific struct nlm_args. NLMv4 procedures will use
different argument structures once they are converted.

Refactor nlmsvc_share_file() and nlmsvc_unshare_file() to accept
individual arguments (oh, access, mode) instead of the common
struct nlm_args. This allows both protocol versions to call these
helpers without forcing a common argument structure.

While here, add kdoc comments to both functions and fix a comment
typo in the unshare path.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/share.h
fs/lockd/svc4proc.c
fs/lockd/svcproc.c
fs/lockd/svcshare.c

index d8f4ebd9c27858f3006712ef5860443d0453bfd9..a2867e30c593ffcc3be877ec7a4fbc996c9a426b 100644 (file)
@@ -20,10 +20,10 @@ struct nlm_share {
        u32                     s_mode;         /* deny mode */
 };
 
-__be32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *,
-                                              struct nlm_args *);
-__be32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *,
-                                              struct nlm_args *);
+__be32 nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file,
+                         struct xdr_netobj *oh, u32 access, u32 mode);
+__be32 nlmsvc_unshare_file(struct nlm_host *host, struct nlm_file *file,
+                           struct xdr_netobj *oh);
 void   nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *,
                                               nlm_host_match_fn_t);
 
index 6dd9afc595518d0c3e601476fd82302dab108b01..d820d6620e061e4b13fc9259096c4c5025828700 100644 (file)
@@ -1072,7 +1072,8 @@ nlm4svc_proc_share(struct svc_rqst *rqstp)
                        rpc_drop_reply : rpc_success;
 
        /* Now try to create the share */
-       resp->status = nlmsvc_share_file(host, file, argp);
+       resp->status = nlmsvc_share_file(host, file, &lock->oh,
+                                        argp->fsm_access, argp->fsm_mode);
 
        dprintk("lockd: SHARE         status %d\n", ntohl(resp->status));
        nlmsvc_release_lockowner(lock);
@@ -1111,8 +1112,8 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp)
                return resp->status == nlm__int__drop_reply ?
                        rpc_drop_reply : rpc_success;
 
-       /* Now try to lock the file */
-       resp->status = nlmsvc_unshare_file(host, file, argp);
+       /* Now try to unshare the file */
+       resp->status = nlmsvc_unshare_file(host, file, &lock->oh);
 
        dprintk("lockd: UNSHARE       status %d\n", ntohl(resp->status));
        nlmsvc_release_lockowner(lock);
index 75b0dfa1a79a7bd20981eda4a3c072dc5975a95f..749abf8886ba7acb5fa22f93124b49cfb6207b61 100644 (file)
@@ -423,7 +423,9 @@ nlmsvc_proc_share(struct svc_rqst *rqstp)
                        rpc_drop_reply : rpc_success;
 
        /* Now try to create the share */
-       resp->status = cast_status(nlmsvc_share_file(host, file, argp));
+       resp->status = cast_status(nlmsvc_share_file(host, file, &argp->lock.oh,
+                                                    argp->fsm_access,
+                                                    argp->fsm_mode));
 
        dprintk("lockd: SHARE         status %d\n", ntohl(resp->status));
        nlmsvc_release_lockowner(&argp->lock);
@@ -459,7 +461,8 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp)
                        rpc_drop_reply : rpc_success;
 
        /* Now try to unshare the file */
-       resp->status = cast_status(nlmsvc_unshare_file(host, file, argp));
+       resp->status = cast_status(nlmsvc_unshare_file(host, file,
+                                                      &argp->lock.oh));
 
        dprintk("lockd: UNSHARE       status %d\n", ntohl(resp->status));
        nlmsvc_release_lockowner(&argp->lock);
index 8675ac80ab164cc37dcaf3319354d175857d6714..53f5655c128c4de4c47728c569bc087607eef1bc 100644 (file)
@@ -25,12 +25,21 @@ nlm_cmp_owner(struct nlm_share *share, struct xdr_netobj *oh)
            && !memcmp(share->s_owner.data, oh->data, oh->len);
 }
 
+/**
+ * nlmsvc_share_file - create a share
+ * @host: Network client peer
+ * @file: File to be shared
+ * @oh: Share owner handle
+ * @access: Requested access mode
+ * @mode: Requested file sharing mode
+ *
+ * Returns an NLM status code.
+ */
 __be32
 nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file,
-                       struct nlm_args *argp)
+                 struct xdr_netobj *oh, u32 access, u32 mode)
 {
        struct nlm_share        *share;
-       struct xdr_netobj       *oh = &argp->lock.oh;
        u8                      *ohdata;
 
        if (nlmsvc_file_cannot_lock(file))
@@ -39,13 +48,11 @@ nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file,
        for (share = file->f_shares; share; share = share->s_next) {
                if (share->s_host == host && nlm_cmp_owner(share, oh))
                        goto update;
-               if ((argp->fsm_access & share->s_mode)
-                || (argp->fsm_mode   & share->s_access ))
+               if ((access & share->s_mode) || (mode & share->s_access))
                        return nlm_lck_denied;
        }
 
-       share = kmalloc(sizeof(*share) + oh->len,
-                                               GFP_KERNEL);
+       share = kmalloc(sizeof(*share) + oh->len, GFP_KERNEL);
        if (share == NULL)
                return nlm_lck_denied_nolocks;
 
@@ -61,20 +68,24 @@ nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file,
        file->f_shares      = share;
 
 update:
-       share->s_access = argp->fsm_access;
-       share->s_mode   = argp->fsm_mode;
+       share->s_access = access;
+       share->s_mode mode;
        return nlm_granted;
 }
 
-/*
- * Delete a share.
+/**
+ * nlmsvc_unshare_file - delete a share
+ * @host: Network client peer
+ * @file: File to be unshared
+ * @oh: Share owner handle
+ *
+ * Returns an NLM status code.
  */
 __be32
 nlmsvc_unshare_file(struct nlm_host *host, struct nlm_file *file,
-                       struct nlm_args *argp)
+                   struct xdr_netobj *oh)
 {
        struct nlm_share        *share, **shpp;
-       struct xdr_netobj       *oh = &argp->lock.oh;
 
        if (nlmsvc_file_cannot_lock(file))
                return nlm_lck_denied_nolocks;