]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
nfsd4: properly type op_set_currentstateid callbacks
authorChristoph Hellwig <hch@lst.de>
Mon, 8 May 2017 18:03:15 +0000 (20:03 +0200)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 13 Jul 2017 19:58:01 +0000 (15:58 -0400)
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
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nfsd/xdr4.h

index 4123551208d88d637593331d697f264fe77df908..3c80a7b5302daea7fc2c1f7e75c1b79b3ee51958 100644 (file)
@@ -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
index 726d28376f7b571b41014719cab4ebd7ecd57950..91cee9e2b4f397c48e84c3f6915644059655dfff 100644 (file)
@@ -1525,7 +1525,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 {
@@ -1565,7 +1564,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,
index 22002fb75a1827f2ca08bd1dcf23a775669fdd14..f9552357923e8785cef0b8ac5b0626222ba6d8b9 100644 (file)
@@ -7103,27 +7103,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);
 }
 
 /*
index eb7f9239304ff628be6c146d2d52acce0810bb15..b625f4aa1061e5a46c03ef00ff169b2fe7212115 100644 (file)
@@ -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;