Clarify module API boundaries
Subsystems (3)
Chuck Lever
maintainercover Clarify module API boundaries
From: Chuck Lever <[email protected]>
The first nine patches in this series refactor the lockd code base to clearly separate its public API from internal implementation details.
The lockd subsystem currently exposes internal implementation headers through include/linux/lockd/, creating implicit API contracts that complicate maintenance. External consumers such as NFSD and the NFS client have developed dependencies on internal structures like struct nlm_host, and wire protocol constants leak into high-level module interfaces.
These patches work to establish clean architectural boundaries. The public API in include/linux/lockd/ is reduced to bind.h and nlm.h, which define the contract between lockd and its consumers. Private implementation details including XDR definitions, share management, and host structures are relocated to fs/lockd/ where they belong. Layering violations are corrected: the NFS client now uses accessor helpers instead of dereferencing internal structures, and nlm_fopen() returns errno values instead of wire protocol codes.
These changes enable subsequent work to modernize the NLMv4 XDR layer using xdrgen without risk of breaking external consumers. This work appears in the remaining patches in this series, which are presented here only to provide context for the API adjustments. No need to review those closely just yet.
The series is based on commit 771cfff228fc in the public nfsd-testing branch.
Chuck Lever (36):
lockd: Have nlm_fopen() return errno values
lockd: Relocate nlmsvc_unlock API declarations
NFS: Use nlmclnt_rpc_clnt() helper to retrieve nlm_host's rpc_clnt
lockd: Move xdr4.h from include/linux/lockd/ to fs/lockd/
lockd: Move share.h from include/linux/lockd/ to fs/lockd/
lockd: Relocate include/linux/lockd/lockd.h
lockd: Remove lockd/debug.h
lockd: Move xdr.h from include/linux/lockd/ to fs/lockd/
Documentation: Add the RPC language description of NLM version 4
lockd: Use xdrgen XDR functions for the NLMv4 NULL procedure
lockd: Use xdrgen XDR functions for the NLMv4 TEST procedure
lockd: Use xdrgen XDR functions for the NLMv4 LOCK procedure
lockd: Use xdrgen XDR functions for the NLMv4 CANCEL procedure
lockd: Use xdrgen XDR functions for the NLMv4 UNLOCK procedure
lockd: Use xdrgen XDR functions for the NLMv4 GRANTED procedure
lockd: Refactor nlm4svc_callback()
lockd: Use xdrgen XDR functions for the NLMv4 TEST_MSG procedure
lockd: Use xdrgen XDR functions for the NLMv4 LOCK_MSG procedure
lockd: Use xdrgen XDR functions for the NLMv4 CANCEL_MSG procedure
lockd: Use xdrgen XDR functions for the NLMv4 UNLOCK_MSG procedure
lockd: Use xdrgen XDR functions for the NLMv4 GRANTED_MSG procedure
lockd: Convert server-side NLMPROC4_TEST_RES to use xdrgen
lockd: Convert server-side NLMPROC4_LOCK_RES to use xdrgen
lockd: Convert server-side NLMPROC4_CANCEL_RES to use xdrgen
lockd: Convert server-side NLMPROC4_UNLOCK_RES to use xdrgen
lockd: Convert server-side NLMPROC4_GRANTED_RES to use xdrgen
lockd: Use xdrgen XDR functions for the NLMv4 SM_NOTIFY procedure
lockd: Convert server-side undefined procedures to xdrgen
lockd: Hoist file_lock init out of nlm4svc_decode_shareargs()
lockd: Update share_file helpers
lockd: Use xdrgen XDR functions for the NLMv4 SHARE procedure
lockd: Use xdrgen XDR functions for the NLMv4 UNSHARE procedure
lockd: Use xdrgen XDR functions for the NLMv4 NM_LOCK procedure
lockd: Use xdrgen XDR functions for the NLMv4 FREE_ALL procedure
lockd: Remove utilities that are no longer used
lockd: Remove dead code from fs/lockd/xdr4.c
Documentation/sunrpc/xdr/nlm4.x | 211 ++++
fs/lockd/Makefile | 21 +-
fs/lockd/clnt4xdr.c | 5 +-
fs/lockd/clntlock.c | 2 +-
fs/lockd/clntproc.c | 2 +-
fs/lockd/clntxdr.c | 5 +-
fs/lockd/host.c | 2 +-
{include/linux => fs}/lockd/lockd.h | 49 +-
fs/lockd/mon.c | 2 +-
fs/lockd/nlm4xdr_gen.c | 724 +++++++++++++
fs/lockd/nlm4xdr_gen.h | 32 +
{include/linux => fs}/lockd/share.h | 16 +-
fs/lockd/svc.c | 2 +-
fs/lockd/svc4proc.c | 1562 +++++++++++++++++----------
fs/lockd/svclock.c | 5 +-
fs/lockd/svcproc.c | 13 +-
fs/lockd/svcshare.c | 40 +-
fs/lockd/svcsubs.c | 43 +-
fs/lockd/trace.h | 3 +-
fs/lockd/xdr.c | 3 +-
{include/linux => fs}/lockd/xdr.h | 12 +-
fs/lockd/xdr4.c | 347 ------
fs/lockd/xdr4.h | 104 ++
fs/nfs/sysfs.c | 10 +-
fs/nfsd/lockd.c | 51 +-
fs/nfsd/nfsctl.c | 2 +-
include/linux/lockd/bind.h | 17 +-
include/linux/lockd/debug.h | 40 -
include/linux/lockd/xdr4.h | 43 -
include/linux/sunrpc/xdrgen/nlm4.h | 231 ++++
30 files changed, 2513 insertions(+), 1086 deletions(-)
create mode 100644 Documentation/sunrpc/xdr/nlm4.x
rename {include/linux => fs}/lockd/lockd.h (94%)
create mode 100644 fs/lockd/nlm4xdr_gen.c
create mode 100644 fs/lockd/nlm4xdr_gen.h
rename {include/linux => fs}/lockd/share.h (63%)
rename {include/linux => fs}/lockd/xdr.h (94%)
delete mode 100644 fs/lockd/xdr4.c
create mode 100644 fs/lockd/xdr4.h
delete mode 100644 include/linux/lockd/debug.h
delete mode 100644 include/linux/lockd/xdr4.h
create mode 100644 include/linux/sunrpc/xdrgen/nlm4.hSignature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 1/36 lockd: Have nlm_fopen() return errno values
From: Chuck Lever <[email protected]>
The nlm_fopen() function is part of the API between nfsd and lockd.
Currently its return value is an on-the-wire NLM status code. But that means that the definitions of those status codes need to be included in NFSD, which is otherwise uninterested in the NLM wire protocol.
In addition, a CONFIG_LOCKD_V4 Kconfig symbol appears in the middle of NFSD source code.
Refactor: Let's not use on-the-wire values as part of a high-level API between two Linux kernel modules. That's what we have errno for, right?
Perform some additional white-space and internal documentation clean-ups while we're here.
Strictly speaking, nlm_fopen() should eventually be changed to use nfsd_file_acquire_gc() instead of calling nfsd_open() directly.
--- fs/lockd/svcsubs.c | 37 +++++++++++++++++++++++----- fs/nfsd/lockd.c | 50 +++++++++++++++++++++----------------- include/linux/lockd/bind.h | 8 +++--- 3 files changed, 62 insertions(+), 33 deletions(-)
fs/lockd/svcsubs.c +31 -6
@@ -87,14 +87,39 @@ static __be32 nlm_do_fopen(struct svc_rqst *rqstp, struct nlm_file *file, int mode) {struct file **fp = &file->f_file[mode]; -__be32 nfserr; +__be32 nlmerr = nlm_granted; +int error;if (*fp) -return 0 ; - nfserr = nlmsvc_ops->fopen (rqstp, &file->f_handle, fp, mode); -if (nfserr) -dprintk ("lockd: open failed (error %d)\n" , nfserr); -return nfserr; +return nlmerr; + + error = nlmsvc_ops->fopen (rqstp, &file->f_handle, fp, mode); +if (error) { +dprintk ("lockd: open failed (errno %d)\n" , error); +switch (error) { +case -EWOULDBLOCK : + nlmerr = nlm_drop_reply; +break ; +case -ESTALE : +#ifdef CONFIG_LOCKD_V4 +/* cast_status() converts this for NLMv3 requests */ + nlmerr = nlm4_stale_fh; +#else + nlmerr = nlm_lck_denied_nolocks; +#endif +break ; +default : +#ifdef CONFIG_LOCKD_V4 +/* cast_status() converts this for NLMv3 requests */ + nlmerr = nlm4_failed; +#else + nlmerr = nlm_lck_denied_nolocks; +#endif +break ; + } + } + +return nlmerr; }/*
fs/nfsd/lockd.c +28 -22
84 lines not on this page · raw message
include/linux/lockd/bind.h +3 -5
@@ -26,11 +26,9 @@ struct rpc_clnt;* This is the set of functions for lockd->nfsd communication */ struct nlmsvc_binding { -__be32 (*fopen)(struct svc_rqst *, -struct nfs_fh *, -struct file **, -int mode); -void (*fclose)(struct file *); +int (*fopen)(struct svc_rqst *rqstp,struct nfs_fh *f, +struct file **filp,int flags); +void (*fclose)(struct file *filp); };extern const struct nlmsvc_binding *nlmsvc_ops;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 2/36 lockd: Relocate nlmsvc_unlock API declarations
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
The nlmsvc_unlock_all_by_sb() and nlmsvc_unlock_all_by_ip() functions are part of lockd's external API, consumed by other kernel subsystems. Their declarations currently reside in linux/lockd/lockd.h alongside internal implementation details, which blurs the boundary between lockd's public interface and its private internals.
Moving these declarations to linux/lockd/bind.h groups them with other external API functions and makes the separation explicit. This clarifies which functions are intended for external use and reduces the risk of internal implementation details leaking into the public API surface.
Build-tested with allyesconfig; no functional changes.
--- fs/nfsd/lockd.c | 1 + fs/nfsd/nfsctl.c | 2 +- include/linux/lockd/bind.h | 3 +++ include/linux/lockd/lockd.h | 6 ------ 4 files changed, 5 insertions(+), 7 deletions(-)
fs/nfsd/lockd.c +1 -0
@@ -8,6 +8,7 @@*/ #include <linux/file.h> +#include <linux/fs.h> #include <linux/lockd/bind.h> #include "nfsd.h" #include "vfs.h"
fs/nfsd/nfsctl.c +1 -1
@@ -11,7 +11,7 @@#include <linux/fs_context.h> #include <linux/sunrpc/svcsock.h> -#include <linux/lockd/lockd.h> +#include <linux/lockd/bind.h> #include <linux/sunrpc/addr.h> #include <linux/sunrpc/gss_api.h> #include <linux/sunrpc/rpc_pipe_fs.h>
include/linux/lockd/bind.h +3 -0
@@ -80,4 +80,7 @@ extern int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, voextern int lockd_up (struct net *net,const struct cred *cred);extern void lockd_down (struct net *net); +int nlmsvc_unlock_all_by_sb (struct super_block *sb); +int nlmsvc_unlock_all_by_ip (struct sockaddr *server_addr); +#endif /* LINUX_LOCKD_BIND_H */
include/linux/lockd/lockd.h +0 -6
@@ -302,12 +302,6 @@ void nlmsvc_mark_resources(struct net *);void nlmsvc_free_host_resources (struct nlm_host *);void nlmsvc_invalidate_all (void ); -/* -* Cluster failover support -*/ -int nlmsvc_unlock_all_by_sb (struct super_block *sb); -int nlmsvc_unlock_all_by_ip (struct sockaddr *server_addr); -static inline struct file *nlmsvc_file_file (const struct nlm_file *file) { return file->f_file[O_RDONLY] ?
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 3/36 NFS: Use nlmclnt_rpc_clnt() helper to retrieve nlm_host's rpc_clnt
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
The external API definitions for lockd reside in linux/lockd/bind.h. Because "struct nlm_host" is an internal lockd structure, bind.h does not include a definition of it. Dereferencing that structure outside of lockd violates the layering boundary between NFS and lockd.
The proper approach is to use the nlmclnt_rpc_clnt() helper function already provided in lockd/bind.h, which retrieves the NLM host's struct rpc_clnt without exposing internal lockd structures. This maintains clean separation between the NFS client and lockd internals.
Note that the nlm_host's h_rpcclnt field can be NULL during initialization (host.c:141) or after cleanup (host.c:629). Add a NULL check before calling shutdown_client() to prevent a potential NULL pointer dereference in the sysfs shutdown path.
--- fs/nfs/sysfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/nfs/sysfs.c +7 -3
@@ -12,7 +12,7 @@#include <linux/string.h> #include <linux/nfs_fs.h> #include <linux/rcupdate.h> -#include <linux/lockd/lockd.h> +#include <linux/lockd/bind.h> #include "internal.h" #include "nfs4_fs.h"
@@ -284,8 +284,12 @@ shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,if (!IS_ERR (server->client_acl))shutdown_client (server->client_acl); -if (server->nlm_host) -shutdown_client (server->nlm_host->h_rpcclnt); +if (server->nlm_host) { +struct rpc_clnt *nlm_clnt =nlmclnt_rpc_clnt (server->nlm_host); + +if (nlm_clnt) +shutdown_client (nlm_clnt); + } out:shutdown_nfs_client (server->nfs_client);return count;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 4/36 lockd: Move xdr4.h from include/linux/lockd/ to fs/lockd/
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
The xdr4.h header declares NLMv4-specific XDR encoder/decoder functions and error codes that are used exclusively within the lockd subsystem. Moving it from include/linux/lockd/ to fs/lockd/ clarifies the intended scope of these declarations and prevents external code from depending on lockd-internal interfaces.
This change reduces the public API surface of the lockd module and makes it easier to refactor NLMv4 internals without risk of breaking out-of-tree consumers. The header's contents are implementation details of the NLMv4 wire protocol handling, not a contract with other kernel subsystems.
---
fs/lockd/clnt4xdr.c | 2 ++
fs/lockd/clntxdr.c | 2 ++
fs/lockd/svc4proc.c | 2 ++
fs/lockd/svclock.c | 2 ++
fs/lockd/svcproc.c | 2 ++
fs/lockd/svcsubs.c | 2 ++
fs/lockd/xdr4.c | 1 +
{include/linux => fs}/lockd/xdr4.h | 13 +++----------
include/linux/lockd/bind.h | 3 ---
include/linux/lockd/lockd.h | 3 ---
10 files changed, 16 insertions(+), 16 deletions(-)
rename {include/linux => fs}/lockd/xdr4.h (87%)fs/lockd/clnt4xdr.c +2 -0
@@ -17,6 +17,8 @@#include <uapi/linux/nfs3.h> +#include "xdr4.h" +#define NLMDBG_FACILITY NLMDBG_XDR#if (NLMCLNT_OHSIZE >XDR_MAX_NETOBJ )
fs/lockd/clntxdr.c +2 -0
@@ -19,6 +19,8 @@#include <uapi/linux/nfs2.h> +#include "xdr4.h" +#define NLMDBG_FACILITY NLMDBG_XDR#if (NLMCLNT_OHSIZE >XDR_MAX_NETOBJ )
fs/lockd/svc4proc.c +2 -0
@@ -14,6 +14,8 @@#include <linux/lockd/share.h> #include <linux/sunrpc/svc_xprt.h> +#include "xdr4.h" +#define NLMDBG_FACILITY NLMDBG_CLIENT/*
fs/lockd/svclock.c +2 -0
@@ -31,6 +31,8 @@#include <linux/lockd/nlm.h> #include <linux/lockd/lockd.h> +#include "xdr4.h" +#define NLMDBG_FACILITY NLMDBG_SVCLOCK#ifdef CONFIG_LOCKD_V4
fs/lockd/svcproc.c +2 -0
@@ -14,6 +14,8 @@#include <linux/lockd/share.h> #include <linux/sunrpc/svc_xprt.h> +#include "xdr4.h" +#define NLMDBG_FACILITY NLMDBG_CLIENT#ifdef CONFIG_LOCKD_V4
fs/lockd/svcsubs.c +2 -0
@@ -21,6 +21,8 @@#include <linux/mount.h> #include <uapi/linux/nfs2.h> +#include "xdr4.h" +#define NLMDBG_FACILITY NLMDBG_SVCSUBS
fs/lockd/xdr4.c +1 -0
@@ -19,6 +19,7 @@#include <linux/lockd/lockd.h> #include "svcxdr.h" +#include "xdr4.h" static inline s64 loff_t_to_s64 (loff_t offset)
fs/lockd/xdr4.h renamed from include/linux/lockd/xdr4.h +3 -10
@@ -1,19 +1,12 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* linux/include/linux/lockd/xdr4.h -* * XDR types for the NLM protocol * * Copyright (C) 1996 Olaf Kirch <[email protected]> */ -#ifndef LOCKD_XDR4_H -#define LOCKD_XDR4_H - -#include <linux/fs.h> -#include <linux/nfs.h> -#include <linux/sunrpc/xdr.h> -#include <linux/lockd/xdr.h> +#ifndef _LOCKD_XDR4_H +#define _LOCKD_XDR4_H/* error codes new to NLMv4 */ #define nlm4_deadlock cpu_to_be32(NLM_DEADLCK)
@@ -40,4 +33,4 @@ bool nlm4svc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr);extern const struct rpc_version nlm_version4; -#endif /* LOCKD_XDR4_H */ +#endif /* _LOCKD_XDR4_H */
include/linux/lockd/bind.h +0 -3
@@ -13,9 +13,6 @@#include <linux/lockd/nlm.h> /* need xdr-encoded error codes too, so... */ #include <linux/lockd/xdr.h> -#ifdef CONFIG_LOCKD_V4 -#include <linux/lockd/xdr4.h> -#endif /* Dummy declarations */ struct svc_rqst ;
include/linux/lockd/lockd.h +0 -3
@@ -22,9 +22,6 @@#include <linux/utsname.h> #include <linux/lockd/bind.h> #include <linux/lockd/xdr.h> -#ifdef CONFIG_LOCKD_V4 -#include <linux/lockd/xdr4.h> -#endif #include <linux/lockd/debug.h> #include <linux/sunrpc/svc.h>
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 5/36 lockd: Move share.h from include/linux/lockd/ to fs/lockd/
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
The share.h header declares struct nlm_share and the DOS share management functions used by the NLM server to implement NLM_SHARE and NLM_UNSHARE operations. These interfaces are used exclusively within the lockd subsystem and are not referenced by any external code.
Relocating this header from include/linux/lockd/ to fs/lockd/ narrows the public API surface of the lockd module and prevents out-of-tree code from depending on these internal interfaces. Future refactoring of the share management implementation can proceed without concern for breaking external consumers.
---
{include/linux => fs}/lockd/share.h | 8 +++-----
fs/lockd/svc4proc.c | 2 +-
fs/lockd/svcproc.c | 2 +-
fs/lockd/svcshare.c | 3 ++-
fs/lockd/svcsubs.c | 2 +-
include/linux/lockd/lockd.h | 2 ++
6 files changed, 10 insertions(+), 9 deletions(-)
rename {include/linux => fs}/lockd/share.h (85%)fs/lockd/share.h renamed from include/linux/lockd/share.h +3 -5
@@ -1,14 +1,12 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* linux/include/linux/lockd/share.h -* * DOS share management for lockd. * * Copyright (C) 1996, Olaf Kirch <[email protected]> */ -#ifndef LINUX_LOCKD_SHARE_H -#define LINUX_LOCKD_SHARE_H +#ifndef _LOCKD_SHARE_H +#define _LOCKD_SHARE_H/* * DOS share for a specific file
@@ -29,4 +27,4 @@ __be32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *,void nlmsvc_traverse_shares (struct nlm_host *,struct nlm_file *,nlm_host_match_fn_t ); -#endif /* LINUX_LOCKD_SHARE_H */ +#endif /* _LOCKD_SHARE_H */
fs/lockd/svc4proc.c +1 -1
@@ -11,9 +11,9 @@#include <linux/types.h> #include <linux/time.h> #include <linux/lockd/lockd.h> -#include <linux/lockd/share.h> #include <linux/sunrpc/svc_xprt.h> +#include "share.h" #include "xdr4.h" #define NLMDBG_FACILITY NLMDBG_CLIENT
fs/lockd/svcproc.c +1 -1
@@ -11,9 +11,9 @@#include <linux/types.h> #include <linux/time.h> #include <linux/lockd/lockd.h> -#include <linux/lockd/share.h> #include <linux/sunrpc/svc_xprt.h> +#include "share.h" #include "xdr4.h" #define NLMDBG_FACILITY NLMDBG_CLIENT
fs/lockd/svcshare.c +2 -1
@@ -15,7 +15,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc.h> #include <linux/lockd/lockd.h> -#include <linux/lockd/share.h> + +#include "share.h" static inline int nlm_cmp_owner (struct nlm_share *share,struct xdr_netobj *oh)
fs/lockd/svcsubs.c +1 -1
@@ -16,11 +16,11 @@#include <linux/sunrpc/svc.h> #include <linux/sunrpc/addr.h> #include <linux/lockd/lockd.h> -#include <linux/lockd/share.h> #include <linux/module.h> #include <linux/mount.h> #include <uapi/linux/nfs2.h> +#include "share.h" #include "xdr4.h" #define NLMDBG_FACILITY NLMDBG_SVCSUBS
include/linux/lockd/lockd.h +2 -0
@@ -146,6 +146,8 @@ struct nlm_rqst {void * a_callback_data;/* sent to nlmclnt_operations callbacks */ }; +struct nlm_share ; +/* * This struct describes a file held open by lockd on behalf of * an NFS client.
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 6/36 lockd: Relocate include/linux/lockd/lockd.h
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Headers placed in include/linux/ form part of the kernel's internal API and signal to subsystem maintainers that other parts of the kernel may depend on them. By moving lockd.h into fs/lockd/, lockd becomes a more self-contained module whose internal interfaces are clearly distinguished from its public contract with the rest of the kernel. This relocation addresses a long-standing XXX comment in the header itself that acknowledged the file's misplacement. Future changes to lockd internals can now proceed with confidence that external consumers are not inadvertently coupled to implementation details.
---
fs/lockd/clnt4xdr.c | 3 ++-
fs/lockd/clntlock.c | 2 +-
fs/lockd/clntproc.c | 2 +-
fs/lockd/clntxdr.c | 3 ++-
fs/lockd/host.c | 2 +-
{include/linux => fs}/lockd/lockd.h | 12 +++---------
fs/lockd/mon.c | 2 +-
fs/lockd/svc.c | 2 +-
fs/lockd/svc4proc.c | 2 +-
fs/lockd/svclock.c | 3 ++-
fs/lockd/svcproc.c | 2 +-
fs/lockd/svcshare.c | 2 +-
fs/lockd/svcsubs.c | 2 +-
fs/lockd/trace.h | 3 ++-
fs/lockd/xdr.c | 3 +--
fs/lockd/xdr4.c | 2 +-
16 files changed, 22 insertions(+), 25 deletions(-)
rename {include/linux => fs}/lockd/lockd.h (98%)fs/lockd/clnt4xdr.c +2 -1
@@ -13,7 +13,8 @@#include <linux/sunrpc/xdr.h> #include <linux/sunrpc/clnt.h> #include <linux/sunrpc/stats.h> -#include <linux/lockd/lockd.h> + +#include "lockd.h" #include <uapi/linux/nfs3.h>
fs/lockd/clntlock.c +1 -1
@@ -15,9 +15,9 @@#include <linux/sunrpc/addr.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/svc_xprt.h> -#include <linux/lockd/lockd.h> #include <linux/kthread.h> +#include "lockd.h" #include "trace.h" #define NLMDBG_FACILITY NLMDBG_CLIENT
fs/lockd/clntproc.c +1 -1
@@ -18,8 +18,8 @@#include <linux/freezer.h> #include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc.h> -#include <linux/lockd/lockd.h> +#include "lockd.h" #include "trace.h" #define NLMDBG_FACILITY NLMDBG_CLIENT
fs/lockd/clntxdr.c +2 -1
@@ -15,7 +15,8 @@#include <linux/sunrpc/xdr.h> #include <linux/sunrpc/clnt.h> #include <linux/sunrpc/stats.h> -#include <linux/lockd/lockd.h> + +#include "lockd.h" #include <uapi/linux/nfs2.h>
fs/lockd/host.c +1 -1
@@ -16,13 +16,13 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/addr.h> #include <linux/sunrpc/svc.h> -#include <linux/lockd/lockd.h> #include <linux/mutex.h> #include <linux/sunrpc/svc_xprt.h> #include <net/ipv6.h> +#include "lockd.h" #include "netns.h" #define NLMDBG_FACILITY NLMDBG_HOSTCACHE
fs/lockd/lockd.h renamed from include/linux/lockd/lockd.h +3 -9
@@ -1,16 +1,10 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* linux/include/linux/lockd/lockd.h -* -* General-purpose lockd include file. -* * Copyright (C) 1996 Olaf Kirch <[email protected]> */ -#ifndef LINUX_LOCKD_LOCKD_H -#define LINUX_LOCKD_LOCKD_H - -/* XXX: a lot of this should really be under fs/lockd. */ +#ifndef _LOCKD_LOCKD_H +#define _LOCKD_LOCKD_H#include <linux/exportfs.h> #include <linux/in.h>
@@ -385,4 +379,4 @@ static inline int nlm_compare_locks(const struct file_lock *fl1,extern const struct lock_manager_operations nlmsvc_lock_operations; -#endif /* LINUX_LOCKD_LOCKD_H */ +#endif /* _LOCKD_LOCKD_H */
fs/lockd/mon.c +1 -1
@@ -16,10 +16,10 @@#include <linux/sunrpc/addr.h> #include <linux/sunrpc/xprtsock.h> #include <linux/sunrpc/svc.h> -#include <linux/lockd/lockd.h> #include <linux/unaligned.h> +#include "lockd.h" #include "netns.h" #define NLMDBG_FACILITY NLMDBG_MONITOR
fs/lockd/svc.c +1 -1
@@ -36,9 +36,9 @@#include <net/ip.h> #include <net/addrconf.h> #include <net/ipv6.h> -#include <linux/lockd/lockd.h> #include <linux/nfs.h> +#include "lockd.h" #include "netns.h" #include "procfs.h" #include "netlink.h"
fs/lockd/svc4proc.c +1 -1
@@ -10,9 +10,9 @@#include <linux/types.h> #include <linux/time.h> -#include <linux/lockd/lockd.h> #include <linux/sunrpc/svc_xprt.h> +#include "lockd.h" #include "share.h" #include "xdr4.h"
fs/lockd/svclock.c +2 -1
@@ -29,7 +29,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/lockd/nlm.h> -#include <linux/lockd/lockd.h> + +#include "lockd.h" #include "xdr4.h"
fs/lockd/svcproc.c +1 -1
@@ -10,9 +10,9 @@#include <linux/types.h> #include <linux/time.h> -#include <linux/lockd/lockd.h> #include <linux/sunrpc/svc_xprt.h> +#include "lockd.h" #include "share.h" #include "xdr4.h"
fs/lockd/svcshare.c +1 -1
@@ -14,8 +14,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc.h> -#include <linux/lockd/lockd.h> +#include "lockd.h" #include "share.h" static inline int
fs/lockd/svcsubs.c +1 -1
@@ -15,11 +15,11 @@#include <linux/mutex.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/addr.h> -#include <linux/lockd/lockd.h> #include <linux/module.h> #include <linux/mount.h> #include <uapi/linux/nfs2.h> +#include "lockd.h" #include "share.h" #include "xdr4.h"
fs/lockd/trace.h +2 -1
@@ -8,7 +8,8 @@#include <linux/tracepoint.h> #include <linux/crc32.h> #include <linux/nfs.h> -#include <linux/lockd/lockd.h> + +#include "lockd.h" #ifdef CONFIG_LOCKD_V4 #define NLM_STATUS_LIST \
fs/lockd/xdr.c +1 -2
@@ -15,13 +15,12 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/stats.h> -#include <linux/lockd/lockd.h> #include <uapi/linux/nfs2.h> +#include "lockd.h" #include "svcxdr.h" -static inline loff_t s32_to_loff_t (__s32 offset) {
fs/lockd/xdr4.c +1 -1
@@ -16,8 +16,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/stats.h> -#include <linux/lockd/lockd.h> +#include "lockd.h" #include "svcxdr.h" #include "xdr4.h"
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 7/36 lockd: Remove lockd/debug.h
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
The lockd include structure has unnecessary indirection. The header include/linux/lockd/debug.h is consumed only by fs/lockd/lockd.h, creating an extra compilation dependency and making the code harder to navigate.
Fold the debug.h definitions directly into lockd.h and remove the now-redundant header. This reduces the include tree depth and makes the debug-related definitions easier to find when working on lockd internals.
Build-tested with lockd built as module and built-in.
--- fs/lockd/lockd.h | 24 +++++++++++++++++++++- include/linux/lockd/debug.h | 40 ------------------------------------- 2 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 include/linux/lockd/debug.h
fs/lockd/lockd.h +23 -1
@@ -16,9 +16,31 @@#include <linux/utsname.h> #include <linux/lockd/bind.h> #include <linux/lockd/xdr.h> -#include <linux/lockd/debug.h> +#include <linux/sunrpc/debug.h> #include <linux/sunrpc/svc.h> +/* +* Enable lockd debugging. +* Requires RPC_DEBUG. +*/ +#undef ifdebug +#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) +# define ifdebug (flag) if (unlikely(nlm_debug & NLMDBG_##flag)) +#else +# define ifdebug (flag) if (0) +#endif + +#define NLMDBG_SVC 0x0001 +#define NLMDBG_CLIENT 0x0002 +#define NLMDBG_CLNTLOCK 0x0004 +#define NLMDBG_SVCLOCK 0x0008 +#define NLMDBG_MONITOR 0x0010 +#define NLMDBG_CLNTSUBS 0x0020 +#define NLMDBG_SVCSUBS 0x0040 +#define NLMDBG_HOSTCACHE 0x0080 +#define NLMDBG_XDR 0x0100 +#define NLMDBG_ALL 0x7fff +/* * Version string */
include/linux/lockd/debug.h deleted +0 -40
@@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* linux/include/linux/lockd/debug.h -* -* Debugging stuff. -* -* Copyright (C) 1996 Olaf Kirch <[email protected]> -*/ - -#ifndef LINUX_LOCKD_DEBUG_H -#define LINUX_LOCKD_DEBUG_H - -#include <linux/sunrpc/debug.h> - -/* -* Enable lockd debugging. -* Requires RPC_DEBUG. -*/ -#undef ifdebug -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) -# define ifdebug (flag) if (unlikely(nlm_debug & NLMDBG_##flag)) -#else -# define ifdebug (flag) if (0) -#endif - -/* -* Debug flags -*/ -#define NLMDBG_SVC 0x0001 -#define NLMDBG_CLIENT 0x0002 -#define NLMDBG_CLNTLOCK 0x0004 -#define NLMDBG_SVCLOCK 0x0008 -#define NLMDBG_MONITOR 0x0010 -#define NLMDBG_CLNTSUBS 0x0020 -#define NLMDBG_SVCSUBS 0x0040 -#define NLMDBG_HOSTCACHE 0x0080 -#define NLMDBG_XDR 0x0100 -#define NLMDBG_ALL 0x7fff - -#endif /* LINUX_LOCKD_DEBUG_H */
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 8/36 lockd: Move xdr.h from include/linux/lockd/ to fs/lockd/
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
The lockd subsystem unnecessarily exposes internal NLM XDR type definitions through the global include path. These definitions are not used by any code outside fs/lockd/, making them inappropriate for include/linux/lockd/.
Moving xdr.h to fs/lockd/ narrows the API surface and clarifies that these types are internal implementation details. The comment in linux/lockd/bind.h claiming xdr.h was needed for "xdr-encoded error codes" is stale: no lockd API consumers actually use those codes. A forward declaration for struct nfs_fh is needed because its definition was previously pulled in transitively through xdr.h.
Built and tested with lockd client/server operations. No functional change.
---
fs/lockd/lockd.h | 2 +-
{include/linux => fs}/lockd/xdr.h | 8 +++-----
include/linux/lockd/bind.h | 3 +--
3 files changed, 5 insertions(+), 8 deletions(-)
rename {include/linux => fs}/lockd/xdr.h (96%)fs/lockd/lockd.h +1 -1
@@ -15,7 +15,7 @@#include <linux/refcount.h> #include <linux/utsname.h> #include <linux/lockd/bind.h> -#include <linux/lockd/xdr.h> +#include "xdr.h" #include <linux/sunrpc/debug.h> #include <linux/sunrpc/svc.h>
fs/lockd/xdr.h renamed from include/linux/lockd/xdr.h +3 -5
@@ -1,14 +1,12 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* linux/include/linux/lockd/xdr.h -* * XDR types for the NLM protocol * * Copyright (C) 1996 Olaf Kirch <[email protected]> */ -#ifndef LOCKD_XDR_H -#define LOCKD_XDR_H +#ifndef _LOCKD_XDR_H +#define _LOCKD_XDR_H#include <linux/fs.h> #include <linux/filelock.h>
@@ -112,4 +110,4 @@ bool nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);bool nlmsvc_encode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nlmsvc_encode_shareres (struct svc_rqst *rqstp,struct xdr_stream *xdr); -#endif /* LOCKD_XDR_H */ +#endif /* _LOCKD_XDR_H */
include/linux/lockd/bind.h +1 -2
@@ -11,10 +11,9 @@#define LINUX_LOCKD_BIND_H #include <linux/lockd/nlm.h> -/* need xdr-encoded error codes too, so... */ -#include <linux/lockd/xdr.h> /* Dummy declarations */ +struct nfs_fh ;struct svc_rqst ;struct rpc_task ;struct rpc_clnt ;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 9/36 Documentation: Add the RPC language description of NLM version 4
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
In order to generate source code to encode and decode NLMv4 protocol elements, include a copy of the RPC language description of NLMv4 for xdrgen to process. The language description is an amalgam of RFC 1813 and the Open Group's XNFS specification:
https://pubs.opengroup.org/onlinepubs/9629799/chap10.htm
The C code committed here was generated from the new nlm4.x file using tools/net/sunrpc/xdrgen/xdrgen.
The goals of replacing hand-written XDR functions with ones that are tool-generated are to improve memory safety and make XDR encoding and decoding less brittle to maintain. Parts of the NFSv4 protocol are still being extended actively. Tool-generated XDR code reduces the time it takes to get a working implementation of new protocol elements.
The xdrgen utility derives both the type definitions and the encode/decode functions directly from protocol specifications, using names and symbols familiar to anyone who knows those specs. Unlike hand-written code that can inadvertently diverge from the specification, xdrgen guarantees that the generated code matches the specification exactly.
We would eventually like xdrgen to generate Rust code as well, making the conversion of the kernel's NFS stacks to use Rust just a little easier for us.
--- Documentation/sunrpc/xdr/nlm4.x | 211 +++++++++ fs/lockd/Makefile | 21 +- fs/lockd/nlm4xdr_gen.c | 724 +++++++++++++++++++++++++++++ fs/lockd/nlm4xdr_gen.h | 32 ++ fs/lockd/svc4proc.c | 1 + fs/lockd/xdr.h | 4 +- fs/lockd/xdr4.h | 2 + include/linux/sunrpc/xdrgen/nlm4.h | 231 +++++++++ 8 files changed, 1222 insertions(+), 4 deletions(-) create mode 100644 Documentation/sunrpc/xdr/nlm4.x create mode 100644 fs/lockd/nlm4xdr_gen.c create mode 100644 fs/lockd/nlm4xdr_gen.h create mode 100644 include/linux/sunrpc/xdrgen/nlm4.h
Documentation/sunrpc/xdr/nlm4.x new file +211 -0
@@ -0,0 +1,211 @@ +/* + * This file was extracted by hand from + * https://www.rfc-editor.org/rfc/rfc1813.html . + * + * Note that RFC 1813 is Informational. Its official date of + * publication (June 1995) is before the IETF required its RFCs to + * carry an explicit copyright or other IP ownership notices. + * + * Note also that RFC 1813 does not specify the whole NLM4 protocol. + * In particular, the argument and result types are not present in + * that document, and had to be reverse-engineered. + */ + +/* + * The NLMv4 protocol + */ + +pragma header nlm4; + +/* + * The following definitions are missing in RFC 1813, + * but can be found in the OpenNetworking Network Lock + * Manager protocol: + * + * https://pubs.opengroup.org/onlinepubs/9629799/chap10.htm + */ + +const LM_MAXSTRLEN = 1024; + +const LM_MAXNAMELEN = 1025; + +const MAXNETOBJ_SZ = 1024; + +typedef opaque netobj<MAXNETOBJ_SZ>; + +enum fsh4_mode { + fsm_DN = 0, + fsm_DR = 1, + fsm_DW = 2, + fsm_DRW = 3 +}; + +enum fsh4_access { + fsa_NONE = 0, + fsa_R = 1, + fsa_W = 2, + fsa_RW = 3 +}; + +/* + * The following definitions come from the OpenNetworking + * Network Status Monitor protocol: + * + * https://pubs.opengroup.org/onlinepubs/9629799/chap11.htm + */ + +const SM_MAXSTRLEN = 1024; + +/* + * The NLM protocol as extracted from: + * https://tools.ietf.org/html/rfc1813 Appendix II + */ + +typedef unsigned hyper uint64; + +typedef hyper int64; + +typedef unsigned long uint32; + +typedef long int32; + +enum nlm4_stats { + NLM4_GRANTED = 0, + NLM4_DENIED = 1, + NLM4_DENIED_NOLOCKS = 2, + NLM4_BLOCKED = 3, + NLM4_DENIED_GRACE_PERIOD = 4, + NLM4_DEADLCK = 5, + NLM4_ROFS = 6, + NLM4_STALE_FH = 7, + NLM4_FBIG = 8, + NLM4_FAILED = 9 +}; + +pragma big_endian nlm4_stats; + +struct nlm4_holder { + bool exclusive; + int32 svid; + netobj oh; + uint64 l_offset; + uint64 l_len; +}; + +union nlm4_testrply switch (nlm4_stats stat) { + case NLM4_DENIED: + nlm4_holder holder; + default: + void; +}; + +struct nlm4_stat { + nlm4_stats stat; +}; + +struct nlm4_res { + netobj cookie; + nlm4_stat stat; +}; + +struct nlm4_testres { + netobj cookie; + nlm4_testrply stat; +}; + +struct nlm4_lock { + string caller_name<LM_MAXSTRLEN>; + netobj fh; + netobj oh; + int32 svid; + uint64 l_offset; + uint64 l_len; +}; + +struct nlm4_lockargs { + netobj cookie; + bool block; + bool exclusive; + nlm4_lock alock; + bool reclaim; + int32 state; +}; + +struct nlm4_cancargs { + netobj cookie; + bool block; + bool exclusive; + nlm4_lock alock; +}; + +struct nlm4_testargs { + netobj cookie; + bool exclusive; + nlm4_lock alock; +}; + +struct nlm4_unlockargs { + netobj cookie; + nlm4_lock alock; +}; + +struct nlm4_share { + string caller_name<LM_MAXSTRLEN>; + netobj fh; + netobj oh; + fsh4_mode mode; + fsh4_access access; +}; + +struct nlm4_shareargs { + netobj cookie; + nlm4_share share; + bool reclaim; +}; + +struct nlm4_shareres { + netobj cookie; + nlm4_stats stat; + int32 sequence; +}; + +struct nlm4_notify { + string name<LM_MAXNAMELEN>; + int32 state; +}; + +/* + * Argument for the Linux-private SM_NOTIFY procedure + */ +const SM_PRIV_SIZE = 16; + +struct nlm4_notifyargs { + nlm4_notify notify; + opaque private[SM_PRIV_SIZE]; +}; + +program NLM4_PROG { + version NLM4_VERS { + void NLMPROC4_NULL(void) = 0; + nlm4_testres NLMPROC4_TEST(nlm4_testargs) = 1; + nlm4_res NLMPROC4_LOCK(nlm4_lockargs) = 2; + nlm4_res NLMPROC4_CANCEL(nlm4_cancargs) = 3; + nlm4_res NLMPROC4_UNLOCK(nlm4_unlockargs) = 4; + nlm4_res NLMPROC4_GRANTED(nlm4_testargs) = 5; + void NLMPROC4_TEST_MSG(nlm4_testargs) = 6; + void NLMPROC4_LOCK_MSG(nlm4_lockargs) = 7; + void NLMPROC4_CANCEL_MSG(nlm4_cancargs) = 8; + void NLMPROC4_UNLOCK_MSG(nlm4_unlockargs) = 9; + void NLMPROC4_GRANTED_MSG(nlm4_testargs) = 10; + void NLMPROC4_TEST_RES(nlm4_testres) = 11; + void NLMPROC4_LOCK_RES(nlm4_res) = 12; + void NLMPROC4_CANCEL_RES(nlm4_res) = 13; + void NLMPROC4_UNLOCK_RES(nlm4_res) = 14; + void NLMPROC4_GRANTED_RES(nlm4_res) = 15; + void NLMPROC4_SM_NOTIFY(nlm4_notifyargs) = 16; + nlm4_shareres NLMPROC4_SHARE(nlm4_shareargs) = 20; + nlm4_shareres NLMPROC4_UNSHARE(nlm4_shareargs) = 21; + nlm4_res NLMPROC4_NM_LOCK(nlm4_lockargs) = 22; + void NLMPROC4_FREE_ALL(nlm4_notify) = 23; + } = 4; +} = 100021;
fs/lockd/Makefile +20 -1
@@ -9,5 +9,24 @@ obj-$(CONFIG_LOCKD) += lockd.o lockd-y := clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \ svcshare.o svcproc.o svcsubs.o mon.o trace.o xdr.o netlink.o -lockd-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o +lockd-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o nlm4xdr_gen.o lockd-$(CONFIG_PROC_FS) += procfs.o + +.PHONY: xdrgen + +XDRGEN = ../../tools/net/sunrpc/xdrgen/xdrgen + +XDRGEN_DEFINITIONS = ../../include/linux/sunrpc/xdrgen/nlm4.h +XDRGEN_DECLARATIONS = nlm4xdr_gen.h +XDRGEN_SOURCE = nlm4xdr_gen.c + +xdrgen: $(XDRGEN_DEFINITIONS) $(XDRGEN_DECLARATIONS) $(XDRGEN_SOURCE) + +../../include/linux/sunrpc/xdrgen/nlm4.h: ../../Documentation/sunrpc/xdr/nlm4.x + $(XDRGEN) definitions $< > $@ + +nlm4xdr_gen.h: ../../Documentation/sunrpc/xdr/nlm4.x + $(XDRGEN) declarations $< > $@ + +nlm4xdr_gen.c: ../../Documentation/sunrpc/xdr/nlm4.x + $(XDRGEN) source --peer server $< > $@
fs/lockd/nlm4xdr_gen.c new file +724 -0
724 lines not on this page · raw message
fs/lockd/nlm4xdr_gen.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification file: ../../Documentation/sunrpc/xdr/nlm4.x */ +/* XDR specification modification time: Thu Dec 18 15:01:58 2025 */ + +#ifndef _LINUX_XDRGEN_NLM4_DECL_H +#define _LINUX_XDRGEN_NLM4_DECL_H + +#include <linux/types.h> + +#include <linux/sunrpc/xdr.h> +#include <linux/sunrpc/xdrgen/_defs.h> +#include <linux/sunrpc/xdrgen/_builtins.h> +#include <linux/sunrpc/xdrgen/nlm4.h> + +bool nlm4_svc_decode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_testargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_lockargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_cancargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_unlockargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_testres (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_res (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_notifyargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_shareargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_decode_nlm4_notify (struct svc_rqst *rqstp,struct xdr_stream *xdr); + +bool nlm4_svc_encode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_encode_nlm4_testres (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_encode_nlm4_res (struct svc_rqst *rqstp,struct xdr_stream *xdr); +bool nlm4_svc_encode_nlm4_shareres (struct svc_rqst *rqstp,struct xdr_stream *xdr); + +#endif /* _LINUX_XDRGEN_NLM4_DECL_H */
fs/lockd/svc4proc.c +1 -0
@@ -14,6 +14,7 @@#include "lockd.h" #include "share.h" +#include "nlm4xdr_gen.h" #include "xdr4.h" #define NLMDBG_FACILITY NLMDBG_CLIENT
fs/lockd/xdr.h +1 -3
@@ -12,9 +12,7 @@#include <linux/filelock.h> #include <linux/nfs.h> #include <linux/sunrpc/xdr.h> - -#define SM_MAXSTRLEN 1024 -#define SM_PRIV_SIZE 16 +#include <linux/sunrpc/xdrgen/nlm4.h> struct nsm_private {unsigned char data[SM_PRIV_SIZE ];
fs/lockd/xdr4.h +2 -0
@@ -8,6 +8,8 @@#ifndef _LOCKD_XDR4_H#define _LOCKD_XDR4_H +#include <linux/sunrpc/xdrgen/nlm4.h> +/* error codes new to NLMv4 */ #define nlm4_deadlock cpu_to_be32(NLM_DEADLCK)#define nlm4_rofs cpu_to_be32(NLM_ROFS)
include/linux/sunrpc/xdrgen/nlm4.h new file +231 -0
231 lines not on this page · raw message
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 10/36 lockd: Use xdrgen XDR functions for the NLMv4 NULL procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Update the NLM4PROC_NULL entry in the nlmsvc_procedures4 array to use the generated XDR encoder and decoder functions (nlm4_svc_decode_void and nlm4_svc_encode_void) instead of the hand- written nlm4svc_decode_void and nlm4svc_encode_void functions.
Also update pc_xdrressize to 0 since the NULL procedure returns a void result with no XDR-encoded data.
--- fs/lockd/svc4proc.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
fs/lockd/svc4proc.c +15 -12
@@ -81,13 +81,16 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,return nlm_lck_denied_nolocks; } -/* -* NULL: Test for presence of service +/** +* nlm4svc_proc_null - NULL: Do nothing +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully */ static __be32 nlm4svc_proc_null (struct svc_rqst *rqstp) { -dprintk ("lockd: NULL called\n" );return rpc_success; }
@@ -508,15 +511,15 @@ struct nlm_void { int dummy; };#define Rg 4/* range (offset + length) */ const struct svc_procedure nlmsvc_procedures4[24 ] = { - [NLMPROC_NULL ] = { - .pc_func = nlm4svc_proc_null, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize =sizeof (struct nlm_void ), - .pc_argzero =sizeof (struct nlm_void ), - .pc_ressize =sizeof (struct nlm_void ), - .pc_xdrressize = St, - .pc_name ="NULL" , + [NLMPROC4_NULL ] = { + .pc_func = nlm4svc_proc_null, + .pc_decode = nlm4_svc_decode_void, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = XDR_void, + .pc_argzero =0 , + .pc_ressize =0 , + .pc_xdrressize = XDR_void, + .pc_name ="NULL" , }, [NLMPROC_TEST ] = { .pc_func = nlm4svc_proc_test,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 11/36 lockd: Use xdrgen XDR functions for the NLMv4 TEST procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_TEST entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 TEST procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 149 ++++++++++++++++++++++++++++++++++++++++---- fs/lockd/xdr4.h | 14 +++++ 2 files changed, 151 insertions(+), 12 deletions(-)
fs/lockd/svc4proc.c +137 -12
@@ -19,6 +19,68 @@#define NLMDBG_FACILITY NLMDBG_CLIENT +static struct nlm_host * +nlm4svc_lookup_host (struct svc_rqst *rqstp,string caller,bool monitored) +{ +struct nlm_host *host; + +if (!nlmsvc_ops) +return NULL ; + host =nlmsvc_lookup_host (rqstp, caller.data, caller.len); +if (!host) +return NULL ; +if (monitored &&nsm_monitor (host) <0 ) { +nlmsvc_release_host (host); +return NULL ; + } +return host; +} + +static __be32 +nlm4svc_lookup_file (struct svc_rqst *rqstp,struct nlm_host *host, +struct nlm_lock *lock,struct nlm_file **filp, +struct nlm4_lock *xdr_lock,unsigned char type) +{ +struct file_lock *fl = &lock->fl; +struct nlm_file *file =NULL ; +__be32 error; + +if (xdr_lock->fh.len >NFS_MAXFHSIZE ) +return nlm_lck_denied_nolocks; + lock->fh.size = xdr_lock->fh.len; +memcpy (lock->fh.data, xdr_lock->fh.data, xdr_lock->fh.len); + + lock->oh.len = xdr_lock->oh.len; + lock->oh.data = xdr_lock->oh.data; + + lock->svid = xdr_lock->svid; + lock->lock_start = xdr_lock->l_offset; + lock->lock_len = xdr_lock->l_len; + +if (lock->lock_start >OFFSET_MAX || + (lock->lock_len && ((lock->lock_len -1 ) > (OFFSET_MAX - lock->lock_start)))) +return nlm4_fbig; + +locks_init_lock (fl); + fl->c.flc_type = type; +nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len); + + error =nlm_lookup_file (rqstp, &file, lock); +if (error) +return error; + *filp = file; + + fl->c.flc_flags =FL_POSIX ; + fl->c.flc_file = file->f_file[lock_to_openmode (fl)]; + fl->c.flc_pid = current->tgid; + fl->fl_lmops = &nlmsvc_lock_operations; +nlmsvc_locks_init_private (fl, host, (pid_t )lock->svid); +if (!fl->c.flc_owner) +return nlm_lck_denied_nolocks; + +return nlm_granted; +} +/* * Obtain client and file from arguments */
@@ -126,10 +188,73 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)return rc; } -static __be32 -nlm4svc_proc_test (struct svc_rqst *rqstp) +/** +* nlm4svc_proc_test - TEST: Check for conflicting lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_drop_reply: Do not send an RPC reply. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The server would be able to grant the +* requested lock. +* %NLM4_DENIED: The requested lock conflicted with existing +* lock reservations for the file. +* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources +* needed to process the request. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. +*/ +static __be32 nlm4svc_proc_test (struct svc_rqst *rqstp) { -return __nlm4svc_proc_test (rqstp, rqstp->rq_resp); +struct nlm4_testargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct nlm4_testres_wrapper *resp = rqstp->rq_resp; +struct nlm_file *file =NULL ; +struct nlm_lockowner *owner; +struct nlm_host *host; + + resp->xdrgen.cookie = argp->xdrgen.cookie; + + resp->xdrgen.stat.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false); +if (!host) + goto out; + + resp->xdrgen.stat.stat =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, + type); +if (resp->xdrgen.stat.stat) + goto out; + + owner = argp->lock.fl.c.flc_owner; + resp->xdrgen.stat.stat =nlmsvc_testlock (rqstp, file, host, + &argp->lock, &resp->lock); +nlmsvc_put_lockowner (owner); + +if (resp->xdrgen.stat.stat == nlm_lck_denied) { +struct nlm_lock *conf = &resp->lock; +struct nlm4_holder *holder = &resp->xdrgen.stat.u.holder; + + holder->exclusive = (conf->fl.c.flc_type !=F_RDLCK ); + holder->svid = conf->svid; + holder->oh.len = conf->oh.len; + holder->oh.data = conf->oh.data; + holder->l_offset = conf->fl.fl_start; +if (conf->fl.fl_end ==OFFSET_MAX ) + holder->l_len =0 ; +else + holder->l_len = conf->fl.fl_end - conf->fl.fl_start +1 ; + } + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->xdrgen.stat.stat == nlm_drop_reply ? + rpc_drop_reply : rpc_success; } static __be32
@@ -521,15 +646,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "NULL", }, - [NLMPROC_TEST] = { - .pc_func = nlm4svc_proc_test, - .pc_decode = nlm4svc_decode_testargs, - .pc_encode = nlm4svc_encode_testres, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St+2+No+Rg, - .pc_name = "TEST", + [NLMPROC4_TEST] = { + .pc_func = nlm4svc_proc_test, + .pc_decode = nlm4_svc_decode_nlm4_testargs, + .pc_encode = nlm4_svc_encode_nlm4_testres, + .pc_argsize = sizeof(struct nlm4_testargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_testres_wrapper), + .pc_xdrressize = NLM4_nlm4_testres_sz, + .pc_name = "TEST", }, [NLMPROC_LOCK] = { .pc_func = nlm4svc_proc_lock,
fs/lockd/xdr4.h +14 -0
@@ -17,6 +17,20 @@#define nlm4_fbig cpu_to_be32(NLM_FBIG)#define nlm4_failed cpu_to_be32(NLM_FAILED) +struct nlm4_testargs_wrapper { +struct nlm4_testargs xdrgen; +struct nlm_lock lock; +}; + +static_assert (offsetof(struct nlm4_testargs_wrapper , xdrgen) ==0 ); + +struct nlm4_testres_wrapper { +struct nlm4_testres xdrgen; +struct nlm_lock lock; +}; + +static_assert (offsetof(struct nlm4_testres_wrapper , xdrgen) ==0 ); +void nlm4svc_set_file_lock_range (struct file_lock *fl,u64 off,u64 len);bool nlm4svc_decode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nlm4svc_decode_testargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 12/36 lockd: Use xdrgen XDR functions for the NLMv4 LOCK procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_LOCK entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 LOCK procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 85 +++++++++++++++++++++++++++++++++++++++------ fs/lockd/xdr4.h | 14 ++++++++ 2 files changed, 89 insertions(+), 10 deletions(-)
fs/lockd/svc4proc.c +75 -10
@@ -19,6 +19,16 @@#define NLMDBG_FACILITY NLMDBG_CLIENT +static __be32 +nlm4_netobj_to_cookie (struct nlm_cookie *cookie,netobj *object) +{ +if (object->len >NLM_MAXCOOKIELEN ) +return nlm_lck_denied_nolocks; + cookie->len = object->len; +memcpy (cookie->data, object->data, object->len); +return nlm_granted; +} +static struct nlm_host *nlm4svc_lookup_host (struct svc_rqst *rqstp,string caller,bool monitored) {
@@ -288,10 +298,65 @@ __nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)return rc; } +/** +* nlm4svc_proc_lock - LOCK: Establish a monitored lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_drop_reply: Do not send an RPC reply. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The requested lock was granted. +* %NLM4_DENIED: The requested lock conflicted with existing +* lock reservations for the file. +* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources +* needed to process the request. +* %NLM4_BLOCKED: The blocking request cannot be granted +* immediately. The server will send an +* NLM_GRANTED procedure to the client when the +* lock can be granted. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. +*/ static __be32 nlm4svc_proc_lock (struct svc_rqst *rqstp) { -return __nlm4svc_proc_lock (rqstp, rqstp->rq_resp); +struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct nlm4_res_wrapper *resp = rqstp->rq_resp; +struct nlm_file *file =NULL ; +struct nlm_host *host; + + resp->xdrgen.cookie = argp->xdrgen.cookie; + + resp->xdrgen.stat.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, true); +if (!host) + goto out; + + resp->xdrgen.stat.stat =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, + type); +if (resp->xdrgen.stat.stat) + goto out; + + resp->xdrgen.stat.stat =nlm4_netobj_to_cookie (&argp->cookie, + &argp->xdrgen.cookie); +if (resp->xdrgen.stat.stat) + goto out; + resp->xdrgen.stat.stat =nlmsvc_lock (rqstp, file, host, &argp->lock, + argp->xdrgen.block, &argp->cookie, + argp->xdrgen.reclaim); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->xdrgen.stat.stat == nlm_drop_reply ? + rpc_drop_reply : rpc_success; } static __be32
@@ -656,15 +721,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_testres_sz, .pc_name = "TEST", }, - [NLMPROC_LOCK] = { - .pc_func = nlm4svc_proc_lock, - .pc_decode = nlm4svc_decode_lockargs, - .pc_encode = nlm4svc_encode_res, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St, - .pc_name = "LOCK", + [NLMPROC4_LOCK] = { + .pc_func = nlm4svc_proc_lock, + .pc_decode = nlm4_svc_decode_nlm4_lockargs, + .pc_encode = nlm4_svc_encode_nlm4_res, + .pc_argsize = sizeof(struct nlm4_lockargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_res_wrapper), + .pc_xdrressize = NLM4_nlm4_res_sz, + .pc_name = "LOCK", }, [NLMPROC_CANCEL] = { .pc_func = nlm4svc_proc_cancel,
fs/lockd/xdr4.h +14 -0
@@ -24,6 +24,14 @@ struct nlm4_testargs_wrapper {static_assert (offsetof(struct nlm4_testargs_wrapper , xdrgen) ==0 ); +struct nlm4_lockargs_wrapper { +struct nlm4_lockargs xdrgen; +struct nlm_cookie cookie; +struct nlm_lock lock; +}; + +static_assert (offsetof(struct nlm4_lockargs_wrapper , xdrgen) ==0 ); +struct nlm4_testres_wrapper {struct nlm4_testres xdrgen;struct nlm_lock lock;
@@ -31,6 +39,12 @@ struct nlm4_testres_wrapper {static_assert (offsetof(struct nlm4_testres_wrapper , xdrgen) ==0 ); +struct nlm4_res_wrapper { +struct nlm4_res xdrgen; +}; + +static_assert (offsetof(struct nlm4_res_wrapper , xdrgen) ==0 ); +void nlm4svc_set_file_lock_range (struct file_lock *fl,u64 off,u64 len);bool nlm4svc_decode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nlm4svc_decode_testargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 13/36 lockd: Use xdrgen XDR functions for the NLMv4 CANCEL procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_CANCEL entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 CANCEL procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 67 ++++++++++++++++++++++++++++++++++++++------- fs/lockd/xdr4.h | 7 +++++ 2 files changed, 64 insertions(+), 10 deletions(-)
fs/lockd/svc4proc.c +57 -10
@@ -390,10 +390,57 @@ __nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_res *resp)return rpc_success; } +/** +* nlm4svc_proc_cancel - CANCEL: Cancel an outstanding blocked lock request +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully +* %rpc_drop_reply: Do not send an RPC reply +* +* Permissible procedure status codes: +* %NLM4_LCK_GRANTED: The requested lock was canceled. +* %NLM4_LCK_DENIED: There was no lock to cancel. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. +*/ static __be32 nlm4svc_proc_cancel (struct svc_rqst *rqstp) { -return __nlm4svc_proc_cancel (rqstp, rqstp->rq_resp); +struct nlm4_cancargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct nlm4_res_wrapper *resp = rqstp->rq_resp; +struct net *net =SVC_NET (rqstp); +struct nlm_host *host =NULL ; +struct nlm_file *file =NULL ; + + resp->xdrgen.cookie = argp->xdrgen.cookie; + + resp->xdrgen.stat.stat = nlm_lck_denied_grace_period; +if (locks_in_grace (net)) + goto out; + + resp->xdrgen.stat.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false); +if (!host) + goto out; + + resp->xdrgen.stat.stat =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, + type); +if (resp->xdrgen.stat.stat) + goto out; + + resp->xdrgen.stat.stat =nlmsvc_cancel_blocked (net, file, &argp->lock); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->xdrgen.stat.stat == nlm_drop_reply ? + rpc_drop_reply : rpc_success; }/*
@@ -731,15 +778,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_res_sz, .pc_name = "LOCK", }, - [NLMPROC_CANCEL] = { - .pc_func = nlm4svc_proc_cancel, - .pc_decode = nlm4svc_decode_cancargs, - .pc_encode = nlm4svc_encode_res, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St, - .pc_name = "CANCEL", + [NLMPROC4_CANCEL] = { + .pc_func = nlm4svc_proc_cancel, + .pc_decode = nlm4_svc_decode_nlm4_cancargs, + .pc_encode = nlm4_svc_encode_nlm4_res, + .pc_argsize = sizeof(struct nlm4_cancargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_res_wrapper), + .pc_xdrressize = NLM4_nlm4_res_sz, + .pc_name = "CANCEL", }, [NLMPROC_UNLOCK] = { .pc_func = nlm4svc_proc_unlock,
fs/lockd/xdr4.h +7 -0
@@ -32,6 +32,13 @@ struct nlm4_lockargs_wrapper {static_assert (offsetof(struct nlm4_lockargs_wrapper , xdrgen) ==0 ); +struct nlm4_cancargs_wrapper { +struct nlm4_cancargs xdrgen; +struct nlm_lock lock; +}; + +static_assert (offsetof(struct nlm4_cancargs_wrapper , xdrgen) ==0 ); +struct nlm4_testres_wrapper {struct nlm4_testres xdrgen;struct nlm_lock lock;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 14/36 lockd: Use xdrgen XDR functions for the NLMv4 UNLOCK procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_UNLOCK entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 UNLOCK procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 65 ++++++++++++++++++++++++++++++++++++++------- fs/lockd/xdr4.h | 7 +++++ 2 files changed, 62 insertions(+), 10 deletions(-)
fs/lockd/svc4proc.c +55 -10
@@ -477,10 +477,55 @@ __nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_res *resp)return rpc_success; } +/** +* nlm4svc_proc_unlock - UNLOCK: Remove a lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_drop_reply: Do not send an RPC reply. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The requested lock was granted. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. +*/ static __be32 nlm4svc_proc_unlock (struct svc_rqst *rqstp) { -return __nlm4svc_proc_unlock (rqstp, rqstp->rq_resp); +struct nlm4_unlockargs_wrapper *argp = rqstp->rq_argp; +struct nlm4_res_wrapper *resp = rqstp->rq_resp; +struct net *net =SVC_NET (rqstp); +struct nlm_host *host =NULL ; +struct nlm_file *file =NULL ; + + resp->xdrgen.cookie = argp->xdrgen.cookie; + + resp->xdrgen.stat.stat = nlm_lck_denied_grace_period; +if (locks_in_grace (net)) + goto out; + + resp->xdrgen.stat.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false); +if (!host) + goto out; + + resp->xdrgen.stat.stat =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, +F_UNLCK ); +if (resp->xdrgen.stat.stat) + goto out; + + resp->xdrgen.stat.stat =nlmsvc_unlock (net, file, &argp->lock); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->xdrgen.stat.stat == nlm_drop_reply ? + rpc_drop_reply : rpc_success; }/*
@@ -788,15 +833,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_res_sz, .pc_name = "CANCEL", }, - [NLMPROC_UNLOCK] = { - .pc_func = nlm4svc_proc_unlock, - .pc_decode = nlm4svc_decode_unlockargs, - .pc_encode = nlm4svc_encode_res, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St, - .pc_name = "UNLOCK", + [NLMPROC4_UNLOCK] = { + .pc_func = nlm4svc_proc_unlock, + .pc_decode = nlm4_svc_decode_nlm4_unlockargs, + .pc_encode = nlm4_svc_encode_nlm4_res, + .pc_argsize = sizeof(struct nlm4_unlockargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_res_wrapper), + .pc_xdrressize = NLM4_nlm4_res_sz, + .pc_name = "UNLOCK", }, [NLMPROC_GRANTED] = { .pc_func = nlm4svc_proc_granted,
fs/lockd/xdr4.h +7 -0
@@ -39,6 +39,13 @@ struct nlm4_cancargs_wrapper {static_assert (offsetof(struct nlm4_cancargs_wrapper , xdrgen) ==0 ); +struct nlm4_unlockargs_wrapper { +struct nlm4_unlockargs xdrgen; +struct nlm_lock lock; +}; + +static_assert (offsetof(struct nlm4_unlockargs_wrapper , xdrgen) ==0 ); +struct nlm4_testres_wrapper {struct nlm4_testres xdrgen;struct nlm_lock lock;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 15/36 lockd: Use xdrgen XDR functions for the NLMv4 GRANTED procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_GRANTED entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 GRANTED procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 54 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 10 deletions(-)
fs/lockd/svc4proc.c +44 -10
@@ -545,10 +545,44 @@ __nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_res *resp)return rpc_success; } +/** +* nlm4svc_proc_granted - GRANTED: Blocked lock has been granted +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The requested lock was granted. +* %NLM4_DENIED: The server could not allocate the resources +* needed to process the request. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. +*/ static __be32 nlm4svc_proc_granted (struct svc_rqst *rqstp) { -return __nlm4svc_proc_granted (rqstp, rqstp->rq_resp); +struct nlm4_testargs_wrapper *argp = rqstp->rq_argp; +struct nlm4_res_wrapper *resp = rqstp->rq_resp; +struct nlm4_lock *alock = &argp->xdrgen.alock; +struct nlm_lock *lock = &argp->lock; + + resp->xdrgen.cookie = argp->xdrgen.cookie; + + resp->xdrgen.stat.stat = nlm_lck_denied; +if (alock->fh.len >NFS_MAXFHSIZE ) + goto out; + + lock->fh.size = alock->fh.len; +memcpy (lock->fh.data, alock->fh.data, alock->fh.len); + lock->svid = alock->svid; +nlm4svc_set_file_lock_range (&lock->fl, alock->l_offset, alock->l_len); + + resp->xdrgen.stat.stat =nlmclnt_grant (svc_addr (rqstp), lock); + +out: +return rpc_success; }/*
@@ -843,15 +877,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_res_sz, .pc_name = "UNLOCK", }, - [NLMPROC_GRANTED] = { - .pc_func = nlm4svc_proc_granted, - .pc_decode = nlm4svc_decode_testargs, - .pc_encode = nlm4svc_encode_res, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St, - .pc_name = "GRANTED", + [NLMPROC4_GRANTED] = { + .pc_func = nlm4svc_proc_granted, + .pc_decode = nlm4_svc_decode_nlm4_testargs, + .pc_encode = nlm4_svc_encode_nlm4_res, + .pc_argsize = sizeof(struct nlm4_testargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_res_wrapper), + .pc_xdrressize = NLM4_nlm4_res_sz, + .pc_name = "GRANTED", }, [NLMPROC_TEST_MSG] = { .pc_func = nlm4svc_proc_test_msg,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 16/36 lockd: Refactor nlm4svc_callback()
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
With xdrgen, each RPC procedure can have a distinct argument struct, so each PROC_YADA_MSG procedure needs to sort its own arguments.
No behavior change is expected.
--- fs/lockd/svc4proc.c | 68 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 15 deletions(-)
fs/lockd/svc4proc.c +53 -15
@@ -607,20 +607,13 @@ static const struct rpc_call_ops nlm4svc_callback_ops = {* because we send the callback before the reply proper. I hope this * doesn't break any clients. */ -static __be32 nlm4svc_callback (struct svc_rqst *rqstp,u32 proc, -__be32 (*func)(struct svc_rqst *,struct nlm_res *)) +static __be32 +nlm4svc_callback (struct svc_rqst *rqstp,struct nlm_host *host,u32 proc, +__be32 (*func)(struct svc_rqst *,struct nlm_res *)) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host;struct nlm_rqst *call;__be32 stat; - host =nlmsvc_lookup_host (rqstp, - argp->lock.caller, - argp->lock.len); -if (host ==NULL ) -return rpc_system_err; - call =nlm_alloc_call (host);nlmsvc_release_host (host);if (call ==NULL )
@@ -640,32 +633,77 @@ static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc,static __be32 nlm4svc_proc_test_msg (struct svc_rqst *rqstp) { +struct nlm_args *argp = rqstp->rq_argp; +struct nlm_host *host; +dprintk ("lockd: TEST_MSG called\n" ); -return nlm4svc_callback (rqstp,NLMPROC_TEST_RES , __nlm4svc_proc_test); + + host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); +if (!host) +return rpc_system_err; + +return nlm4svc_callback (rqstp, host,NLMPROC_TEST_RES , + __nlm4svc_proc_test); }static __be32 nlm4svc_proc_lock_msg (struct svc_rqst *rqstp) { +struct nlm_args *argp = rqstp->rq_argp; +struct nlm_host *host; +dprintk ("lockd: LOCK_MSG called\n" ); -return nlm4svc_callback (rqstp,NLMPROC_LOCK_RES , __nlm4svc_proc_lock); + + host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); +if (!host) +return rpc_system_err; + +return nlm4svc_callback (rqstp, host,NLMPROC_LOCK_RES , + __nlm4svc_proc_lock); }static __be32 nlm4svc_proc_cancel_msg (struct svc_rqst *rqstp) { +struct nlm_args *argp = rqstp->rq_argp; +struct nlm_host *host; +dprintk ("lockd: CANCEL_MSG called\n" ); -return nlm4svc_callback (rqstp,NLMPROC_CANCEL_RES , __nlm4svc_proc_cancel); + + host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); +if (!host) +return rpc_system_err; + +return nlm4svc_callback (rqstp, host,NLMPROC_CANCEL_RES , + __nlm4svc_proc_cancel); }static __be32 nlm4svc_proc_unlock_msg (struct svc_rqst *rqstp) { +struct nlm_args *argp = rqstp->rq_argp; +struct nlm_host *host; +dprintk ("lockd: UNLOCK_MSG called\n" ); -return nlm4svc_callback (rqstp,NLMPROC_UNLOCK_RES , __nlm4svc_proc_unlock); + + host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); +if (!host) +return rpc_system_err; + +return nlm4svc_callback (rqstp, host,NLMPROC_UNLOCK_RES , + __nlm4svc_proc_unlock); }static __be32 nlm4svc_proc_granted_msg (struct svc_rqst *rqstp) { +struct nlm_args *argp = rqstp->rq_argp; +struct nlm_host *host; +dprintk ("lockd: GRANTED_MSG called\n" ); -return nlm4svc_callback (rqstp,NLMPROC_GRANTED_RES , __nlm4svc_proc_granted); + + host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); +if (!host) +return rpc_system_err; + +return nlm4svc_callback (rqstp, host,NLMPROC_GRANTED_RES , + __nlm4svc_proc_granted); }/*
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 17/36 lockd: Use xdrgen XDR functions for the NLMv4 TEST_MSG procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_TEST_MSG entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 TEST_MSG procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
The NLM async callback mechanism uses client-side functions, which continue to take old-school results like struct nlm_res. That means that for now, NLMPROC4_TEST and NLMPROC4_TEST_MSG cannot share code.
--- fs/lockd/svc4proc.c | 106 ++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 48 deletions(-)
fs/lockd/svc4proc.c +58 -48
@@ -166,38 +166,6 @@ nlm4svc_proc_null(struct svc_rqst *rqstp)return rpc_success; } -/* -* TEST: Check for conflicting lock -*/ -static __be32 -__nlm4svc_proc_test (struct svc_rqst *rqstp,struct nlm_res *resp) -{ -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; -struct nlm_file *file; -__be32 rc = rpc_success; - -dprintk ("lockd: TEST4 called\n" ); - resp->cookie = argp->cookie; - -/* Obtain client and file */ -if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file))) -return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - -/* Now check for conflicting locks */ - resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, - &resp->lock); -if (resp->status == nlm_drop_reply) - rc = rpc_drop_reply; -else -dprintk ("lockd: TEST4 status %d\n" ,ntohl (resp->status)); - -nlmsvc_release_lockowner (&argp->lock); -nlmsvc_release_host (host); -nlm_release_file (file); -return rc; -} -/** * nlm4svc_proc_test - TEST: Check for conflicting lock * @rqstp: RPC transaction context
@@ -631,19 +599,61 @@ nlm4svc_callback(struct svc_rqst *rqstp, struct nlm_host *host, u32 proc,return rpc_success; } +static __be32 +__nlm4svc_proc_test_msg (struct svc_rqst *rqstp,struct nlm_res *resp) +{ +struct nlm4_testargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct nlm_lockowner *owner; +struct nlm_file *file =NULL ; +struct nlm_host *host =NULL ; + + resp->status = nlm_lck_denied_nolocks; +if (nlm4_netobj_to_cookie (&resp->cookie, &argp->xdrgen.cookie)) + goto out; + + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false); +if (!host) + goto out; + + resp->status =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, type); +if (resp->status) + goto out; + + owner = argp->lock.fl.c.flc_owner; + resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, + &resp->lock); +nlmsvc_put_lockowner (owner); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->status == nlm_drop_reply ? rpc_drop_reply : rpc_success; +} + +/** +* nlm4svc_proc_test_msg - TEST_MSG: Check for conflicting lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_system_err: RPC execution failed. +* +* The response to this request is delivered via the TEST_RES procedure. +*/ static __be32 nlm4svc_proc_test_msg (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; +struct nlm4_testargs_wrapper *argp = rqstp->rq_argp; +struct nlm_host *host; -dprintk ("lockd: TEST_MSG called\n" ); - - host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false);if (!host)return rpc_system_err; -return nlm4svc_callback (rqstp, host,NLMPROC_TEST_RES , - __nlm4svc_proc_test); +return nlm4svc_callback (rqstp, host,NLMPROC4_TEST_RES , + __nlm4svc_proc_test_msg); }static __be32 nlm4svc_proc_lock_msg (struct svc_rqst *rqstp)
@@ -925,15 +935,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_res_sz, .pc_name = "GRANTED", }, - [NLMPROC_TEST_MSG] = { - .pc_func = nlm4svc_proc_test_msg, - .pc_decode = nlm4svc_decode_testargs, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "TEST_MSG", + [NLMPROC4_TEST_MSG] = { + .pc_func = nlm4svc_proc_test_msg, + .pc_decode = nlm4_svc_decode_nlm4_testargs, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_testargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "TEST_MSG", }, [NLMPROC_LOCK_MSG] = { .pc_func = nlm4svc_proc_lock_msg,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 18/36 lockd: Use xdrgen XDR functions for the NLMv4 LOCK_MSG procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_LOCK_MSG entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 LOCK_MSG procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
The NLM async callback mechanism uses client-side functions, which continue to take old-school results like struct nlm_res. That means that for now, NLMPROC4_TEST and NLMPROC4_LOCK_MSG cannot share code.
--- fs/lockd/svc4proc.c | 106 ++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 47 deletions(-)
fs/lockd/svc4proc.c +59 -47
@@ -235,37 +235,6 @@ static __be32 nlm4svc_proc_test(struct svc_rqst *rqstp) rpc_drop_reply : rpc_success; } -static __be32 -__nlm4svc_proc_lock (struct svc_rqst *rqstp,struct nlm_res *resp) -{ -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; -struct nlm_file *file; -__be32 rc = rpc_success; - -dprintk ("lockd: LOCK called\n" ); - - resp->cookie = argp->cookie; - -/* Obtain client and file */ -if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file))) -return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - -/* Now try to lock the file */ - resp->status =nlmsvc_lock (rqstp, file, host, &argp->lock, - argp->block, &argp->cookie, - argp->reclaim); -if (resp->status == nlm_drop_reply) - rc = rpc_drop_reply; -else -dprintk ("lockd: LOCK status %d\n" ,ntohl (resp->status)); - -nlmsvc_release_lockowner (&argp->lock); -nlmsvc_release_host (host); -nlm_release_file (file); -return rc; -} -/** * nlm4svc_proc_lock - LOCK: Establish a monitored lock * @rqstp: RPC transaction context
@@ -656,19 +625,62 @@ static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp) __nlm4svc_proc_test_msg); } +static __be32 +__nlm4svc_proc_lock_msg (struct svc_rqst *rqstp,struct nlm_res *resp) +{ +struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct nlm_file *file =NULL ; +struct nlm_host *host =NULL ; + + resp->status = nlm_lck_denied_nolocks; +if (nlm4_netobj_to_cookie (&resp->cookie, &argp->xdrgen.cookie)) + goto out; + + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, true); +if (!host) + goto out; + + resp->status =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, type); +if (resp->status) + goto out; + +if (nlm4_netobj_to_cookie (&argp->cookie, &argp->xdrgen.cookie)) + goto out; + resp->status =nlmsvc_lock (rqstp, file, host, &argp->lock, + argp->xdrgen.block, &argp->cookie, + argp->xdrgen.reclaim); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->status == nlm_drop_reply ? rpc_drop_reply : rpc_success; +} + +/** +* nlm4svc_proc_lock_msg - LOCK_MSG: Establish a monitored lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_system_err: RPC execution failed. +* +* The response to this request is delivered via the LOCK_RES procedure. +*/ static __be32 nlm4svc_proc_lock_msg (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; +struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp; +struct nlm_host *host; -dprintk ("lockd: LOCK_MSG called\n" ); - - host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, true);if (!host)return rpc_system_err; -return nlm4svc_callback (rqstp, host,NLMPROC_LOCK_RES , - __nlm4svc_proc_lock); +return nlm4svc_callback (rqstp, host,NLMPROC4_LOCK_RES , + __nlm4svc_proc_lock_msg); }static __be32 nlm4svc_proc_cancel_msg (struct svc_rqst *rqstp)
@@ -945,15 +957,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "TEST_MSG", }, - [NLMPROC_LOCK_MSG] = { - .pc_func = nlm4svc_proc_lock_msg, - .pc_decode = nlm4svc_decode_lockargs, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "LOCK_MSG", + [NLMPROC4_LOCK_MSG] = { + .pc_func = nlm4svc_proc_lock_msg, + .pc_decode = nlm4_svc_decode_nlm4_lockargs, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_lockargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "LOCK_MSG", }, [NLMPROC_CANCEL_MSG] = { .pc_func = nlm4svc_proc_cancel_msg,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 19/36 lockd: Use xdrgen XDR functions for the NLMv4 CANCEL_MSG procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_CANCEL_MSG entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 CANCEL_MSG procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
The NLM async callback mechanism uses client-side functions, which continue to take old-school results like struct nlm_res. That means that for now, NLMPROC4_CANCEL and NLMPROC4_CANCEL_MSG cannot share code.
--- fs/lockd/svc4proc.c | 108 +++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 47 deletions(-)
fs/lockd/svc4proc.c +61 -47
@@ -296,37 +296,6 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp) rpc_drop_reply : rpc_success; } -static __be32 -__nlm4svc_proc_cancel (struct svc_rqst *rqstp,struct nlm_res *resp) -{ -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; -struct nlm_file *file; - -dprintk ("lockd: CANCEL called\n" ); - - resp->cookie = argp->cookie; - -/* Don't accept requests during grace period */ -if (locks_in_grace (SVC_NET (rqstp))) { - resp->status = nlm_lck_denied_grace_period; -return rpc_success; - } - -/* Obtain client and file */ -if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file))) -return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - -/* Try to cancel request. */ - resp->status =nlmsvc_cancel_blocked (SVC_NET (rqstp), file, &argp->lock); - -dprintk ("lockd: CANCEL status %d\n" ,ntohl (resp->status)); -nlmsvc_release_lockowner (&argp->lock); -nlmsvc_release_host (host); -nlm_release_file (file); -return rpc_success; -} -/** * nlm4svc_proc_cancel - CANCEL: Cancel an outstanding blocked lock request * @rqstp: RPC transaction context
@@ -683,19 +652,64 @@ static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp) __nlm4svc_proc_lock_msg); } +static __be32 +__nlm4svc_proc_cancel_msg (struct svc_rqst *rqstp,struct nlm_res *resp) +{ +struct nlm4_cancargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct net *net =SVC_NET (rqstp); +struct nlm_file *file =NULL ; +struct nlm_host *host =NULL ; + + resp->status = nlm_lck_denied_nolocks; +if (nlm4_netobj_to_cookie (&resp->cookie, &argp->xdrgen.cookie)) + goto out; + + resp->status = nlm_lck_denied_grace_period; +if (locks_in_grace (net)) + goto out; + + resp->status = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false); +if (!host) + goto out; + + resp->status =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, type); +if (resp->status) + goto out; + + resp->status =nlmsvc_cancel_blocked (net, file, &argp->lock); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->status == nlm_drop_reply ? rpc_drop_reply : rpc_success; +} + +/** +* nlm4svc_proc_cancel_msg - CANCEL_MSG: Cancel an outstanding lock request +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_system_err: RPC execution failed. +* +* The response to this request is delivered via the CANCEL_RES procedure. +*/ static __be32 nlm4svc_proc_cancel_msg (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; +struct nlm4_cancargs_wrapper *argp = rqstp->rq_argp; +struct nlm_host *host; -dprintk ("lockd: CANCEL_MSG called\n" ); - - host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false);if (!host)return rpc_system_err; -return nlm4svc_callback (rqstp, host,NLMPROC_CANCEL_RES , - __nlm4svc_proc_cancel); +return nlm4svc_callback (rqstp, host,NLMPROC4_CANCEL_RES , + __nlm4svc_proc_cancel_msg); }static __be32 nlm4svc_proc_unlock_msg (struct svc_rqst *rqstp)
@@ -967,15 +981,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "LOCK_MSG", }, - [NLMPROC_CANCEL_MSG] = { - .pc_func = nlm4svc_proc_cancel_msg, - .pc_decode = nlm4svc_decode_cancargs, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "CANCEL_MSG", + [NLMPROC4_CANCEL_MSG] = { + .pc_func = nlm4svc_proc_cancel_msg, + .pc_decode = nlm4_svc_decode_nlm4_cancargs, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_cancargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "CANCEL_MSG", }, [NLMPROC_UNLOCK_MSG] = { .pc_func = nlm4svc_proc_unlock_msg,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 20/36 lockd: Use xdrgen XDR functions for the NLMv4 UNLOCK_MSG procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_UNLOCK_MSG entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 UNLOCK_MSG procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
The NLM async callback mechanism uses client-side functions, which continue to take old-school results like struct nlm_res. That means that for now, NLMPROC4_UNLOCK and NLMPROC4_UNLOCK_MSG cannot share code.
--- fs/lockd/svc4proc.c | 110 ++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 50 deletions(-)
fs/lockd/svc4proc.c +60 -50
@@ -349,40 +349,6 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp) rpc_drop_reply : rpc_success; } -/* -* UNLOCK: release a lock -*/ -static __be32 -__nlm4svc_proc_unlock (struct svc_rqst *rqstp,struct nlm_res *resp) -{ -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; -struct nlm_file *file; - -dprintk ("lockd: UNLOCK called\n" ); - - resp->cookie = argp->cookie; - -/* Don't accept new lock requests during grace period */ -if (locks_in_grace (SVC_NET (rqstp))) { - resp->status = nlm_lck_denied_grace_period; -return rpc_success; - } - -/* Obtain client and file */ -if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file))) -return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - -/* Now try to remove the lock */ - resp->status =nlmsvc_unlock (SVC_NET (rqstp), file, &argp->lock); - -dprintk ("lockd: UNLOCK status %d\n" ,ntohl (resp->status)); -nlmsvc_release_lockowner (&argp->lock); -nlmsvc_release_host (host); -nlm_release_file (file); -return rpc_success; -} -/** * nlm4svc_proc_unlock - UNLOCK: Remove a lock * @rqstp: RPC transaction context
@@ -712,19 +678,63 @@ static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp) __nlm4svc_proc_cancel_msg); } +static __be32 +__nlm4svc_proc_unlock_msg (struct svc_rqst *rqstp,struct nlm_res *resp) +{ +struct nlm4_unlockargs_wrapper *argp = rqstp->rq_argp; +struct net *net =SVC_NET (rqstp); +struct nlm_file *file =NULL ; +struct nlm_host *host =NULL ; + + resp->status = nlm_lck_denied_nolocks; +if (nlm4_netobj_to_cookie (&resp->cookie, &argp->xdrgen.cookie)) + goto out; + + resp->status = nlm_lck_denied_grace_period; +if (locks_in_grace (net)) + goto out; + + resp->status = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false); +if (!host) + goto out; + + resp->status =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock,F_UNLCK ); +if (resp->status) + goto out; + + resp->status =nlmsvc_unlock (net, file, &argp->lock); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->status == nlm_drop_reply ? rpc_drop_reply : rpc_success; +} + +/** +* nlm4svc_proc_unlock_msg - UNLOCK_MSG: Remove an existing lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_system_err: RPC execution failed. +* +* The response to this request is delivered via the UNLOCK_RES procedure. +*/ static __be32 nlm4svc_proc_unlock_msg (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; +struct nlm4_unlockargs_wrapper *argp = rqstp->rq_argp; +struct nlm_host *host; -dprintk ("lockd: UNLOCK_MSG called\n" ); - - host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false);if (!host)return rpc_system_err; -return nlm4svc_callback (rqstp, host,NLMPROC_UNLOCK_RES , - __nlm4svc_proc_unlock); +return nlm4svc_callback (rqstp, host,NLMPROC4_UNLOCK_RES , + __nlm4svc_proc_unlock_msg); }static __be32 nlm4svc_proc_granted_msg (struct svc_rqst *rqstp)
@@ -991,15 +1001,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "CANCEL_MSG", }, - [NLMPROC_UNLOCK_MSG] = { - .pc_func = nlm4svc_proc_unlock_msg, - .pc_decode = nlm4svc_decode_unlockargs, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "UNLOCK_MSG", + [NLMPROC4_UNLOCK_MSG] = { + .pc_func = nlm4svc_proc_unlock_msg, + .pc_decode = nlm4_svc_decode_nlm4_unlockargs, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_unlockargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "UNLOCK_MSG", }, [NLMPROC_GRANTED_MSG] = { .pc_func = nlm4svc_proc_granted_msg,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 21/36 lockd: Use xdrgen XDR functions for the NLMv4 GRANTED_MSG procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_GRANTED_MSG entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 GRANTED_MSG procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
The NLM async callback mechanism uses client-side functions, which continue to take old-school results like struct nlm_res. That means that for now, NLMPROC4_GRANTED and NLMPROC4_GRANTED_MSG cannot share code.
--- fs/lockd/svc4proc.c | 82 +++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 33 deletions(-)
fs/lockd/svc4proc.c +49 -33
@@ -400,23 +400,6 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp) rpc_drop_reply : rpc_success; } -/* -* GRANTED: A server calls us to tell that a process' lock request -* was granted -*/ -static __be32 -__nlm4svc_proc_granted (struct svc_rqst *rqstp,struct nlm_res *resp) -{ -struct nlm_args *argp = rqstp->rq_argp; - - resp->cookie = argp->cookie; - -dprintk ("lockd: GRANTED called\n" ); - resp->status =nlmclnt_grant (svc_addr (rqstp), &argp->lock); -dprintk ("lockd: GRANTED status %d\n" ,ntohl (resp->status)); -return rpc_success; -} -/** * nlm4svc_proc_granted - GRANTED: Blocked lock has been granted * @rqstp: RPC transaction context
@@ -737,19 +720,52 @@ static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp) __nlm4svc_proc_unlock_msg); } +static __be32 +__nlm4svc_proc_granted_msg (struct svc_rqst *rqstp,struct nlm_res *resp) +{ +struct nlm4_testargs_wrapper *argp = rqstp->rq_argp; +struct nlm4_lock *alock = &argp->xdrgen.alock; +struct nlm_lock *lock = &argp->lock; + + resp->status = nlm_lck_denied; +if (nlm4_netobj_to_cookie (&resp->cookie, &argp->xdrgen.cookie)) + goto out; + +if (alock->fh.len >NFS_MAXFHSIZE ) + goto out; + + lock->fh.size = alock->fh.len; +memcpy (lock->fh.data, alock->fh.data, alock->fh.len); + lock->svid = alock->svid; +nlm4svc_set_file_lock_range (&lock->fl, alock->l_offset, alock->l_len); + + resp->status =nlmclnt_grant (svc_addr (rqstp), lock); + +out: +return rpc_success; +} + +/** +* nlm4svc_proc_granted_msg - GRANTED_MSG: Blocked lock has been granted +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_system_err: RPC execution failed. +* +* The response to this request is delivered via the GRANTED_RES procedure. +*/ static __be32 nlm4svc_proc_granted_msg (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_host *host; +struct nlm4_testargs_wrapper *argp = rqstp->rq_argp; +struct nlm_host *host; -dprintk ("lockd: GRANTED_MSG called\n" ); - - host =nlmsvc_lookup_host (rqstp, argp->lock.caller, argp->lock.len); + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false);if (!host)return rpc_system_err; -return nlm4svc_callback (rqstp, host,NLMPROC_GRANTED_RES , - __nlm4svc_proc_granted); +return nlm4svc_callback (rqstp, host,NLMPROC4_GRANTED_RES , + __nlm4svc_proc_granted_msg); }/*
@@ -1011,15 +1027,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "UNLOCK_MSG", }, - [NLMPROC_GRANTED_MSG] = { - .pc_func = nlm4svc_proc_granted_msg, - .pc_decode = nlm4svc_decode_testargs, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "GRANTED_MSG", + [NLMPROC4_GRANTED_MSG] = { + .pc_func = nlm4svc_proc_granted_msg, + .pc_decode = nlm4_svc_decode_nlm4_testargs, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_testargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "GRANTED_MSG", }, [NLMPROC_TEST_RES] = { .pc_func = nlm4svc_proc_null,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 22/36 lockd: Convert server-side NLMPROC4_TEST_RES to use xdrgen
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/lockd/svc4proc.c +9 -9
@@ -1037,15 +1037,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "GRANTED_MSG", }, - [NLMPROC_TEST_RES] = { - .pc_func = nlm4svc_proc_null, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_res), - .pc_argzero = sizeof(struct nlm_res), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "TEST_RES", + [NLMPROC4_TEST_RES] = { + .pc_func = nlm4svc_proc_null, + .pc_decode = nlm4_svc_decode_nlm4_testres, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_testres), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "TEST_RES", }, [NLMPROC_LOCK_RES] = { .pc_func = nlm4svc_proc_null,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 23/36 lockd: Convert server-side NLMPROC4_LOCK_RES to use xdrgen
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/lockd/svc4proc.c +9 -9
@@ -1047,15 +1047,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "TEST_RES", }, - [NLMPROC_LOCK_RES] = { - .pc_func = nlm4svc_proc_null, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_res), - .pc_argzero = sizeof(struct nlm_res), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "LOCK_RES", + [NLMPROC4_LOCK_RES] = { + .pc_func = nlm4svc_proc_null, + .pc_decode = nlm4_svc_decode_nlm4_res, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_res), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "LOCK_RES", }, [NLMPROC_CANCEL_RES] = { .pc_func = nlm4svc_proc_null,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 24/36 lockd: Convert server-side NLMPROC4_CANCEL_RES to use xdrgen
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/lockd/svc4proc.c +9 -9
@@ -1057,15 +1057,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "LOCK_RES", }, - [NLMPROC_CANCEL_RES] = { - .pc_func = nlm4svc_proc_null, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_res), - .pc_argzero = sizeof(struct nlm_res), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "CANCEL_RES", + [NLMPROC4_CANCEL_RES] = { + .pc_func = nlm4svc_proc_null, + .pc_decode = nlm4_svc_decode_nlm4_res, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_res), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "CANCEL_RES", }, [NLMPROC_UNLOCK_RES] = { .pc_func = nlm4svc_proc_null,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 25/36 lockd: Convert server-side NLMPROC4_UNLOCK_RES to use xdrgen
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/lockd/svc4proc.c +9 -9
@@ -1067,15 +1067,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "CANCEL_RES", }, - [NLMPROC_UNLOCK_RES] = { - .pc_func = nlm4svc_proc_null, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_res), - .pc_argzero = sizeof(struct nlm_res), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "UNLOCK_RES", + [NLMPROC4_UNLOCK_RES] = { + .pc_func = nlm4svc_proc_null, + .pc_decode = nlm4_svc_decode_nlm4_res, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_res), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "UNLOCK_RES", }, [NLMPROC_GRANTED_RES] = { .pc_func = nlm4svc_proc_granted_res,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 26/36 lockd: Convert server-side NLMPROC4_GRANTED_RES to use xdrgen
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 56 ++++++++++++++++++++++++--------------------- fs/lockd/xdr4.h | 1 + 2 files changed, 31 insertions(+), 26 deletions(-)
fs/lockd/svc4proc.c +30 -26
@@ -768,6 +768,27 @@ static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp) __nlm4svc_proc_granted_msg); } +/** +* nlm4svc_proc_granted_res - GRANTED_RES: Lock Granted result +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +*/ +static __be32 nlm4svc_proc_granted_res (struct svc_rqst *rqstp) +{ +struct nlm4_res_wrapper *argp = rqstp->rq_argp; + +if (!nlmsvc_ops) +return rpc_success; + +if (nlm4_netobj_to_cookie (&argp->cookie, &argp->xdrgen.cookie)) +return rpc_success; +nlmsvc_grant_reply (&argp->cookie, argp->xdrgen.stat.stat); + +return rpc_success; +} +/* * SHARE: create a DOS share or alter existing share. */
@@ -891,23 +912,6 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp)return rpc_success; } -/* -* client sent a GRANTED_RES, let's remove the associated block -*/ -static __be32 -nlm4svc_proc_granted_res (struct svc_rqst *rqstp) -{ -struct nlm_res *argp = rqstp->rq_argp; - -if (!nlmsvc_ops) -return rpc_success; - -dprintk ("lockd: GRANTED_RES called\n" ); - -nlmsvc_grant_reply (&argp->cookie, argp->status); -return rpc_success; -} -static __be32 nlm4svc_proc_unused (struct svc_rqst *rqstp) {
@@ -1077,15 +1081,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "UNLOCK_RES", }, - [NLMPROC_GRANTED_RES] = { - .pc_func = nlm4svc_proc_granted_res, - .pc_decode = nlm4svc_decode_res, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_res), - .pc_argzero = sizeof(struct nlm_res), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "GRANTED_RES", + [NLMPROC4_GRANTED_RES] = { + .pc_func = nlm4svc_proc_granted_res, + .pc_decode = nlm4_svc_decode_nlm4_res, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_res_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "GRANTED_RES", }, [NLMPROC_NSM_NOTIFY] = { .pc_func = nlm4svc_proc_sm_notify,
fs/lockd/xdr4.h +1 -0
@@ -55,6 +55,7 @@ static_assert(offsetof(struct nlm4_testres_wrapper, xdrgen) == 0);struct nlm4_res_wrapper {struct nlm4_res xdrgen; +struct nlm_cookie cookie; };static_assert (offsetof(struct nlm4_res_wrapper , xdrgen) ==0 );
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 27/36 lockd: Use xdrgen XDR functions for the NLMv4 SM_NOTIFY procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_SM_NOTIFY entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 SM_NOTIFY procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 74 +++++++++++++++++++++++++++------------------ fs/lockd/xdr4.h | 7 +++++ 2 files changed, 51 insertions(+), 30 deletions(-)
fs/lockd/svc4proc.c +44 -30
@@ -789,6 +789,41 @@ static __be32 nlm4svc_proc_granted_res(struct svc_rqst *rqstp)return rpc_success; } +/** +* nlm4svc_proc_sm_notify - SM_NOTIFY: Peer has rebooted +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_system_err: RPC execution failed. +* +* The SM_NOTIFY procedure is a private callback from Linux statd and is +* not part of the official NLM protocol. +*/ +static __be32 nlm4svc_proc_sm_notify (struct svc_rqst *rqstp) +{ +struct nlm4_notifyargs_wrapper *argp = rqstp->rq_argp; +struct nlm_reboot *reboot = &argp->reboot; + +if (!nlm_privileged_requester (rqstp)) { +char buf[RPC_MAX_ADDRBUFLEN ]; + +printk (KERN_WARNING "lockd: rejected NSM callback from %s\n" , +svc_print_addr (rqstp, buf,sizeof (buf))); +return rpc_system_err; + } + + reboot->len = argp->xdrgen.notify.name.len; + reboot->mon = (char *)argp->xdrgen.notify.name.data; + reboot->state = argp->xdrgen.notify.state; +memcpy (&reboot->priv.data, argp->xdrgen.private, +sizeof (reboot->priv.data)); + +nlm_host_rebooted (SVC_NET (rqstp), reboot); + +return rpc_success; +} +/* * SHARE: create a DOS share or alter existing share. */
@@ -891,27 +926,6 @@ nlm4svc_proc_free_all(struct svc_rqst *rqstp)return rpc_success; } -/* -* SM_NOTIFY: private callback from statd (not part of official NLM proto) -*/ -static __be32 -nlm4svc_proc_sm_notify (struct svc_rqst *rqstp) -{ -struct nlm_reboot *argp = rqstp->rq_argp; - -dprintk ("lockd: SM_NOTIFY called\n" ); - -if (!nlm_privileged_requester (rqstp)) { -char buf[RPC_MAX_ADDRBUFLEN ]; -printk (KERN_WARNING "lockd: rejected NSM callback from %s\n" , -svc_print_addr (rqstp, buf,sizeof (buf))); -return rpc_system_err; - } - -nlm_host_rebooted (SVC_NET (rqstp), argp); -return rpc_success; -} -static __be32 nlm4svc_proc_unused (struct svc_rqst *rqstp) {
@@ -1091,15 +1105,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "GRANTED_RES", }, - [NLMPROC_NSM_NOTIFY] = { - .pc_func = nlm4svc_proc_sm_notify, - .pc_decode = nlm4svc_decode_reboot, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_reboot), - .pc_argzero = sizeof(struct nlm_reboot), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "SM_NOTIFY", + [NLMPROC4_SM_NOTIFY] = { + .pc_func = nlm4svc_proc_sm_notify, + .pc_decode = nlm4_svc_decode_nlm4_notifyargs, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_notifyargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "SM_NOTIFY", }, [17] = { .pc_func = nlm4svc_proc_unused,
fs/lockd/xdr4.h +7 -0
@@ -46,6 +46,13 @@ struct nlm4_unlockargs_wrapper {static_assert (offsetof(struct nlm4_unlockargs_wrapper , xdrgen) ==0 ); +struct nlm4_notifyargs_wrapper { +struct nlm4_notifyargs xdrgen; +struct nlm_reboot reboot; +}; + +static_assert (offsetof(struct nlm4_notifyargs_wrapper , xdrgen) ==0 ); +struct nlm4_testres_wrapper {struct nlm4_testres xdrgen;struct nlm_lock lock;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 28/36 lockd: Convert server-side undefined procedures to xdrgen
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-)
fs/lockd/svc4proc.c +36 -30
@@ -824,6 +824,18 @@ static __be32 nlm4svc_proc_sm_notify(struct svc_rqst *rqstp)return rpc_success; } +/** +* nlm4svc_proc_unused - stub for unused procedures +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_proc_unavailable: Program can't support procedure. +*/ +static __be32 nlm4svc_proc_unused (struct svc_rqst *rqstp) +{ +return rpc_proc_unavail; +} +/* * SHARE: create a DOS share or alter existing share. */
@@ -926,12 +938,6 @@ nlm4svc_proc_free_all(struct svc_rqst *rqstp)return rpc_success; } -static __be32 -nlm4svc_proc_unused (struct svc_rqst *rqstp) -{ -return rpc_proc_unavail; -} -/* * NLM Server procedures.
@@ -1116,34 +1122,34 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_name = "SM_NOTIFY", }, [17] = { - .pc_func = nlm4svc_proc_unused, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_void), - .pc_argzero = sizeof(struct nlm_void), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = 0, - .pc_name = "UNUSED", + .pc_func = nlm4svc_proc_unused, + .pc_decode = nlm4_svc_decode_void, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = 0, + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "UNUSED", }, [18] = { - .pc_func = nlm4svc_proc_unused, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_void), - .pc_argzero = sizeof(struct nlm_void), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = 0, - .pc_name = "UNUSED", + .pc_func = nlm4svc_proc_unused, + .pc_decode = nlm4_svc_decode_void, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = 0, + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "UNUSED", }, [19] = { - .pc_func = nlm4svc_proc_unused, - .pc_decode = nlm4svc_decode_void, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_void), - .pc_argzero = sizeof(struct nlm_void), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = 0, - .pc_name = "UNUSED", + .pc_func = nlm4svc_proc_unused, + .pc_decode = nlm4_svc_decode_void, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = 0, + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "UNUSED", }, [NLMPROC_SHARE] = { .pc_func = nlm4svc_proc_share,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 29/36 lockd: Hoist file_lock init out of nlm4svc_decode_shareargs()
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Refactor: Remove one more dependency in fs/lockd/xdr4.c on the "struct nlm_lock::fl" field in preparation for converting to use machine-generated XDR.
--- fs/lockd/svc4proc.c | 16 ++++++++++++---- fs/lockd/xdr4.c | 3 --- 2 files changed, 12 insertions(+), 7 deletions(-)
fs/lockd/svc4proc.c +12 -4
@@ -844,6 +844,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp) {struct nlm_args *argp = rqstp->rq_argp;struct nlm_res *resp = rqstp->rq_resp; +struct nlm_lock *lock = &argp->lock;struct nlm_host *host;struct nlm_file *file;
@@ -858,14 +859,17 @@ nlm4svc_proc_share(struct svc_rqst *rqstp) }/* Obtain client and file */ -if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file))) +locks_init_lock (&lock->fl); + lock->svid = ~(u32 )0 ; + resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file); +if (resp->status)return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;/* Now try to create the share */ resp->status =nlmsvc_share_file (host, file, argp);dprintk ("lockd: SHARE status %d\n" ,ntohl (resp->status)); -nlmsvc_release_lockowner (&argp->lock); +nlmsvc_release_lockowner (lock);nlmsvc_release_host (host);nlm_release_file (file);return rpc_success;
@@ -879,6 +883,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp) {struct nlm_args *argp = rqstp->rq_argp;struct nlm_res *resp = rqstp->rq_resp; +struct nlm_lock *lock = &argp->lock;struct nlm_host *host;struct nlm_file *file;
@@ -893,14 +898,17 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp) }/* Obtain client and file */ -if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file))) +locks_init_lock (&lock->fl); + lock->svid = ~(u32 )0 ; + resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file); +if (resp->status)return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;/* Now try to lock the file */ resp->status =nlmsvc_unshare_file (host, file, argp);dprintk ("lockd: UNSHARE status %d\n" ,ntohl (resp->status)); -nlmsvc_release_lockowner (&argp->lock); +nlmsvc_release_lockowner (lock);nlmsvc_release_host (host);nlm_release_file (file);return rpc_success;
fs/lockd/xdr4.c +0 -3
@@ -268,9 +268,6 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)struct nlm_args *argp = rqstp->rq_argp;struct nlm_lock *lock = &argp->lock; -locks_init_lock (&lock->fl); - lock->svid = ~(u32 )0 ; -if (!svcxdr_decode_cookie (xdr, &argp->cookie))return false;if (!svcxdr_decode_string (xdr, &lock->caller, &lock->len))
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 30/36 lockd: Update share_file helpers
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Refactor the internal nlmsvc_share_file() and nlmsvc_unshare_file() helper functions to use raw arguments rather than the common struct nlm_args, which is about to be replaced for NLMv4.
--- fs/lockd/share.h | 8 ++++---- fs/lockd/svc4proc.c | 7 ++++--- fs/lockd/svcproc.c | 7 +++++-- fs/lockd/svcshare.c | 35 +++++++++++++++++++++++------------ 4 files changed, 36 insertions(+), 21 deletions(-)
fs/lockd/share.h +4 -4
@@ -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 );
fs/lockd/svc4proc.c +4 -3
@@ -866,7 +866,8 @@ nlm4svc_proc_share(struct svc_rqst *rqstp)return resp->status == nlm_drop_reply ? 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);
@@ -904,8 +905,8 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp)if (resp->status)return resp->status == nlm_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);
fs/lockd/svcproc.c +5 -2
@@ -407,7 +407,9 @@ nlmsvc_proc_share(struct svc_rqst *rqstp)return resp->status == nlm_drop_reply ? 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);
@@ -442,7 +444,8 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp)return resp->status == nlm_drop_reply ? 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);
fs/lockd/svcshare.c +23 -12
@@ -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;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 31/36 lockd: Use xdrgen XDR functions for the NLMv4 SHARE procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_SHARE entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 SHARE procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 90 +++++++++++++++++++++++++++------------------ fs/lockd/xdr4.h | 13 +++++++ 2 files changed, 68 insertions(+), 35 deletions(-)
fs/lockd/svc4proc.c +55 -35
@@ -836,43 +836,63 @@ static __be32 nlm4svc_proc_unused(struct svc_rqst *rqstp)return rpc_proc_unavail; } -/* -* SHARE: create a DOS share or alter existing share. +/** +* nlm4svc_proc_share - SHARE: Open a file using DOS file-sharing modes +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_drop_reply: Do not send an RPC reply. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The requested share lock was granted. +* %NLM4_DENIED: The requested lock conflicted with existing +* lock reservations for the file. +* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources +* needed to process the request. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. */ -static __be32 -nlm4svc_proc_share (struct svc_rqst *rqstp) +static __be32 nlm4svc_proc_share (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_res *resp = rqstp->rq_resp; +struct nlm4_shareargs_wrapper *argp = rqstp->rq_argp; +struct nlm4_shareres_wrapper *resp = rqstp->rq_resp;struct nlm_lock *lock = &argp->lock; -struct nlm_host *host; -struct nlm_file *file; +struct nlm_host *host =NULL ; +struct nlm_file *file =NULL ; +struct nlm4_lock xdr_lock = { + .fh = argp->xdrgen.share.fh, + .oh = argp->xdrgen.share.oh, + .svid = ~(u32 )0 , + }; -dprintk ("lockd: SHARE called\n" ); + resp->xdrgen.cookie = argp->xdrgen.cookie; - resp->cookie = argp->cookie; + resp->xdrgen.stat = nlm_lck_denied_grace_period; +if (locks_in_grace (SVC_NET (rqstp)) && !argp->xdrgen.reclaim) + goto out; -/* Don't accept new lock requests during grace period */ -if (locks_in_grace (SVC_NET (rqstp)) && !argp->reclaim) { - resp->status = nlm_lck_denied_grace_period; -return rpc_success; - } + resp->xdrgen.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.share.caller_name, true); +if (!host) + goto out; -/* Obtain client and file */ -locks_init_lock (&lock->fl); - lock->svid = ~(u32 )0 ; - resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file); -if (resp->status) -return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; + resp->xdrgen.stat =nlm4svc_lookup_file (rqstp, host, lock, &file, + &xdr_lock,F_RDLCK ); +if (resp->xdrgen.stat) + goto out; -/* Now try to create the share */ - resp->status =nlmsvc_share_file (host, file, &lock->oh, - argp->fsm_access, argp->fsm_mode); + resp->xdrgen.stat =nlmsvc_share_file (host, file, &lock->oh, + argp->xdrgen.share.access, + argp->xdrgen.share.mode); -dprintk ("lockd: SHARE status %d\n" ,ntohl (resp->status));nlmsvc_release_lockowner (lock); + +out: +if (file) +nlm_release_file (file);nlmsvc_release_host (host); -nlm_release_file (file);return rpc_success; }
@@ -1160,15 +1180,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = XDR_void, .pc_name = "UNUSED", }, - [NLMPROC_SHARE] = { - .pc_func = nlm4svc_proc_share, - .pc_decode = nlm4svc_decode_shareargs, - .pc_encode = nlm4svc_encode_shareres, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St+1, - .pc_name = "SHARE", + [NLMPROC4_SHARE] = { + .pc_func = nlm4svc_proc_share, + .pc_decode = nlm4_svc_decode_nlm4_shareargs, + .pc_encode = nlm4_svc_encode_nlm4_shareres, + .pc_argsize = sizeof(struct nlm4_shareargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_shareres_wrapper), + .pc_xdrressize = NLM4_nlm4_shareres_sz, + .pc_name = "SHARE", }, [NLMPROC_UNSHARE] = { .pc_func = nlm4svc_proc_unshare,
fs/lockd/xdr4.h +13 -0
@@ -53,6 +53,13 @@ struct nlm4_notifyargs_wrapper {static_assert (offsetof(struct nlm4_notifyargs_wrapper , xdrgen) ==0 ); +struct nlm4_shareargs_wrapper { +struct nlm4_shareargs xdrgen; +struct nlm_lock lock; +}; + +static_assert (offsetof(struct nlm4_shareargs_wrapper , xdrgen) ==0 ); +struct nlm4_testres_wrapper {struct nlm4_testres xdrgen;struct nlm_lock lock;
@@ -67,6 +74,12 @@ struct nlm4_res_wrapper {static_assert (offsetof(struct nlm4_res_wrapper , xdrgen) ==0 ); +struct nlm4_shareres_wrapper { +struct nlm4_shareres xdrgen; +}; + +static_assert (offsetof(struct nlm4_shareres_wrapper , xdrgen) ==0 ); +void nlm4svc_set_file_lock_range (struct file_lock *fl,u64 off,u64 len);bool nlm4svc_decode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nlm4svc_decode_testargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 32/36 lockd: Use xdrgen XDR functions for the NLMv4 UNSHARE procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_UNSHARE entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 UNSHARE procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 84 +++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 34 deletions(-)
fs/lockd/svc4proc.c +50 -34
@@ -896,42 +896,58 @@ static __be32 nlm4svc_proc_share(struct svc_rqst *rqstp)return rpc_success; } -/* -* UNSHARE: Release a DOS share. +/** +* nlm4svc_proc_unshare - UNSHARE: Release a share reservation +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_drop_reply: Do not send an RPC reply. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The requested share lock was granted. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. */ -static __be32 -nlm4svc_proc_unshare (struct svc_rqst *rqstp) +static __be32 nlm4svc_proc_unshare (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; -struct nlm_res *resp = rqstp->rq_resp; +struct nlm4_shareargs_wrapper *argp = rqstp->rq_argp; +struct nlm4_shareres_wrapper *resp = rqstp->rq_resp;struct nlm_lock *lock = &argp->lock; -struct nlm_host *host; -struct nlm_file *file; +struct nlm4_lock xdr_lock = { + .fh = argp->xdrgen.share.fh, + .oh = argp->xdrgen.share.oh, + .svid = ~(u32 )0 , + }; +struct nlm_host *host =NULL ; +struct nlm_file *file =NULL ; -dprintk ("lockd: UNSHARE called\n" ); + resp->xdrgen.cookie = argp->xdrgen.cookie; - resp->cookie = argp->cookie; + resp->xdrgen.stat = nlm_lck_denied_grace_period; +if (locks_in_grace (SVC_NET (rqstp))) + goto out; -/* Don't accept requests during grace period */ -if (locks_in_grace (SVC_NET (rqstp))) { - resp->status = nlm_lck_denied_grace_period; -return rpc_success; - } + resp->xdrgen.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.share.caller_name, true); +if (!host) + goto out; -/* Obtain client and file */ -locks_init_lock (&lock->fl); - lock->svid = ~(u32 )0 ; - resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file); -if (resp->status) -return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; + resp->xdrgen.stat =nlm4svc_lookup_file (rqstp, host, lock, &file, + &xdr_lock,F_RDLCK ); +if (resp->xdrgen.stat) + goto out; -/* Now try to unshare the file */ - resp->status =nlmsvc_unshare_file (host, file, &lock->oh); -dprintk ("lockd: UNSHARE status %d\n" ,ntohl (resp->status)); + resp->xdrgen.stat =nlmsvc_unshare_file (host, file, &lock->oh); +nlmsvc_release_lockowner (lock); + +out: +if (file) +nlm_release_file (file);nlmsvc_release_host (host); -nlm_release_file (file);return rpc_success; }
@@ -1190,15 +1206,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_shareres_sz, .pc_name = "SHARE", }, - [NLMPROC_UNSHARE] = { - .pc_func = nlm4svc_proc_unshare, - .pc_decode = nlm4svc_decode_shareargs, - .pc_encode = nlm4svc_encode_shareres, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St+1, - .pc_name = "UNSHARE", + [NLMPROC4_UNSHARE] = { + .pc_func = nlm4svc_proc_unshare, + .pc_decode = nlm4_svc_decode_nlm4_shareargs, + .pc_encode = nlm4_svc_encode_nlm4_shareres, + .pc_argsize = sizeof(struct nlm4_shareargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_shareres_wrapper), + .pc_xdrressize = NLM4_nlm4_shareres_sz, + .pc_name = "UNSHARE", }, [NLMPROC_NM_LOCK] = { .pc_func = nlm4svc_proc_nm_lock,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 33/36 lockd: Use xdrgen XDR functions for the NLMv4 NM_LOCK procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_NM_LOCK entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 NM_LOCK procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 80 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 17 deletions(-)
fs/lockd/svc4proc.c +63 -17
@@ -951,18 +951,64 @@ static __be32 nlm4svc_proc_unshare(struct svc_rqst *rqstp)return rpc_success; } -/* -* NM_LOCK: Create an unmonitored lock +/** +* nlm4svc_proc_nm_lock - NM_LOCK: Establish a non-monitored lock +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. +* %rpc_drop_reply: Do not send an RPC reply. +* +* Permissible procedure status codes: +* %NLM4_GRANTED: The requested lock was granted. +* %NLM4_DENIED: The requested lock conflicted with existing +* lock reservations for the file. +* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources +* needed to process the request. +* %NLM4_BLOCKED: The blocking request cannot be granted +* immediately. The server will send an +* NLM_GRANTED procedure to the client when the +* lock can be granted. +* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is +* re-establishing existing locks, and is not +* yet ready to accept normal service requests. */ -static __be32 -nlm4svc_proc_nm_lock (struct svc_rqst *rqstp) +static __be32 nlm4svc_proc_nm_lock (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; +struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp; +unsigned char type = argp->xdrgen.exclusive ?F_WRLCK :F_RDLCK ; +struct nlm4_res_wrapper *resp = rqstp->rq_resp; +struct nlm_file *file =NULL ; +struct nlm_host *host; -dprintk ("lockd: NM_LOCK called\n" ); + resp->xdrgen.cookie = argp->xdrgen.cookie; - argp->monitor =0 ;/* just clean the monitor flag */ -return nlm4svc_proc_lock (rqstp); + resp->xdrgen.stat.stat = nlm_lck_denied_nolocks; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, true); +if (!host) + goto out; + + resp->xdrgen.stat.stat =nlm4svc_lookup_file (rqstp, host, &argp->lock, + &file, &argp->xdrgen.alock, + type); +if (resp->xdrgen.stat.stat) + goto out; + + resp->xdrgen.stat.stat =nlm4_netobj_to_cookie (&argp->cookie, + &argp->xdrgen.cookie); +if (resp->xdrgen.stat.stat) + goto out; + resp->xdrgen.stat.stat =nlmsvc_lock (rqstp, file, host, &argp->lock, + argp->xdrgen.block, &argp->cookie, + argp->xdrgen.reclaim); +nlmsvc_release_lockowner (&argp->lock); + +out: +if (file) +nlm_release_file (file); +nlmsvc_release_host (host); +return resp->xdrgen.stat.stat == nlm_drop_reply ? + rpc_drop_reply : rpc_success; }/*
@@ -1216,15 +1262,15 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_shareres_sz, .pc_name = "UNSHARE", }, - [NLMPROC_NM_LOCK] = { - .pc_func = nlm4svc_proc_nm_lock, - .pc_decode = nlm4svc_decode_lockargs, - .pc_encode = nlm4svc_encode_res, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_res), - .pc_xdrressize = Ck+St, - .pc_name = "NM_LOCK", + [NLMPROC4_NM_LOCK] = { + .pc_func = nlm4svc_proc_nm_lock, + .pc_decode = nlm4_svc_decode_nlm4_lockargs, + .pc_encode = nlm4_svc_encode_nlm4_res, + .pc_argsize = sizeof(struct nlm4_lockargs_wrapper), + .pc_argzero = 0, + .pc_ressize = sizeof(struct nlm4_res_wrapper), + .pc_xdrressize = NLM4_nlm4_res_sz, + .pc_name = "NM_LOCK", }, [NLMPROC_FREE_ALL] = { .pc_func = nlm4svc_proc_free_all,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 34/36 lockd: Use xdrgen XDR functions for the NLMv4 FREE_ALL procedure
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Replace the NLMPROC4_FREE_ALL entry in the nlm_procedures4 array with an entry that uses the xdrgen-built XDR functions for that procedure. Helper functions are introduced which will be used here and in subsequent patches.
The .pc_argzero field is now set to zero for the NLMv4 FREE_ALL procedure. The xdrgen decoders are trusted to initialize all arguments in the argp->xdrgen field, making the early defensive memset unnecessary. The remaining argp fields are cleared as needed.
--- fs/lockd/svc4proc.c | 102 ++++++++++---------------------------------- fs/lockd/xdr4.h | 6 +++ 2 files changed, 29 insertions(+), 79 deletions(-)
fs/lockd/svc4proc.c +23 -79
@@ -91,68 +91,6 @@ nlm4svc_lookup_file(struct svc_rqst *rqstp, struct nlm_host *host,return nlm_granted; } -/* -* Obtain client and file from arguments -*/ -static __be32 -nlm4svc_retrieve_args (struct svc_rqst *rqstp,struct nlm_args *argp, -struct nlm_host **hostp,struct nlm_file **filp) -{ -struct nlm_host *host =NULL ; -struct nlm_file *file =NULL ; -struct nlm_lock *lock = &argp->lock; -__be32 error =0 ; - -/* nfsd callbacks must have been installed for this procedure */ -if (!nlmsvc_ops) -return nlm_lck_denied_nolocks; - -if (lock->lock_start >OFFSET_MAX || - (lock->lock_len && ((lock->lock_len -1 ) > (OFFSET_MAX - lock->lock_start)))) -return nlm4_fbig; - -/* Obtain host handle */ -if (!(host =nlmsvc_lookup_host (rqstp, lock->caller, lock->len)) - || (argp->monitor &&nsm_monitor (host) <0 )) - goto no_locks; - *hostp = host; - -/* Obtain file pointer. Not used by FREE_ALL call. */ -if (filp !=NULL ) { -int mode =lock_to_openmode (&lock->fl); - - lock->fl.c.flc_flags =FL_POSIX ; - - error =nlm_lookup_file (rqstp, &file, lock); -if (error) - goto no_locks; - *filp = file; - -/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_file = file->f_file[mode]; - lock->fl.c.flc_pid = current->tgid; - lock->fl.fl_start = (loff_t )lock->lock_start; - lock->fl.fl_end = lock->lock_len ? - (loff_t)(lock->lock_start + lock->lock_len -1 ) : -OFFSET_MAX ; - lock->fl.fl_lmops = &nlmsvc_lock_operations; -nlmsvc_locks_init_private (&lock->fl, host, (pid_t )lock->svid); -if (!lock->fl.c.flc_owner) { -/* lockowner allocation has failed */ -nlmsvc_release_host (host); -return nlm_lck_denied_nolocks; - } - } - -return 0 ; - -no_locks: -nlmsvc_release_host (host); -if (error) -return error; -return nlm_lck_denied_nolocks; -} -/** * nlm4svc_proc_null - NULL: Do nothing * @rqstp: RPC transaction context
@@ -1011,21 +949,27 @@ static __be32 nlm4svc_proc_nm_lock(struct svc_rqst *rqstp) rpc_drop_reply : rpc_success; } -/* -* FREE_ALL: Release all locks and shares held by client +/** +* nlm4svc_proc_free_all - FREE_ALL: Discard client's lock and share state +* @rqstp: RPC transaction context +* +* Returns: +* %rpc_success: RPC executed successfully. */ -static __be32 -nlm4svc_proc_free_all (struct svc_rqst *rqstp) +static __be32 nlm4svc_proc_free_all (struct svc_rqst *rqstp) { -struct nlm_args *argp = rqstp->rq_argp; +struct nlm4_notify_wrapper *argp = rqstp->rq_argp;struct nlm_host *host; -/* Obtain client */ -if (nlm4svc_retrieve_args (rqstp, argp, &host,NULL )) -return rpc_success; + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.name, false); +if (!host) + goto out;nlmsvc_free_host_resources (host); +nlmsvc_release_host (host); + +out:return rpc_success; }
@@ -1272,14 +1216,14 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_xdrressize = NLM4_nlm4_res_sz, .pc_name = "NM_LOCK", }, - [NLMPROC_FREE_ALL] = { - .pc_func = nlm4svc_proc_free_all, - .pc_decode = nlm4svc_decode_notify, - .pc_encode = nlm4svc_encode_void, - .pc_argsize = sizeof(struct nlm_args), - .pc_argzero = sizeof(struct nlm_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "FREE_ALL", + [NLMPROC4_FREE_ALL] = { + .pc_func = nlm4svc_proc_free_all, + .pc_decode = nlm4_svc_decode_nlm4_notify, + .pc_encode = nlm4_svc_encode_void, + .pc_argsize = sizeof(struct nlm4_notify), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "FREE_ALL", }, };
fs/lockd/xdr4.h +6 -0
@@ -60,6 +60,12 @@ struct nlm4_shareargs_wrapper {static_assert (offsetof(struct nlm4_shareargs_wrapper , xdrgen) ==0 ); +struct nlm4_notify_wrapper { +struct nlm4_notify xdrgen; +}; + +static_assert (offsetof(struct nlm4_notify_wrapper , xdrgen) ==0 ); +struct nlm4_testres_wrapper {struct nlm4_testres xdrgen;struct nlm_lock lock;
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 35/36 lockd: Remove utilities that are no longer used
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/svc4proc.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
fs/lockd/svc4proc.c +1 -10
@@ -17,8 +17,6 @@#include "nlm4xdr_gen.h" #include "xdr4.h" -#define NLMDBG_FACILITY NLMDBG_CLIENT -static __be32 nlm4_netobj_to_cookie (struct nlm_cookie *cookie,netobj *object) {
@@ -975,16 +973,9 @@ static __be32 nlm4svc_proc_free_all(struct svc_rqst *rqstp)/* -* NLM Server procedures. +* NLMv4 Server procedures. */ -struct nlm_void {int dummy; }; - -#define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN))/* cookie */ -#define No (1+1024/4)/* netobj */ -#define St 1/* status */ -#define Rg 4/* range (offset + length) */ -const struct svc_procedure nlmsvc_procedures4[24 ] = { [NLMPROC4_NULL ] = { .pc_func = nlm4svc_proc_null,
Signature · 1 line
2.52.0
Chuck Lever
maintainerPATCH 36/36 lockd: Remove dead code from fs/lockd/xdr4.c
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
--- fs/lockd/Makefile | 2 +- fs/lockd/xdr4.c | 345 ---------------------------------------------- fs/lockd/xdr4.h | 25 ++-- 3 files changed, 12 insertions(+), 360 deletions(-) delete mode 100644 fs/lockd/xdr4.c
fs/lockd/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-$(CONFIG_LOCKD) += lockd.o lockd-y := clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \ svcshare.o svcproc.o svcsubs.o mon.o trace.o xdr.o netlink.o -lockd-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o nlm4xdr_gen.o +lockd-$(CONFIG_LOCKD_V4) += clnt4xdr.o svc4proc.o nlm4xdr_gen.o lockd-$(CONFIG_PROC_FS) += procfs.o .PHONY: xdrgen
fs/lockd/xdr4.c deleted +0 -345
345 lines not on this page · raw message
fs/lockd/xdr4.h +11 -14
@@ -8,6 +8,7 @@#ifndef _LOCKD_XDR4_H#define _LOCKD_XDR4_H +#include <linux/filelock.h> #include <linux/sunrpc/xdrgen/nlm4.h> /* error codes new to NLMv4 */
@@ -86,21 +87,17 @@ struct nlm4_shareres_wrapper {static_assert (offsetof(struct nlm4_shareres_wrapper , xdrgen) ==0 ); -void nlm4svc_set_file_lock_range (struct file_lock *fl,u64 off,u64 len); -bool nlm4svc_decode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_testargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_lockargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_cancargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_unlockargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_res (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_reboot (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_shareargs (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_decode_notify (struct svc_rqst *rqstp,struct xdr_stream *xdr); +static inline void +nlm4svc_set_file_lock_range (struct file_lock *fl,u64 off,u64 len) +{ +s64 end = off + len -1 ; -bool nlm4svc_encode_testres (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_encode_res (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_encode_void (struct svc_rqst *rqstp,struct xdr_stream *xdr); -bool nlm4svc_encode_shareres (struct svc_rqst *rqstp,struct xdr_stream *xdr); + fl->fl_start = off; +if (len ==0 || end <0 ) + fl->fl_end =OFFSET_MAX ; +else + fl->fl_end = end; +}extern const struct rpc_version nlm_version4;
Signature · 1 line
2.52.0
Jeff Layton
maintainerRe: [PATCH v1 35/36] lockd: Remove utilities that are no longer used
In reply to Chuck Levernit: title should probably read "Remove utility defines that are no longer used".
Quoted 38 lines · Chuck Lever
From: Chuck Lever <[email protected]>
Signed-off-by Chuck Lever <[email protected]>--- fs/lockd/svc4proc.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)fs/lockd/svc4proc.c +1
-10@@ -17,8 +17,6 @@#include "nlm4xdr_gen.h" #include "xdr4.h" -#define NLMDBG_FACILITY NLMDBG_CLIENT -static __be32 nlm4_netobj_to_cookie (struct nlm_cookie *cookie,netobj *object) {@@ -975,16 +973,9 @@ static __be32 nlm4svc_proc_free_all(struct svc_rqst *rqstp)/* -* NLM Server procedures. +* NLMv4 Server procedures. */ -struct nlm_void {int dummy; }; - -#define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN))/* cookie */ -#define No (1+1024/4)/* netobj */ -#define St 1/* status */ -#define Rg 4/* range (offset + length) */ -const struct svc_procedure nlmsvc_procedures4[24 ] = { [NLMPROC4_NULL ] = { .pc_func = nlm4svc_proc_null,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 104 lines · Chuck Lever
From: Chuck Lever <[email protected]>
The first nine patches in this series refactor the lockd code base to clearly separate its public API from internal implementation details.
The lockd subsystem currently exposes internal implementation headers through
include/linux/lockd/, creating implicit API contracts that complicate maintenance. External consumers such as NFSD and the NFS client have developed dependencies on internal structures like structnlm_host, and wire protocol constants leak into high-level module interfaces.These patches work to establish clean architectural boundaries. The public API in
include/linux/lockd/is reduced tobind.handnlm.h, which define the contract between lockd and its consumers. Private implementation details including XDR definitions, share management, and host structures are relocated tofs/lockd/where they belong. Layering violations are corrected: the NFS client now uses accessor helpers instead of dereferencing internal structures, andnlm_fopen()returns errno values instead of wire protocol codes.These changes enable subsequent work to modernize the NLMv4 XDR layer using xdrgen without risk of breaking external consumers. This work appears in the remaining patches in this series, which are presented here only to provide context for the API adjustments. No need to review those closely just yet.
The series is based on commit
771cfff228fcin the public nfsd-testing branch.Chuck Lever (36):
lockd: Havenlm_fopen()return errno values
lockd: Relocatenlmsvc_unlockAPI declarations
NFS: Usenlmclnt_rpc_clnt()helper to retrieve nlm_host'srpc_clnt
lockd: Movexdr4.hfrominclude/linux/lockd/tofs/lockd/
lockd: Moveshare.hfrominclude/linux/lockd/tofs/lockd/
lockd: Relocateinclude/linux/lockd/lockd.h
lockd: Removelockd/debug.h
lockd: Movexdr.hfrominclude/linux/lockd/tofs/lockd/
Documentation: Add the RPC language description of NLM version 4
lockd: Use xdrgen XDR functions for the NLMv4 NULL procedure
lockd: Use xdrgen XDR functions for the NLMv4 TEST procedure
lockd: Use xdrgen XDR functions for the NLMv4 LOCK procedure
lockd: Use xdrgen XDR functions for the NLMv4 CANCEL procedure
lockd: Use xdrgen XDR functions for the NLMv4 UNLOCK procedure
lockd: Use xdrgen XDR functions for the NLMv4 GRANTED procedure
lockd: Refactornlm4svc_callback()
lockd: Use xdrgen XDR functions for the NLMv4TEST_MSGprocedure
lockd: Use xdrgen XDR functions for the NLMv4LOCK_MSGprocedure
lockd: Use xdrgen XDR functions for the NLMv4CANCEL_MSGprocedure
lockd: Use xdrgen XDR functions for the NLMv4UNLOCK_MSGprocedure
lockd: Use xdrgen XDR functions for the NLMv4GRANTED_MSGprocedure
lockd: Convert server-sideNLMPROC4_TEST_RESto use xdrgen
lockd: Convert server-sideNLMPROC4_LOCK_RESto use xdrgen
lockd: Convert server-sideNLMPROC4_CANCEL_RESto use xdrgen
lockd: Convert server-sideNLMPROC4_UNLOCK_RESto use xdrgen
lockd: Convert server-sideNLMPROC4_GRANTED_RESto use xdrgen
lockd: Use xdrgen XDR functions for the NLMv4SM_NOTIFYprocedure
lockd: Convert server-side undefined procedures to xdrgen
lockd: Hoistfile_lockinit out ofnlm4svc_decode_shareargs()
lockd: Updateshare_filehelpers
lockd: Use xdrgen XDR functions for the NLMv4 SHARE procedure
lockd: Use xdrgen XDR functions for the NLMv4 UNSHARE procedure
lockd: Use xdrgen XDR functions for the NLMv4NM_LOCKprocedure
lockd: Use xdrgen XDR functions for the NLMv4FREE_ALLprocedure
lockd: Remove utilities that are no longer used
lockd: Remove dead code fromfs/lockd/xdr4.cDocumentation/sunrpc/xdr/nlm4.x | 211 ++++ fs/lockd/Makefile | 21 +- fs/lockd/clnt4xdr.c | 5 +- fs/lockd/clntlock.c | 2 +- fs/lockd/clntproc.c | 2 +- fs/lockd/clntxdr.c | 5 +- fs/lockd/host.c | 2 +- {include/linux => fs}/lockd/lockd.h | 49 +- fs/lockd/mon.c | 2 +- fs/lockd/nlm4xdr_gen.c | 724 +++++++++++++ fs/lockd/nlm4xdr_gen.h | 32 + {include/linux => fs}/lockd/share.h | 16 +- fs/lockd/svc.c | 2 +- fs/lockd/svc4proc.c | 1562 +++++++++++++++++---------- fs/lockd/svclock.c | 5 +- fs/lockd/svcproc.c | 13 +- fs/lockd/svcshare.c | 40 +- fs/lockd/svcsubs.c | 43 +- fs/lockd/trace.h | 3 +- fs/lockd/xdr.c | 3 +- {include/linux => fs}/lockd/xdr.h | 12 +- fs/lockd/xdr4.c | 347 ------ fs/lockd/xdr4.h | 104 ++ fs/nfs/sysfs.c | 10 +- fs/nfsd/lockd.c | 51 +- fs/nfsd/nfsctl.c | 2 +- include/linux/lockd/bind.h | 17 +- include/linux/lockd/debug.h | 40 - include/linux/lockd/xdr4.h | 43 - include/linux/sunrpc/xdrgen/nlm4.h | 231 ++++ 30 files changed, 2513 insertions(+), 1086 deletions(-) create mode 100644 Documentation/sunrpc/xdr/nlm4.x rename {include/linux => fs}/lockd/lockd.h (94%) create mode 100644 fs/lockd/nlm4xdr_gen.c
Quoted 8 lines
create mode 100644 fs/lockd/nlm4xdr_gen.h
rename {include/linux => fs}/lockd/share.h (63%)
rename {include/linux => fs}/lockd/xdr.h (94%)
delete mode 100644 fs/lockd/xdr4.c
create mode 100644 fs/lockd/xdr4.h
delete mode 100644 include/linux/lockd/debug.h
delete mode 100644 include/linux/lockd/xdr4.h
create mode 100644 include/linux/sunrpc/xdrgen/nlm4.hBig pile! I looked over the more interesting bits and didn't see anything objectionable. This looks like a nice change that removes a pile of stuff from include/ and gets lockd working with xdrgen'ed definitions. You can add: