Commit 9c88ef1f authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] kNFSd: Minor rearrangements in NFSv4 server code to prepare for mroe state management.

From: "William A.(Andy) Adamson" <andros@citi.umich.edu>

this is the first of several patches against 2.5 concerning NFSv4 state for
nfsd. it cleans up the names of state structures in preperation for future
share, lease, byte-range, and delegation patches. specifically, it

1) renames portions of the stateid_t and moves it along with the clientid_t
from xdr.h into state.h

2) uses xdr_netobj to gather related data and length fields in struct
nfs4_open (in xdr4.h) (e.g. we have op_fname.data and op_fname.len
instead of op_name and op_namelen).

3) renames NFSD4_CLIENT_MAXNAME to NFS4_OPAQUE_LIMIT which will be used in
other state fields (not just for name length)
parent bc70926a
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <linux/nfsd/nfsd.h> #include <linux/nfsd/nfsd.h>
#include <linux/nfsd/cache.h> #include <linux/nfsd/cache.h>
#include <linux/nfs4.h> #include <linux/nfs4.h>
#include <linux/nfsd/state.h>
#include <linux/nfsd/xdr4.h> #include <linux/nfsd/xdr4.h>
#define NFSDDBG_FACILITY NFSDDBG_PROC #define NFSDDBG_FACILITY NFSDDBG_PROC
...@@ -80,14 +81,14 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o ...@@ -80,14 +81,14 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
* Note: create modes (UNCHECKED,GUARDED...) are the same * Note: create modes (UNCHECKED,GUARDED...) are the same
* in NFSv4 as in v3. * in NFSv4 as in v3.
*/ */
status = nfsd_create_v3(rqstp, current_fh, open->op_name, status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data,
open->op_namelen, &open->op_iattr, open->op_fname.len, &open->op_iattr,
&resfh, open->op_createmode, &resfh, open->op_createmode,
(u32 *)open->op_verf, &open->op_truncate); (u32 *)open->op_verf, &open->op_truncate);
} }
else { else {
status = nfsd_lookup(rqstp, current_fh, status = nfsd_lookup(rqstp, current_fh,
open->op_name, open->op_namelen, &resfh); open->op_fname.data, open->op_fname.len, &resfh);
fh_unlock(current_fh); fh_unlock(current_fh);
} }
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
#include <linux/nfsd/nfsd.h> #include <linux/nfsd/nfsd.h>
#include <linux/nfsd/cache.h> #include <linux/nfsd/cache.h>
#include <linux/nfs4.h> #include <linux/nfs4.h>
#include <linux/nfsd/xdr4.h>
#include <linux/nfsd/state.h> #include <linux/nfsd/state.h>
#include <linux/nfsd/xdr4.h>
#define NFSDDBG_FACILITY NFSDDBG_PROC #define NFSDDBG_FACILITY NFSDDBG_PROC
...@@ -225,7 +225,7 @@ check_name(struct xdr_netobj name) { ...@@ -225,7 +225,7 @@ check_name(struct xdr_netobj name) {
if (name.len == 0) if (name.len == 0)
return 0; return 0;
if (name.len > NFSD4_CLIENT_MAXNAME) { if (name.len > NFS4_OPAQUE_LIMIT) {
printk("NFSD: check_name: name too long(%d)!\n", name.len); printk("NFSD: check_name: name too long(%d)!\n", name.len);
return 0; return 0;
} }
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/name_lookup.h> #include <linux/sunrpc/name_lookup.h>
#include <linux/nfsd/nfsd.h> #include <linux/nfsd/nfsd.h>
#include <linux/nfsd/state.h>
#include <linux/nfsd/xdr4.h> #include <linux/nfsd/xdr4.h>
#define NFSDDBG_FACILITY NFSDDBG_XDR #define NFSDDBG_FACILITY NFSDDBG_XDR
...@@ -483,8 +484,8 @@ nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) ...@@ -483,8 +484,8 @@ nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close)
READ_BUF(4 + sizeof(stateid_t)); READ_BUF(4 + sizeof(stateid_t));
READ32(close->cl_seqid); READ32(close->cl_seqid);
READ32(close->cl_stateid.st_generation); READ32(close->cl_stateid.si_generation);
COPYMEM(&close->cl_stateid.st_other, sizeof(stateid_other_t)); COPYMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t));
DECODE_TAIL; DECODE_TAIL;
} }
...@@ -595,11 +596,11 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) ...@@ -595,11 +596,11 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
READ32(open->op_share_access); READ32(open->op_share_access);
READ32(open->op_share_deny); READ32(open->op_share_deny);
COPYMEM(&open->op_clientid, sizeof(clientid_t)); COPYMEM(&open->op_clientid, sizeof(clientid_t));
READ32(open->op_ownerlen); READ32(open->op_owner.len);
/* owner, open_flag */ /* owner, open_flag */
READ_BUF(open->op_ownerlen + 4); READ_BUF(open->op_owner.len + 4);
SAVEMEM(open->op_owner, open->op_ownerlen); SAVEMEM(open->op_owner.data, open->op_owner.len);
READ32(open->op_create); READ32(open->op_create);
switch (open->op_create) { switch (open->op_create) {
case NFS4_OPEN_NOCREATE: case NFS4_OPEN_NOCREATE:
...@@ -632,10 +633,10 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) ...@@ -632,10 +633,10 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
case NFS4_OPEN_CLAIM_NULL: case NFS4_OPEN_CLAIM_NULL:
case NFS4_OPEN_CLAIM_DELEGATE_PREV: case NFS4_OPEN_CLAIM_DELEGATE_PREV:
READ_BUF(4); READ_BUF(4);
READ32(open->op_namelen); READ32(open->op_fname.len);
READ_BUF(open->op_namelen); READ_BUF(open->op_fname.len);
SAVEMEM(open->op_name, open->op_namelen); SAVEMEM(open->op_fname.data, open->op_fname.len);
if ((status = check_filename(open->op_name, open->op_namelen, nfserr_inval))) if ((status = check_filename(open->op_fname.data, open->op_fname.len, nfserr_inval)))
return status; return status;
break; break;
case NFS4_OPEN_CLAIM_PREVIOUS: case NFS4_OPEN_CLAIM_PREVIOUS:
...@@ -645,10 +646,10 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) ...@@ -645,10 +646,10 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
case NFS4_OPEN_CLAIM_DELEGATE_CUR: case NFS4_OPEN_CLAIM_DELEGATE_CUR:
READ_BUF(sizeof(delegation_stateid_t) + 4); READ_BUF(sizeof(delegation_stateid_t) + 4);
COPYMEM(&open->op_delegate_stateid, sizeof(delegation_stateid_t)); COPYMEM(&open->op_delegate_stateid, sizeof(delegation_stateid_t));
READ32(open->op_namelen); READ32(open->op_fname.len);
READ_BUF(open->op_namelen); READ_BUF(open->op_fname.len);
SAVEMEM(open->op_name, open->op_namelen); SAVEMEM(open->op_fname.data, open->op_fname.len);
if ((status = check_filename(open->op_name, open->op_namelen, nfserr_inval))) if ((status = check_filename(open->op_fname.data, open->op_fname.len, nfserr_inval)))
return status; return status;
break; break;
default: default:
...@@ -679,8 +680,8 @@ nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read) ...@@ -679,8 +680,8 @@ nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read)
DECODE_HEAD; DECODE_HEAD;
READ_BUF(sizeof(stateid_t) + 12); READ_BUF(sizeof(stateid_t) + 12);
READ32(read->rd_stateid.st_generation); READ32(read->rd_stateid.si_generation);
COPYMEM(&read->rd_stateid.st_other, sizeof(stateid_other_t)); COPYMEM(&read->rd_stateid.si_opaque, sizeof(stateid_opaque_t));
READ64(read->rd_offset); READ64(read->rd_offset);
READ32(read->rd_length); READ32(read->rd_length);
...@@ -755,8 +756,8 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta ...@@ -755,8 +756,8 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta
DECODE_HEAD; DECODE_HEAD;
READ_BUF(sizeof(stateid_t)); READ_BUF(sizeof(stateid_t));
READ32(setattr->sa_stateid.st_generation); READ32(setattr->sa_stateid.si_generation);
COPYMEM(&setattr->sa_stateid.st_other, sizeof(stateid_other_t)); COPYMEM(&setattr->sa_stateid.si_opaque, sizeof(stateid_opaque_t));
if ((status = nfsd4_decode_fattr(argp, setattr->sa_bmval, &setattr->sa_iattr))) if ((status = nfsd4_decode_fattr(argp, setattr->sa_bmval, &setattr->sa_iattr)))
goto out; goto out;
...@@ -825,8 +826,8 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) ...@@ -825,8 +826,8 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
DECODE_HEAD; DECODE_HEAD;
READ_BUF(sizeof(stateid_t) + 16); READ_BUF(sizeof(stateid_t) + 16);
READ32(write->wr_stateid.st_generation); READ32(write->wr_stateid.si_generation);
COPYMEM(&write->wr_stateid.st_other, sizeof(stateid_other_t)); COPYMEM(&write->wr_stateid.si_opaque, sizeof(stateid_opaque_t));
READ64(write->wr_offset); READ64(write->wr_offset);
READ32(write->wr_stable_how); READ32(write->wr_stable_how);
if (write->wr_stable_how > 2) if (write->wr_stable_how > 2)
...@@ -1543,8 +1544,8 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_clos ...@@ -1543,8 +1544,8 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_clos
if (!nfserr) { if (!nfserr) {
RESERVE_SPACE(sizeof(stateid_t)); RESERVE_SPACE(sizeof(stateid_t));
WRITE32(close->cl_stateid.st_generation); WRITE32(close->cl_stateid.si_generation);
WRITEMEM(&close->cl_stateid.st_other, sizeof(stateid_other_t)); WRITEMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t));
ADJUST_ARGS(); ADJUST_ARGS();
} }
} }
...@@ -1632,8 +1633,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_open ...@@ -1632,8 +1633,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, int nfserr, struct nfsd4_open
return; return;
RESERVE_SPACE(36 + sizeof(stateid_t)); RESERVE_SPACE(36 + sizeof(stateid_t));
WRITE32(open->op_stateid.st_generation); WRITE32(open->op_stateid.si_generation);
WRITEMEM(&open->op_stateid.st_other, sizeof(stateid_other_t)); WRITEMEM(&open->op_stateid.si_opaque, sizeof(stateid_opaque_t));
WRITECINFO(open->op_cinfo); WRITECINFO(open->op_cinfo);
WRITE32(open->op_rflags); WRITE32(open->op_rflags);
WRITE32(2); WRITE32(2);
......
...@@ -39,9 +39,25 @@ ...@@ -39,9 +39,25 @@
#include <linux/list.h> #include <linux/list.h>
#define NFSD4_CLIENT_MAXNAME 1024 #define NFS4_OPAQUE_LIMIT 1024
typedef struct {
u32 cl_boot;
u32 cl_id;
} clientid_t;
extern int nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid); typedef struct {
u32 so_boot;
u32 so_stateownerid;
u32 so_fileid;
} stateid_opaque_t;
typedef struct {
u32 si_generation;
stateid_opaque_t si_opaque;
} stateid_t;
#define si_boot si_opaque.so_boot
#define si_stateownerid si_opaque.so_stateownerid
#define si_fileid si_opaque.so_fileid
/* /*
* struct nfs4_client - one per client. Clientids live here. * struct nfs4_client - one per client. Clientids live here.
......
...@@ -41,27 +41,6 @@ ...@@ -41,27 +41,6 @@
#define NFSD4_MAX_TAGLEN 128 #define NFSD4_MAX_TAGLEN 128
typedef struct {
u32 cl_boot;
u32 cl_id;
} clientid_t;
typedef u32 stateid_boot_t; /* used to detect stale stateids */
typedef u32 stateid_lockowner_t; /* lockowner id - used in various places */
typedef u32 stateid_file_t; /* identifies a unique file per lockowner */
typedef u32 stateid_generation_t; /* used to update stateids */
typedef struct {
stateid_boot_t so_boot;
stateid_lockowner_t so_lockowner;
stateid_file_t so_file;
} stateid_other_t;
typedef struct {
stateid_generation_t st_generation;
stateid_other_t st_other;
} stateid_t;
typedef u32 delegation_zero_t; typedef u32 delegation_zero_t;
typedef u32 delegation_boot_t; typedef u32 delegation_boot_t;
typedef u64 delegation_id_t; typedef u64 delegation_id_t;
...@@ -143,8 +122,7 @@ struct nfsd4_putfh { ...@@ -143,8 +122,7 @@ struct nfsd4_putfh {
struct nfsd4_open { struct nfsd4_open {
u32 op_claim_type; /* request */ u32 op_claim_type; /* request */
u32 op_namelen; /* request - everything but CLAIM_PREV */ struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
char * op_name; /* request - everything but CLAIM_PREV */
u32 op_delegate_type; /* request - CLAIM_PREV only */ u32 op_delegate_type; /* request - CLAIM_PREV only */
delegation_stateid_t op_delegate_stateid; /* request - CLAIM_DELEGATE_CUR only */ delegation_stateid_t op_delegate_stateid; /* request - CLAIM_DELEGATE_CUR only */
u32 op_create; /* request */ u32 op_create; /* request */
...@@ -155,8 +133,7 @@ struct nfsd4_open { ...@@ -155,8 +133,7 @@ struct nfsd4_open {
nfs4_verifier verf; /* EXCLUSIVE4 */ nfs4_verifier verf; /* EXCLUSIVE4 */
} u; } u;
clientid_t op_clientid; /* request */ clientid_t op_clientid; /* request */
u32 op_ownerlen; /* request */ struct xdr_netobj op_owner; /* request */
char * op_owner; /* request */
u32 op_seqid; /* request */ u32 op_seqid; /* request */
u32 op_share_access; /* request */ u32 op_share_access; /* request */
u32 op_share_deny; /* request */ u32 op_share_deny; /* request */
...@@ -343,6 +320,8 @@ int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *, struct nfsd4_compoundre ...@@ -343,6 +320,8 @@ int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *, struct nfsd4_compoundre
void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
struct dentry *dentry, u32 *buffer, int *countp, u32 *bmval); struct dentry *dentry, u32 *buffer, int *countp, u32 *bmval);
extern int nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid);
extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp, struct nfsd4_setclientid_confirm *setclientid_confirm);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment