Commit 8c7424cf authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: don't try to encode conflicting owner if low on space

I ran into this corner case in testing: in theory clients can provide
state owners up to 1024 bytes long.  In the sessions case there might be
a risk of this pushing us over the DRC slot size.

The conflicting owner isn't really that important, so let's humor a
client that provides a small maxresponsize_cached by allowing ourselves
to return without the conflicting owner instead of outright failing the
operation.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent f5236013
...@@ -1432,7 +1432,8 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, ...@@ -1432,7 +1432,8 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
#define op_encode_change_info_maxsz (5) #define op_encode_change_info_maxsz (5)
#define nfs4_fattr_bitmap_maxsz (4) #define nfs4_fattr_bitmap_maxsz (4)
#define op_encode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) /* We'll fall back on returning no lockowner if run out of space: */
#define op_encode_lockowner_maxsz (0)
#define op_encode_lock_denied_maxsz (8 + op_encode_lockowner_maxsz) #define op_encode_lock_denied_maxsz (8 + op_encode_lockowner_maxsz)
#define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
......
...@@ -2878,9 +2878,20 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld) ...@@ -2878,9 +2878,20 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld)
struct xdr_netobj *conf = &ld->ld_owner; struct xdr_netobj *conf = &ld->ld_owner;
__be32 *p; __be32 *p;
again:
p = xdr_reserve_space(xdr, 32 + XDR_LEN(conf->len)); p = xdr_reserve_space(xdr, 32 + XDR_LEN(conf->len));
if (!p) if (!p) {
/*
* Don't fail to return the result just because we can't
* return the conflicting open:
*/
if (conf->len) {
conf->len = 0;
conf->data = NULL;
goto again;
}
return nfserr_resource; return nfserr_resource;
}
WRITE64(ld->ld_start); WRITE64(ld->ld_start);
WRITE64(ld->ld_length); WRITE64(ld->ld_length);
WRITE32(ld->ld_type); WRITE32(ld->ld_type);
...@@ -2888,7 +2899,6 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld) ...@@ -2888,7 +2899,6 @@ nfsd4_encode_lock_denied(struct xdr_stream *xdr, struct nfsd4_lock_denied *ld)
WRITEMEM(&ld->ld_clientid, 8); WRITEMEM(&ld->ld_clientid, 8);
WRITE32(conf->len); WRITE32(conf->len);
WRITEMEM(conf->data, conf->len); WRITEMEM(conf->data, conf->len);
kfree(conf->data);
} else { /* non - nfsv4 lock in conflict, no clientid nor owner */ } else { /* non - nfsv4 lock in conflict, no clientid nor owner */
WRITE64((u64)0); /* clientid */ WRITE64((u64)0); /* clientid */
WRITE32(0); /* length of owner name */ WRITE32(0); /* length of owner name */
...@@ -2905,7 +2915,7 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo ...@@ -2905,7 +2915,7 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo
nfserr = nfsd4_encode_stateid(xdr, &lock->lk_resp_stateid); nfserr = nfsd4_encode_stateid(xdr, &lock->lk_resp_stateid);
else if (nfserr == nfserr_denied) else if (nfserr == nfserr_denied)
nfserr = nfsd4_encode_lock_denied(xdr, &lock->lk_denied); nfserr = nfsd4_encode_lock_denied(xdr, &lock->lk_denied);
kfree(lock->lk_denied.ld_owner.data);
return nfserr; return nfserr;
} }
......
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