Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lockd: Prepare share helpers for xdrgen conversion

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>

+36 -21
+4 -4
fs/lockd/share.h
··· 20 20 u32 s_mode; /* deny mode */ 21 21 }; 22 22 23 - __be32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *, 24 - struct nlm_args *); 25 - __be32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *, 26 - struct nlm_args *); 23 + __be32 nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file, 24 + struct xdr_netobj *oh, u32 access, u32 mode); 25 + __be32 nlmsvc_unshare_file(struct nlm_host *host, struct nlm_file *file, 26 + struct xdr_netobj *oh); 27 27 void nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *, 28 28 nlm_host_match_fn_t); 29 29
+4 -3
fs/lockd/svc4proc.c
··· 1072 1072 rpc_drop_reply : rpc_success; 1073 1073 1074 1074 /* Now try to create the share */ 1075 - resp->status = nlmsvc_share_file(host, file, argp); 1075 + resp->status = nlmsvc_share_file(host, file, &lock->oh, 1076 + argp->fsm_access, argp->fsm_mode); 1076 1077 1077 1078 dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); 1078 1079 nlmsvc_release_lockowner(lock); ··· 1112 1111 return resp->status == nlm__int__drop_reply ? 1113 1112 rpc_drop_reply : rpc_success; 1114 1113 1115 - /* Now try to lock the file */ 1116 - resp->status = nlmsvc_unshare_file(host, file, argp); 1114 + /* Now try to unshare the file */ 1115 + resp->status = nlmsvc_unshare_file(host, file, &lock->oh); 1117 1116 1118 1117 dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); 1119 1118 nlmsvc_release_lockowner(lock);
+5 -2
fs/lockd/svcproc.c
··· 423 423 rpc_drop_reply : rpc_success; 424 424 425 425 /* Now try to create the share */ 426 - resp->status = cast_status(nlmsvc_share_file(host, file, argp)); 426 + resp->status = cast_status(nlmsvc_share_file(host, file, &argp->lock.oh, 427 + argp->fsm_access, 428 + argp->fsm_mode)); 427 429 428 430 dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); 429 431 nlmsvc_release_lockowner(&argp->lock); ··· 461 459 rpc_drop_reply : rpc_success; 462 460 463 461 /* Now try to unshare the file */ 464 - resp->status = cast_status(nlmsvc_unshare_file(host, file, argp)); 462 + resp->status = cast_status(nlmsvc_unshare_file(host, file, 463 + &argp->lock.oh)); 465 464 466 465 dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); 467 466 nlmsvc_release_lockowner(&argp->lock);
+23 -12
fs/lockd/svcshare.c
··· 25 25 && !memcmp(share->s_owner.data, oh->data, oh->len); 26 26 } 27 27 28 + /** 29 + * nlmsvc_share_file - create a share 30 + * @host: Network client peer 31 + * @file: File to be shared 32 + * @oh: Share owner handle 33 + * @access: Requested access mode 34 + * @mode: Requested file sharing mode 35 + * 36 + * Returns an NLM status code. 37 + */ 28 38 __be32 29 39 nlmsvc_share_file(struct nlm_host *host, struct nlm_file *file, 30 - struct nlm_args *argp) 40 + struct xdr_netobj *oh, u32 access, u32 mode) 31 41 { 32 42 struct nlm_share *share; 33 - struct xdr_netobj *oh = &argp->lock.oh; 34 43 u8 *ohdata; 35 44 36 45 if (nlmsvc_file_cannot_lock(file)) ··· 48 39 for (share = file->f_shares; share; share = share->s_next) { 49 40 if (share->s_host == host && nlm_cmp_owner(share, oh)) 50 41 goto update; 51 - if ((argp->fsm_access & share->s_mode) 52 - || (argp->fsm_mode & share->s_access )) 42 + if ((access & share->s_mode) || (mode & share->s_access)) 53 43 return nlm_lck_denied; 54 44 } 55 45 56 - share = kmalloc(sizeof(*share) + oh->len, 57 - GFP_KERNEL); 46 + share = kmalloc(sizeof(*share) + oh->len, GFP_KERNEL); 58 47 if (share == NULL) 59 48 return nlm_lck_denied_nolocks; 60 49 ··· 68 61 file->f_shares = share; 69 62 70 63 update: 71 - share->s_access = argp->fsm_access; 72 - share->s_mode = argp->fsm_mode; 64 + share->s_access = access; 65 + share->s_mode = mode; 73 66 return nlm_granted; 74 67 } 75 68 76 - /* 77 - * Delete a share. 69 + /** 70 + * nlmsvc_unshare_file - delete a share 71 + * @host: Network client peer 72 + * @file: File to be unshared 73 + * @oh: Share owner handle 74 + * 75 + * Returns an NLM status code. 78 76 */ 79 77 __be32 80 78 nlmsvc_unshare_file(struct nlm_host *host, struct nlm_file *file, 81 - struct nlm_args *argp) 79 + struct xdr_netobj *oh) 82 80 { 83 81 struct nlm_share *share, **shpp; 84 - struct xdr_netobj *oh = &argp->lock.oh; 85 82 86 83 if (nlmsvc_file_cannot_lock(file)) 87 84 return nlm_lck_denied_nolocks;