From: Christoph Hellwig <hch@lst.de>
To: Trond Myklebust <trond.myklebust@primarydata.com>,
Anna Schumaker <anna.schumaker@netapp.com>,
"J. Bruce Fields" <bfields@fieldses.org>,
Jeff Layton <jlayton@poochiereds.net>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 25/32] nfsd4: properly type op_set_currentstateid callbacks
Date: Tue, 9 May 2017 11:20:03 +0200 [thread overview]
Message-ID: <20170509092010.30752-26-hch@lst.de> (raw)
In-Reply-To: <20170509092010.30752-1-hch@lst.de>
Given the args union in struct nfsd4_op a name, and pass it to the
op_set_currentstateid callbacks instead of using unsafe function
pointer casts.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/nfsd/current_stateid.h | 12 ++++++++----
fs/nfsd/nfs4proc.c | 12 ++++++------
fs/nfsd/nfs4state.c | 20 ++++++++++++--------
fs/nfsd/xdr4.h | 2 +-
4 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/fs/nfsd/current_stateid.h b/fs/nfsd/current_stateid.h
index 4123551208d8..3c80a7b5302d 100644
--- a/fs/nfsd/current_stateid.h
+++ b/fs/nfsd/current_stateid.h
@@ -8,10 +8,14 @@ extern void clear_current_stateid(struct nfsd4_compound_state *cstate);
/*
* functions to set current state id
*/
-extern void nfsd4_set_opendowngradestateid(struct nfsd4_compound_state *cstate, struct nfsd4_open_downgrade *);
-extern void nfsd4_set_openstateid(struct nfsd4_compound_state *, struct nfsd4_open *);
-extern void nfsd4_set_lockstateid(struct nfsd4_compound_state *, struct nfsd4_lock *);
-extern void nfsd4_set_closestateid(struct nfsd4_compound_state *, struct nfsd4_close *);
+extern void nfsd4_set_opendowngradestateid(struct nfsd4_compound_state *,
+ union nfsd4_op_u *);
+extern void nfsd4_set_openstateid(struct nfsd4_compound_state *,
+ union nfsd4_op_u *);
+extern void nfsd4_set_lockstateid(struct nfsd4_compound_state *,
+ union nfsd4_op_u *);
+extern void nfsd4_set_closestateid(struct nfsd4_compound_state *,
+ union nfsd4_op_u *);
/*
* functions to consume current state id
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 1e0387a1e32f..49640f6ffb8d 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1524,7 +1524,6 @@ typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
void *);
typedef u32(*nfsd4op_rsize)(struct svc_rqst *, struct nfsd4_op *op);
-typedef void(*stateid_setter)(struct nfsd4_compound_state *, void *);
typedef void(*stateid_getter)(struct nfsd4_compound_state *, void *);
enum nfsd4_op_flags {
@@ -1564,7 +1563,8 @@ struct nfsd4_operation {
/* Try to get response size before operation */
nfsd4op_rsize op_rsize_bop;
stateid_getter op_get_currentstateid;
- stateid_setter op_set_currentstateid;
+ void (*op_set_currentstateid)(struct nfsd4_compound_state *,
+ union nfsd4_op_u *);
};
static struct nfsd4_operation nfsd4_ops[];
@@ -2104,7 +2104,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_name = "OP_CLOSE",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_status_stateid_rsize,
.op_get_currentstateid = (stateid_getter)nfsd4_get_closestateid,
- .op_set_currentstateid = (stateid_setter)nfsd4_set_closestateid,
+ .op_set_currentstateid = nfsd4_set_closestateid,
},
[OP_COMMIT] = {
.op_func = (nfsd4op_func)nfsd4_commit,
@@ -2148,7 +2148,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_flags = OP_MODIFIES_SOMETHING,
.op_name = "OP_LOCK",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_lock_rsize,
- .op_set_currentstateid = (stateid_setter)nfsd4_set_lockstateid,
+ .op_set_currentstateid = nfsd4_set_lockstateid,
},
[OP_LOCKT] = {
.op_func = (nfsd4op_func)nfsd4_lockt,
@@ -2184,7 +2184,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_flags = OP_HANDLES_WRONGSEC | OP_MODIFIES_SOMETHING,
.op_name = "OP_OPEN",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_open_rsize,
- .op_set_currentstateid = (stateid_setter)nfsd4_set_openstateid,
+ .op_set_currentstateid = nfsd4_set_openstateid,
},
[OP_OPEN_CONFIRM] = {
.op_func = (nfsd4op_func)nfsd4_open_confirm,
@@ -2198,7 +2198,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_name = "OP_OPEN_DOWNGRADE",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_status_stateid_rsize,
.op_get_currentstateid = (stateid_getter)nfsd4_get_opendowngradestateid,
- .op_set_currentstateid = (stateid_setter)nfsd4_set_opendowngradestateid,
+ .op_set_currentstateid = nfsd4_set_opendowngradestateid,
},
[OP_PUTFH] = {
.op_func = (nfsd4op_func)nfsd4_putfh,
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index e9ef50addddb..4cf05b59ddf6 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -7116,27 +7116,31 @@ clear_current_stateid(struct nfsd4_compound_state *cstate)
* functions to set current state id
*/
void
-nfsd4_set_opendowngradestateid(struct nfsd4_compound_state *cstate, struct nfsd4_open_downgrade *odp)
+nfsd4_set_opendowngradestateid(struct nfsd4_compound_state *cstate,
+ union nfsd4_op_u *u)
{
- put_stateid(cstate, &odp->od_stateid);
+ put_stateid(cstate, &u->open_downgrade.od_stateid);
}
void
-nfsd4_set_openstateid(struct nfsd4_compound_state *cstate, struct nfsd4_open *open)
+nfsd4_set_openstateid(struct nfsd4_compound_state *cstate,
+ union nfsd4_op_u *u)
{
- put_stateid(cstate, &open->op_stateid);
+ put_stateid(cstate, &u->open.op_stateid);
}
void
-nfsd4_set_closestateid(struct nfsd4_compound_state *cstate, struct nfsd4_close *close)
+nfsd4_set_closestateid(struct nfsd4_compound_state *cstate,
+ union nfsd4_op_u *u)
{
- put_stateid(cstate, &close->cl_stateid);
+ put_stateid(cstate, &u->close.cl_stateid);
}
void
-nfsd4_set_lockstateid(struct nfsd4_compound_state *cstate, struct nfsd4_lock *lock)
+nfsd4_set_lockstateid(struct nfsd4_compound_state *cstate,
+ union nfsd4_op_u *u)
{
- put_stateid(cstate, &lock->lk_resp_stateid);
+ put_stateid(cstate, &u->lock.lk_resp_stateid);
}
/*
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index eb7f9239304f..b625f4aa1061 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -539,7 +539,7 @@ struct nfsd4_seek {
struct nfsd4_op {
int opnum;
__be32 status;
- union {
+ union nfsd4_op_u {
struct nfsd4_access access;
struct nfsd4_close close;
struct nfsd4_commit commit;
--
2.11.0
next prev parent reply other threads:[~2017-05-09 9:21 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 9:19 RFC: remove function pointer casts and constify function tables Christoph Hellwig
2017-05-09 9:19 ` [PATCH 01/32] sunrpc: properly type argument to kxdreproc_t Christoph Hellwig
2017-05-09 9:19 ` [PATCH 02/32] sunrpc: fix encoder callback prototypes Christoph Hellwig
2017-05-09 9:43 ` Mkrtchyan, Tigran
2017-05-09 13:11 ` Christoph Hellwig
2017-05-09 13:30 ` Jeff Layton
2017-05-09 14:17 ` J. Bruce Fields
2017-05-10 18:38 ` J. Bruce Fields
2017-05-09 12:28 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 03/32] lockd: " Christoph Hellwig
2017-05-09 12:29 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 04/32] nfs: " Christoph Hellwig
2017-05-09 12:30 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 05/32] nfsd: " Christoph Hellwig
2017-05-09 9:19 ` [PATCH 06/32] sunrpc/auth_gss: " Christoph Hellwig
2017-05-09 12:32 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 07/32] sunrpc: properly type argument to kxdrdproc_t Christoph Hellwig
2017-05-09 12:34 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 08/32] sunrpc: fix decoder callback prototypes Christoph Hellwig
2017-05-09 9:19 ` [PATCH 09/32] sunrpc/auth_gss: " Christoph Hellwig
2017-05-09 12:35 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 10/32] nfsd: " Christoph Hellwig
2017-05-09 9:19 ` [PATCH 11/32] lockd: " Christoph Hellwig
2017-05-09 12:36 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 12/32] nfs: " Christoph Hellwig
2017-05-09 12:37 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 13/32] nfs: don't cast callback decode/proc/encode routines Christoph Hellwig
2017-05-09 12:38 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 14/32] RFC: sunrpc: remove p_count Christoph Hellwig
2017-05-09 12:41 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 15/32] sunrpc: mark all struct rpc_procinfo instances as const Christoph Hellwig
2017-05-09 12:42 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 16/32] lockd: fix some weird indentation Christoph Hellwig
2017-05-09 12:43 ` Trond Myklebust
2017-05-09 9:19 ` [PATCH 17/32] nfsd4: const-ify nfs_cb_version4 Christoph Hellwig
2017-05-09 9:19 ` [PATCH 18/32] nfsd: use named initializers in PROC() Christoph Hellwig
2017-05-09 9:19 ` [PATCH 19/32] nfsd: remove the unused PROC() macro in nfs3proc.c Christoph Hellwig
2017-05-09 9:19 ` [PATCH 20/32] sunrpc: properly type pc_func callbacks Christoph Hellwig
2017-05-09 9:19 ` [PATCH 21/32] sunrpc: properly type pc_release callbacks Christoph Hellwig
2017-05-09 9:20 ` [PATCH 22/32] sunrpc: properly type pc_decode callbacks Christoph Hellwig
2017-05-09 9:20 ` [PATCH 23/32] sunrpc: properly type pc_encode callbacks Christoph Hellwig
2017-05-09 12:10 ` Trond Myklebust
2017-05-09 9:20 ` [PATCH 24/32] sunrpc: remove kxdrproc_t Christoph Hellwig
2017-05-09 9:20 ` Christoph Hellwig [this message]
2017-05-09 9:20 ` [PATCH 26/32] nfsd4: properly type op_get_currentstateid callbacks Christoph Hellwig
2017-05-09 9:20 ` [PATCH 27/32] nfsd4: remove nfsd4op_rsize Christoph Hellwig
2017-05-09 9:20 ` [PATCH 28/32] nfsd4: properly type op_func callbacks Christoph Hellwig
2017-05-09 9:20 ` [PATCH 29/32] RFC: sunrpc: remove pc_count Christoph Hellwig
2017-05-09 12:16 ` Trond Myklebust
2017-05-09 13:43 ` Chuck Lever
2017-05-09 17:35 ` Jeff Layton
2017-05-09 9:20 ` [PATCH 30/32] sunrpc: mark all struct svc_procinfo instances as const Christoph Hellwig
2017-05-09 9:20 ` [PATCH 31/32] sunrpc: mark all struct svc_version " Christoph Hellwig
2017-05-09 12:11 ` Trond Myklebust
2017-05-09 9:20 ` [PATCH 32/32] nfsd4: const-ify nfsd4_ops Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170509092010.30752-26-hch@lst.de \
--to=hch@lst.de \
--cc=anna.schumaker@netapp.com \
--cc=bfields@fieldses.org \
--cc=jlayton@poochiereds.net \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).