[pnfs] [PATCH 4/4] nfsd41: CREATE_EXCLUSIVE4_1

Benny Halevy bhalevy at panasas.com
Mon May 12 15:45:16 EDT 2008


On May. 12, 2008, 12:04 -0700, Dean Hildebrand <seattleplus at gmail.com> wrote:
> 
> Benny Halevy wrote:
>> Signed-off-by: Benny Halevy <bhalevy at panasas.com>
>> ---
>>  fs/nfsd/nfs4proc.c        |   15 +++++++++++++++
>>  fs/nfsd/nfs4xdr.c         |   21 +++++++++++++++++++++
>>  include/linux/nfs4.h      |    8 +++++++-
>>  include/linux/nfsd/xdr4.h |   10 ++++------
>>  4 files changed, 47 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
>> index 5430c0f..ba1fce7 100644
>> --- a/fs/nfsd/nfs4proc.c
>> +++ b/fs/nfsd/nfs4proc.c
>> @@ -149,6 +149,21 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
>>  	open->op_truncate = 0;
>>  
>>  	if (open->op_create) {
>> +		/* FIXME: check session persistence and pnfs flags.
>> +		 * The nfsv4.1 spec requires the following semantics:
>> +		 *
>> +		 * Persistent   | pNFS   | Server REQUIRED | Client Allowed
>> +		 * Reply Cache  | server |                 |
>> +		 * -------------+--------+-----------------+--------------------
>> +		 * no           | no     | EXCLUSIVE4_1    | EXCLUSIVE4_1
>> +		 *              |        |                 | (SHOULD)
>> +		 *              |        | and EXCLUSIVE4  | or EXCLUSIVE4
>> +		 *              |        |                 | (SHOULD NOT)
>> +		 * no           | yes    | EXCLUSIVE4_1    | EXCLUSIVE4_1
>> +		 * yes          | no     | GUARDED4        | GUARDED4
>> +		 * yes          | yes    | GUARDED4        | GUARDED4
>> +		 */
>> +
>>  		/*
>>  		 * Note: create modes (UNCHECKED,GUARDED...) are the same
>>  		 * in NFSv4 as in v3.
>> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
>> index 8173af8..173e8de 100644
>> --- a/fs/nfsd/nfs4xdr.c
>> +++ b/fs/nfsd/nfs4xdr.c
>> @@ -262,6 +262,14 @@ static u32 nfsd_attrmask[] = {
>>  	NFSD_WRITEABLE_ATTRS_WORD2
>>  };
>>  
>> +#if defined(CONFIG_NFSD_V4_1)
>> +static u32 nfsd41_ex_attrmask[] = {
>> +	NFSD_SUPPATTR_EXCLCREAT_WORD0,
>> +	NFSD_SUPPATTR_EXCLCREAT_WORD1,
>> +	NFSD_SUPPATTR_EXCLCREAT_WORD2
>> +};
>> +#endif /* CONFIG_NFSD_V4_1 */
>> +
>>  static __be32
>>  nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, u32 *writable,
>>  		   struct iattr *iattr, struct nfs4_acl **acl)
>> @@ -691,6 +699,19 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
>>  			READ_BUF(8);
>>  			COPYMEM(open->op_verf.data, 8);
>>  			break;
>> +#if defined(CONFIG_NFSD_V4_1)
>> +		case NFS4_CREATE_EXCLUSIVE4_1:
>> +			if (argp->minorversion < 1)
>> +				goto xdr_error;
>> +			READ_BUF(8);
>> +			COPYMEM(open->op_verf.data, 8);
>> +			status = nfsd4_decode_fattr(argp, open->op_bmval,
>> +				nfsd41_ex_attrmask, &open->op_iattr,
>> +				&open->op_acl);
>> +			if (status)
>> +				goto out;
>> +			break;
>> +#endif /* CONFIG_NFSD_V4_1 */
>>  		default:
>>  			goto xdr_error;
>>  		}
>> diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
>> index 190f070..382a779 100644
>> --- a/include/linux/nfs4.h
>> +++ b/include/linux/nfs4.h
>> @@ -331,7 +331,13 @@ enum opentype4 {
>>  enum createmode4 {
>>  	NFS4_CREATE_UNCHECKED = 0,
>>  	NFS4_CREATE_GUARDED = 1,
>> -	NFS4_CREATE_EXCLUSIVE = 2
>> +	NFS4_CREATE_EXCLUSIVE = 2,
>> +	/*
>> +	 * New to NFSv4.1. If session is persistent,
>> +	 * GUARDED4 MUST be used. Otherwise, use
>> +	 * EXCLUSIVE4_1 instead of EXCLUSIVE4.
>> +	 */
>> +	NFS4_CREATE_EXCLUSIVE4_1 = 3
>>   
> Should this be under ifdef?

I didn't want to do this here in the protocol definition since this
would force a corresponding #ifdef everywhere it is used.

Benny

>>  };
>>  
>>  enum limit_by4 {
>> diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
>> index 8b4b48d..2988c8c 100644
>> --- a/include/linux/nfsd/xdr4.h
>> +++ b/include/linux/nfsd/xdr4.h
>> @@ -211,10 +211,8 @@ struct nfsd4_open {
>>  	u32		op_create;     	    /* request */
>>  	u32		op_createmode;      /* request */
>>  	u32		op_bmval[3];        /* request */
>> -	union {                             /* request */
>> -		struct iattr	iattr;                      /* UNCHECKED4,GUARDED4 */
>> -		nfs4_verifier	verf;                                /* EXCLUSIVE4 */
>> -	} u;
>> +	struct iattr	iattr;              /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
>> +	nfs4_verifier	verf;               /* EXCLUSIVE4 */
>>  	clientid_t	op_clientid;        /* request */
>>  	struct xdr_netobj op_owner;           /* request */
>>  	u32		op_seqid;           /* request */
>> @@ -229,8 +227,8 @@ struct nfsd4_open {
>>  	struct nfs4_stateowner *op_stateowner; /* used during processing */
>>  	struct nfs4_acl *op_acl;
>>  };
>> -#define op_iattr	u.iattr
>> -#define op_verf		u.verf
>> +#define op_iattr	iattr
>> +#define op_verf		verf
>>   
> Why is it no longer a union?

Since the client may pass both a verifier and attrs in EXCLUSIVE4_1 createmode.
This is the mode's purpose.

Benny

> Dean
>>  
>>  struct nfsd4_open_confirm {
>>  	stateid_t	oc_req_stateid		/* request */;
>>   
> _______________________________________________
> pNFS mailing list
> pNFS at linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs



More information about the pNFS mailing list