NFSD: Add nfsd4_encode_open_read_delegation4()
Refactor nfsd4_encode_open() so the open_read_delegation4 type is encoded in a separate function. This makes it more straightforward to later add support for returning an nfsace4 in OPEN responses that offer a delegation. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
c564178290
commit
e4ad7ce775
3 changed files with 49 additions and 20 deletions
|
@ -5688,11 +5688,11 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
|
||||||
struct path path;
|
struct path path;
|
||||||
|
|
||||||
cb_up = nfsd4_cb_channel_good(oo->oo_owner.so_client);
|
cb_up = nfsd4_cb_channel_good(oo->oo_owner.so_client);
|
||||||
open->op_recall = 0;
|
open->op_recall = false;
|
||||||
switch (open->op_claim_type) {
|
switch (open->op_claim_type) {
|
||||||
case NFS4_OPEN_CLAIM_PREVIOUS:
|
case NFS4_OPEN_CLAIM_PREVIOUS:
|
||||||
if (!cb_up)
|
if (!cb_up)
|
||||||
open->op_recall = 1;
|
open->op_recall = true;
|
||||||
break;
|
break;
|
||||||
case NFS4_OPEN_CLAIM_NULL:
|
case NFS4_OPEN_CLAIM_NULL:
|
||||||
parent = currentfh;
|
parent = currentfh;
|
||||||
|
@ -5746,7 +5746,7 @@ out_no_deleg:
|
||||||
if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS &&
|
if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS &&
|
||||||
open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) {
|
open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) {
|
||||||
dprintk("NFSD: WARNING: refusing delegation reclaim\n");
|
dprintk("NFSD: WARNING: refusing delegation reclaim\n");
|
||||||
open->op_recall = 1;
|
open->op_recall = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4.1 client asking for a delegation? */
|
/* 4.1 client asking for a delegation? */
|
||||||
|
|
|
@ -4078,6 +4078,49 @@ nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
return nfsd4_encode_change_info4(xdr, &link->li_cinfo);
|
return nfsd4_encode_change_info4(xdr, &link->li_cinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This implementation does not yet support returning an ACE in an
|
||||||
|
* OPEN that offers a delegation.
|
||||||
|
*/
|
||||||
|
static __be32
|
||||||
|
nfsd4_encode_open_nfsace4(struct xdr_stream *xdr)
|
||||||
|
{
|
||||||
|
__be32 status;
|
||||||
|
|
||||||
|
/* type */
|
||||||
|
status = nfsd4_encode_acetype4(xdr, NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE);
|
||||||
|
if (status != nfs_ok)
|
||||||
|
return nfserr_resource;
|
||||||
|
/* flag */
|
||||||
|
status = nfsd4_encode_aceflag4(xdr, 0);
|
||||||
|
if (status != nfs_ok)
|
||||||
|
return nfserr_resource;
|
||||||
|
/* access mask */
|
||||||
|
status = nfsd4_encode_acemask4(xdr, 0);
|
||||||
|
if (status != nfs_ok)
|
||||||
|
return nfserr_resource;
|
||||||
|
/* who - empty for now */
|
||||||
|
if (xdr_stream_encode_u32(xdr, 0) != XDR_UNIT)
|
||||||
|
return nfserr_resource;
|
||||||
|
return nfs_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __be32
|
||||||
|
nfsd4_encode_open_read_delegation4(struct xdr_stream *xdr, struct nfsd4_open *open)
|
||||||
|
{
|
||||||
|
__be32 status;
|
||||||
|
|
||||||
|
/* stateid */
|
||||||
|
status = nfsd4_encode_stateid4(xdr, &open->op_delegate_stateid);
|
||||||
|
if (status != nfs_ok)
|
||||||
|
return status;
|
||||||
|
/* recall */
|
||||||
|
status = nfsd4_encode_bool(xdr, open->op_recall);
|
||||||
|
if (status != nfs_ok)
|
||||||
|
return status;
|
||||||
|
/* permissions */
|
||||||
|
return nfsd4_encode_open_nfsace4(xdr);
|
||||||
|
}
|
||||||
|
|
||||||
static __be32
|
static __be32
|
||||||
nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr,
|
nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
|
@ -4110,22 +4153,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
case NFS4_OPEN_DELEGATE_NONE:
|
case NFS4_OPEN_DELEGATE_NONE:
|
||||||
break;
|
break;
|
||||||
case NFS4_OPEN_DELEGATE_READ:
|
case NFS4_OPEN_DELEGATE_READ:
|
||||||
nfserr = nfsd4_encode_stateid4(xdr, &open->op_delegate_stateid);
|
/* read */
|
||||||
if (nfserr)
|
return nfsd4_encode_open_read_delegation4(xdr, open);
|
||||||
return nfserr;
|
|
||||||
p = xdr_reserve_space(xdr, 20);
|
|
||||||
if (!p)
|
|
||||||
return nfserr_resource;
|
|
||||||
*p++ = cpu_to_be32(open->op_recall);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: ACE's in delegations
|
|
||||||
*/
|
|
||||||
*p++ = cpu_to_be32(NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE);
|
|
||||||
*p++ = cpu_to_be32(0);
|
|
||||||
*p++ = cpu_to_be32(0);
|
|
||||||
*p++ = cpu_to_be32(0); /* XXX: is NULL principal ok? */
|
|
||||||
break;
|
|
||||||
case NFS4_OPEN_DELEGATE_WRITE:
|
case NFS4_OPEN_DELEGATE_WRITE:
|
||||||
nfserr = nfsd4_encode_stateid4(xdr, &open->op_delegate_stateid);
|
nfserr = nfsd4_encode_stateid4(xdr, &open->op_delegate_stateid);
|
||||||
if (nfserr)
|
if (nfserr)
|
||||||
|
|
|
@ -380,9 +380,9 @@ struct nfsd4_open {
|
||||||
u32 op_deleg_want; /* request */
|
u32 op_deleg_want; /* request */
|
||||||
stateid_t op_stateid; /* response */
|
stateid_t op_stateid; /* response */
|
||||||
__be32 op_xdr_error; /* see nfsd4_open_omfg() */
|
__be32 op_xdr_error; /* see nfsd4_open_omfg() */
|
||||||
u32 op_recall; /* recall */
|
|
||||||
struct nfsd4_change_info op_cinfo; /* response */
|
struct nfsd4_change_info op_cinfo; /* response */
|
||||||
u32 op_rflags; /* response */
|
u32 op_rflags; /* response */
|
||||||
|
bool op_recall; /* response */
|
||||||
bool op_truncate; /* used during processing */
|
bool op_truncate; /* used during processing */
|
||||||
bool op_created; /* used during processing */
|
bool op_created; /* used during processing */
|
||||||
struct nfs4_openowner *op_openowner; /* used during processing */
|
struct nfs4_openowner *op_openowner; /* used during processing */
|
||||||
|
|
Loading…
Add table
Reference in a new issue