Commit a9004abc34239705840eaf6fe3d6cc9cb7656cba
1 parent
28dde241cc
Exists in
master
and in
6 other branches
nfsd4: cleanup and consolidate seqid_mutating_err
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Showing 3 changed files with 17 additions and 37 deletions Side-by-side Diff
fs/nfs/nfs4_fs.h
... | ... | @@ -13,30 +13,6 @@ |
13 | 13 | |
14 | 14 | struct idmap; |
15 | 15 | |
16 | -/* | |
17 | - * In a seqid-mutating op, this macro controls which error return | |
18 | - * values trigger incrementation of the seqid. | |
19 | - * | |
20 | - * from rfc 3010: | |
21 | - * The client MUST monotonically increment the sequence number for the | |
22 | - * CLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE | |
23 | - * operations. This is true even in the event that the previous | |
24 | - * operation that used the sequence number received an error. The only | |
25 | - * exception to this rule is if the previous operation received one of | |
26 | - * the following errors: NFSERR_STALE_CLIENTID, NFSERR_STALE_STATEID, | |
27 | - * NFSERR_BAD_STATEID, NFSERR_BAD_SEQID, NFSERR_BADXDR, | |
28 | - * NFSERR_RESOURCE, NFSERR_NOFILEHANDLE. | |
29 | - * | |
30 | - */ | |
31 | -#define seqid_mutating_err(err) \ | |
32 | -(((err) != NFSERR_STALE_CLIENTID) && \ | |
33 | - ((err) != NFSERR_STALE_STATEID) && \ | |
34 | - ((err) != NFSERR_BAD_STATEID) && \ | |
35 | - ((err) != NFSERR_BAD_SEQID) && \ | |
36 | - ((err) != NFSERR_BAD_XDR) && \ | |
37 | - ((err) != NFSERR_RESOURCE) && \ | |
38 | - ((err) != NFSERR_NOFILEHANDLE)) | |
39 | - | |
40 | 16 | enum nfs4_client_state { |
41 | 17 | NFS4CLNT_MANAGER_RUNNING = 0, |
42 | 18 | NFS4CLNT_CHECK_LEASE, |
fs/nfsd/nfs4xdr.c
... | ... | @@ -1623,18 +1623,6 @@ |
1623 | 1623 | \ |
1624 | 1624 | save = resp->p; |
1625 | 1625 | |
1626 | -static bool seqid_mutating_err(__be32 err) | |
1627 | -{ | |
1628 | - /* rfc 3530 section 8.1.5: */ | |
1629 | - return err != nfserr_stale_clientid && | |
1630 | - err != nfserr_stale_stateid && | |
1631 | - err != nfserr_bad_stateid && | |
1632 | - err != nfserr_bad_seqid && | |
1633 | - err != nfserr_bad_xdr && | |
1634 | - err != nfserr_resource && | |
1635 | - err != nfserr_nofilehandle; | |
1636 | -} | |
1637 | - | |
1638 | 1626 | /* |
1639 | 1627 | * Routine for encoding the result of a "seqid-mutating" NFSv4 operation. This |
1640 | 1628 | * is where sequence id's are incremented, and the replay cache is filled. |
... | ... | @@ -1643,7 +1631,7 @@ |
1643 | 1631 | */ |
1644 | 1632 | |
1645 | 1633 | #define ENCODE_SEQID_OP_TAIL(stateowner) do { \ |
1646 | - if (seqid_mutating_err(nfserr) && stateowner) { \ | |
1634 | + if (seqid_mutating_err(ntohl(nfserr)) && stateowner) { \ | |
1647 | 1635 | stateowner->so_seqid++; \ |
1648 | 1636 | stateowner->so_replay.rp_status = nfserr; \ |
1649 | 1637 | stateowner->so_replay.rp_buflen = \ |
include/linux/nfs4.h
... | ... | @@ -373,6 +373,22 @@ |
373 | 373 | NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */ |
374 | 374 | }; |
375 | 375 | |
376 | +static inline bool seqid_mutating_err(u32 err) | |
377 | +{ | |
378 | + /* rfc 3530 section 8.1.5: */ | |
379 | + switch (err) { | |
380 | + case NFS4ERR_STALE_CLIENTID: | |
381 | + case NFS4ERR_STALE_STATEID: | |
382 | + case NFS4ERR_BAD_STATEID: | |
383 | + case NFS4ERR_BAD_SEQID: | |
384 | + case NFS4ERR_BADXDR: | |
385 | + case NFS4ERR_RESOURCE: | |
386 | + case NFS4ERR_NOFILEHANDLE: | |
387 | + return false; | |
388 | + }; | |
389 | + return true; | |
390 | +} | |
391 | + | |
376 | 392 | /* |
377 | 393 | * Note: NF4BAD is not actually part of the protocol; it is just used |
378 | 394 | * internally by nfsd. |