Skip to content

Commit 43502f6

Browse files
neilbrownTrond Myklebust
authored andcommitted
NFS: fix open_owner_id_maxsz and related fields.
A recent change increased the size of an NFSv4 open owner, but didn't increase the corresponding max_sz defines. This is not know to have caused failure, but should be fixed. This patch also fixes some relates _maxsz fields that are wrong. Note that the XXX_owner_id_maxsz values now are only the size of the id and do NOT include the len field that will always preceed the id in xdr encoding. I think this is clearer. Reported-by: David Disseldorp <[email protected]> Fixes: d98f722 ("nfs: simplify and guarantee owner uniqueness.") Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent e767b59 commit 43502f6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fs/nfs/nfs4xdr.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
8282
* we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
8383
*/
8484
#define pagepad_maxsz (1)
85-
#define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2)
86-
#define lock_owner_id_maxsz (1 + 1 + 4)
87-
#define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
85+
#define open_owner_id_maxsz (2 + 1 + 2 + 2)
86+
#define lock_owner_id_maxsz (2 + 1 + 2)
8887
#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
8988
#define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
9089
#define op_encode_hdr_maxsz (1)
@@ -185,7 +184,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
185184
#define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
186185
#define encode_open_maxsz (op_encode_hdr_maxsz + \
187186
2 + encode_share_access_maxsz + 2 + \
188-
open_owner_id_maxsz + \
187+
1 + open_owner_id_maxsz + \
189188
encode_opentype_maxsz + \
190189
encode_claim_null_maxsz)
191190
#define decode_space_limit_maxsz (3)
@@ -255,13 +254,14 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
255254
#define encode_link_maxsz (op_encode_hdr_maxsz + \
256255
nfs4_name_maxsz)
257256
#define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
258-
#define encode_lockowner_maxsz (7)
257+
#define encode_lockowner_maxsz (2 + 1 + lock_owner_id_maxsz)
258+
259259
#define encode_lock_maxsz (op_encode_hdr_maxsz + \
260260
7 + \
261261
1 + encode_stateid_maxsz + 1 + \
262262
encode_lockowner_maxsz)
263263
#define decode_lock_denied_maxsz \
264-
(8 + decode_lockowner_maxsz)
264+
(2 + 2 + 1 + 2 + 1 + lock_owner_id_maxsz)
265265
#define decode_lock_maxsz (op_decode_hdr_maxsz + \
266266
decode_lock_denied_maxsz)
267267
#define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \
@@ -617,7 +617,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
617617
encode_lockowner_maxsz)
618618
#define NFS4_dec_release_lockowner_sz \
619619
(compound_decode_hdr_maxsz + \
620-
decode_lockowner_maxsz)
620+
decode_release_lockowner_maxsz)
621621
#define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
622622
encode_sequence_maxsz + \
623623
encode_putfh_maxsz + \
@@ -1412,7 +1412,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
14121412
__be32 *p;
14131413
/*
14141414
* opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1415-
* owner 4 = 32
1415+
* owner 28
14161416
*/
14171417
encode_nfs4_seqid(xdr, arg->seqid);
14181418
encode_share_access(xdr, arg->share_access);
@@ -5077,7 +5077,7 @@ static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
50775077
/*
50785078
* We create the owner, so we know a proper owner.id length is 4.
50795079
*/
5080-
static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
5080+
static int decode_lock_denied(struct xdr_stream *xdr, struct file_lock *fl)
50815081
{
50825082
uint64_t offset, length, clientid;
50835083
__be32 *p;

0 commit comments

Comments
 (0)