diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-04 18:13:57 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-06 10:32:47 -0500 |
commit | 2d2f24add1ff903ff8e0ce61c5c05635cc636985 (patch) | |
tree | 132ddb133179b95931d42a19e79d25f2db33339c | |
parent | f597c53790f662662281b82b7692a22d2a4d4afa (diff) |
NFSv4: Simplify the struct nfs4_stateid
Replace the union with the common struct stateid4 as defined in both
RFC3530 and RFC5661. This makes it easier to access the sequence id,
which will again make implementing support for parallel OPEN calls
easier.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/callback_xdr.c | 4 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 4 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 7 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 4 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 6 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 10 | ||||
-rw-r--r-- | include/linux/nfs4.h | 7 |
7 files changed, 19 insertions, 23 deletions
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 5466829c7e77..fd6cfdb917da 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
@@ -138,10 +138,10 @@ static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | |||
138 | { | 138 | { |
139 | __be32 *p; | 139 | __be32 *p; |
140 | 140 | ||
141 | p = read_buf(xdr, 16); | 141 | p = read_buf(xdr, NFS4_STATEID_SIZE); |
142 | if (unlikely(p == NULL)) | 142 | if (unlikely(p == NULL)) |
143 | return htonl(NFS4ERR_RESOURCE); | 143 | return htonl(NFS4ERR_RESOURCE); |
144 | memcpy(stateid->data, p, 16); | 144 | memcpy(stateid, p, NFS4_STATEID_SIZE); |
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 1c54ef3146d4..16373df96f90 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -351,12 +351,12 @@ extern struct svc_version nfs4_callback_version4; | |||
351 | 351 | ||
352 | static inline void nfs4_stateid_copy(nfs4_stateid *dst, const nfs4_stateid *src) | 352 | static inline void nfs4_stateid_copy(nfs4_stateid *dst, const nfs4_stateid *src) |
353 | { | 353 | { |
354 | memcpy(dst->data, src->data, sizeof(dst->data)); | 354 | memcpy(dst, src, sizeof(*dst)); |
355 | } | 355 | } |
356 | 356 | ||
357 | static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_stateid *src) | 357 | static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_stateid *src) |
358 | { | 358 | { |
359 | return memcmp(dst->data, src->data, sizeof(dst->data)) == 0; | 359 | return memcmp(dst, src, sizeof(*dst)) == 0; |
360 | } | 360 | } |
361 | 361 | ||
362 | #else | 362 | #else |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ce0ad81dd466..e0e35288361c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -6271,13 +6271,12 @@ static int nfs41_free_stateid(struct nfs_server *server, nfs4_stateid *stateid) | |||
6271 | static bool nfs41_match_stateid(const nfs4_stateid *s1, | 6271 | static bool nfs41_match_stateid(const nfs4_stateid *s1, |
6272 | const nfs4_stateid *s2) | 6272 | const nfs4_stateid *s2) |
6273 | { | 6273 | { |
6274 | if (memcmp(s1->stateid.other, s2->stateid.other, | 6274 | if (memcmp(s1->other, s2->other, sizeof(s1->other)) != 0) |
6275 | sizeof(s1->stateid.other)) != 0) | ||
6276 | return false; | 6275 | return false; |
6277 | 6276 | ||
6278 | if (s1->stateid.seqid == s2->stateid.seqid) | 6277 | if (s1->seqid == s2->seqid) |
6279 | return true; | 6278 | return true; |
6280 | if (s1->stateid.seqid == 0 || s2->stateid.seqid == 0) | 6279 | if (s1->seqid == 0 || s2->seqid == 0) |
6281 | return true; | 6280 | return true; |
6282 | 6281 | ||
6283 | return false; | 6282 | return false; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 55c8a81cd6fb..1dad5c53c7fa 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -1240,8 +1240,8 @@ restart: | |||
1240 | * Open state on this file cannot be recovered | 1240 | * Open state on this file cannot be recovered |
1241 | * All we can do is revert to using the zero stateid. | 1241 | * All we can do is revert to using the zero stateid. |
1242 | */ | 1242 | */ |
1243 | memset(state->stateid.data, 0, | 1243 | memset(&state->stateid, 0, |
1244 | sizeof(state->stateid.data)); | 1244 | sizeof(state->stateid)); |
1245 | /* Mark the file as being 'closed' */ | 1245 | /* Mark the file as being 'closed' */ |
1246 | state->state = 0; | 1246 | state->state = 0; |
1247 | break; | 1247 | break; |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 38736dca1b18..76ef98632839 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -930,7 +930,7 @@ static void encode_nops(struct compound_hdr *hdr) | |||
930 | 930 | ||
931 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) | 931 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
932 | { | 932 | { |
933 | encode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); | 933 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
934 | } | 934 | } |
935 | 935 | ||
936 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) | 936 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
@@ -1548,7 +1548,7 @@ static void encode_open_stateid(struct xdr_stream *xdr, const struct nfs_open_co | |||
1548 | if (ctx->state != NULL) { | 1548 | if (ctx->state != NULL) { |
1549 | nfs4_select_rw_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); | 1549 | nfs4_select_rw_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); |
1550 | if (zero_seqid) | 1550 | if (zero_seqid) |
1551 | stateid.stateid.seqid = 0; | 1551 | stateid.seqid = 0; |
1552 | encode_nfs4_stateid(xdr, &stateid); | 1552 | encode_nfs4_stateid(xdr, &stateid); |
1553 | } else | 1553 | } else |
1554 | encode_nfs4_stateid(xdr, &zero_stateid); | 1554 | encode_nfs4_stateid(xdr, &zero_stateid); |
@@ -4237,7 +4237,7 @@ static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) | |||
4237 | 4237 | ||
4238 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | 4238 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
4239 | { | 4239 | { |
4240 | return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); | 4240 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
4241 | } | 4241 | } |
4242 | 4242 | ||
4243 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) | 4243 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index c190e9c2e3d2..6f1c1e3d12bc 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -496,12 +496,12 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | |||
496 | { | 496 | { |
497 | u32 oldseq, newseq; | 497 | u32 oldseq, newseq; |
498 | 498 | ||
499 | oldseq = be32_to_cpu(lo->plh_stateid.stateid.seqid); | 499 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); |
500 | newseq = be32_to_cpu(new->stateid.seqid); | 500 | newseq = be32_to_cpu(new->seqid); |
501 | if ((int)(newseq - oldseq) > 0) { | 501 | if ((int)(newseq - oldseq) > 0) { |
502 | nfs4_stateid_copy(&lo->plh_stateid, new); | 502 | nfs4_stateid_copy(&lo->plh_stateid, new); |
503 | if (update_barrier) { | 503 | if (update_barrier) { |
504 | u32 new_barrier = be32_to_cpu(new->stateid.seqid); | 504 | u32 new_barrier = be32_to_cpu(new->seqid); |
505 | 505 | ||
506 | if ((int)(new_barrier - lo->plh_barrier)) | 506 | if ((int)(new_barrier - lo->plh_barrier)) |
507 | lo->plh_barrier = new_barrier; | 507 | lo->plh_barrier = new_barrier; |
@@ -525,7 +525,7 @@ pnfs_layoutgets_blocked(struct pnfs_layout_hdr *lo, nfs4_stateid *stateid, | |||
525 | int lget) | 525 | int lget) |
526 | { | 526 | { |
527 | if ((stateid) && | 527 | if ((stateid) && |
528 | (int)(lo->plh_barrier - be32_to_cpu(stateid->stateid.seqid)) >= 0) | 528 | (int)(lo->plh_barrier - be32_to_cpu(stateid->seqid)) >= 0) |
529 | return true; | 529 | return true; |
530 | return lo->plh_block_lgets || | 530 | return lo->plh_block_lgets || |
531 | test_bit(NFS_LAYOUT_DESTROYED, &lo->plh_flags) || | 531 | test_bit(NFS_LAYOUT_DESTROYED, &lo->plh_flags) || |
@@ -759,7 +759,7 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier) | |||
759 | } | 759 | } |
760 | if (!found) { | 760 | if (!found) { |
761 | struct pnfs_layout_hdr *lo = nfsi->layout; | 761 | struct pnfs_layout_hdr *lo = nfsi->layout; |
762 | u32 current_seqid = be32_to_cpu(lo->plh_stateid.stateid.seqid); | 762 | u32 current_seqid = be32_to_cpu(lo->plh_stateid.seqid); |
763 | 763 | ||
764 | /* Since close does not return a layout stateid for use as | 764 | /* Since close does not return a layout stateid for use as |
765 | * a barrier, we choose the worst-case barrier. | 765 | * a barrier, we choose the worst-case barrier. |
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 32345c2805c0..834df8bf08b6 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h | |||
@@ -183,15 +183,12 @@ struct nfs4_acl { | |||
183 | 183 | ||
184 | typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier; | 184 | typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier; |
185 | 185 | ||
186 | struct nfs41_stateid { | 186 | struct nfs_stateid4 { |
187 | __be32 seqid; | 187 | __be32 seqid; |
188 | char other[NFS4_STATEID_OTHER_SIZE]; | 188 | char other[NFS4_STATEID_OTHER_SIZE]; |
189 | } __attribute__ ((packed)); | 189 | } __attribute__ ((packed)); |
190 | 190 | ||
191 | typedef union { | 191 | typedef struct nfs_stateid4 nfs4_stateid; |
192 | char data[NFS4_STATEID_SIZE]; | ||
193 | struct nfs41_stateid stateid; | ||
194 | } nfs4_stateid; | ||
195 | 192 | ||
196 | enum nfs_opnum4 { | 193 | enum nfs_opnum4 { |
197 | OP_ACCESS = 3, | 194 | OP_ACCESS = 3, |