Skip to content

Commit fcd8843

Browse files
trondmypdamschuma-ntap
authored andcommitted
NFSv4: Replace closed stateids with the "invalid special stateid"
When decoding a CLOSE, replace the stateid returned by the server with the "invalid special stateid" described in RFC5661, Section 8.2.3. In nfs_set_open_stateid_locked, ignore stateids from closed state. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent e1fff5d commit fcd8843

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

fs/nfs/nfs4_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ extern int nfs4_sequence_done(struct rpc_task *task,
481481
extern void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp);
482482

483483
extern const nfs4_stateid zero_stateid;
484+
extern const nfs4_stateid invalid_stateid;
484485

485486
/* nfs4super.c */
486487
struct nfs_mount_info;

fs/nfs/nfs4state.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ const nfs4_stateid zero_stateid = {
6969
{ .data = { 0 } },
7070
.type = NFS4_SPECIAL_STATEID_TYPE,
7171
};
72+
const nfs4_stateid invalid_stateid = {
73+
{
74+
.seqid = cpu_to_be32(0xffffffffU),
75+
.other = { 0 },
76+
},
77+
.type = NFS4_INVALID_STATEID_TYPE,
78+
};
79+
7280
static DEFINE_MUTEX(nfs_clid_init_mutex);
7381

7482
int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)

fs/nfs/nfs4xdr.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4385,6 +4385,14 @@ static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *state
43854385
return decode_stateid(xdr, stateid);
43864386
}
43874387

4388+
static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
4389+
{
4390+
nfs4_stateid dummy;
4391+
4392+
nfs4_stateid_copy(stateid, &invalid_stateid);
4393+
return decode_stateid(xdr, &dummy);
4394+
}
4395+
43884396
static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
43894397
{
43904398
int status;
@@ -4393,7 +4401,7 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
43934401
if (status != -EIO)
43944402
nfs_increment_open_seqid(status, res->seqid);
43954403
if (!status)
4396-
status = decode_open_stateid(xdr, &res->stateid);
4404+
status = decode_invalid_stateid(xdr, &res->stateid);
43974405
return status;
43984406
}
43994407

@@ -6108,6 +6116,8 @@ static int decode_layoutreturn(struct xdr_stream *xdr,
61086116
res->lrs_present = be32_to_cpup(p);
61096117
if (res->lrs_present)
61106118
status = decode_layout_stateid(xdr, &res->stateid);
6119+
else
6120+
nfs4_stateid_copy(&res->stateid, &invalid_stateid);
61116121
return status;
61126122
out_overflow:
61136123
print_overflow_msg(__func__, xdr);

0 commit comments

Comments
 (0)