diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2018-03-20 17:03:12 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2018-04-10 16:06:22 -0400 |
commit | 8b0649462407ec4192cacd0f283627b38f24aa5c (patch) | |
tree | 519e4b8d9f9fd9f153f349d690e02321348e0cdc | |
parent | 8bcbe7d98cffb60efdea40e36171c58dcc2bdd31 (diff) |
NFSv4: Clean up CB_GETATTR encoding
Replace the open coded bitmap implementation with a generic one.
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r-- | fs/nfs/callback_xdr.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 123c069429a7..a813979b5be0 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
@@ -535,35 +535,10 @@ static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char | |||
535 | return 0; | 535 | return 0; |
536 | } | 536 | } |
537 | 537 | ||
538 | #define CB_SUPPORTED_ATTR0 (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) | 538 | static __be32 encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, size_t sz) |
539 | #define CB_SUPPORTED_ATTR1 (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) | ||
540 | static __be32 encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, __be32 **savep) | ||
541 | { | 539 | { |
542 | __be32 bm[2]; | 540 | if (xdr_stream_encode_uint32_array(xdr, bitmap, sz) < 0) |
543 | __be32 *p; | 541 | return cpu_to_be32(NFS4ERR_RESOURCE); |
544 | |||
545 | bm[0] = htonl(bitmap[0] & CB_SUPPORTED_ATTR0); | ||
546 | bm[1] = htonl(bitmap[1] & CB_SUPPORTED_ATTR1); | ||
547 | if (bm[1] != 0) { | ||
548 | p = xdr_reserve_space(xdr, 16); | ||
549 | if (unlikely(p == NULL)) | ||
550 | return htonl(NFS4ERR_RESOURCE); | ||
551 | *p++ = htonl(2); | ||
552 | *p++ = bm[0]; | ||
553 | *p++ = bm[1]; | ||
554 | } else if (bm[0] != 0) { | ||
555 | p = xdr_reserve_space(xdr, 12); | ||
556 | if (unlikely(p == NULL)) | ||
557 | return htonl(NFS4ERR_RESOURCE); | ||
558 | *p++ = htonl(1); | ||
559 | *p++ = bm[0]; | ||
560 | } else { | ||
561 | p = xdr_reserve_space(xdr, 8); | ||
562 | if (unlikely(p == NULL)) | ||
563 | return htonl(NFS4ERR_RESOURCE); | ||
564 | *p++ = htonl(0); | ||
565 | } | ||
566 | *savep = p; | ||
567 | return 0; | 542 | return 0; |
568 | } | 543 | } |
569 | 544 | ||
@@ -656,9 +631,13 @@ static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, | |||
656 | 631 | ||
657 | if (unlikely(status != 0)) | 632 | if (unlikely(status != 0)) |
658 | goto out; | 633 | goto out; |
659 | status = encode_attr_bitmap(xdr, res->bitmap, &savep); | 634 | status = encode_attr_bitmap(xdr, res->bitmap, ARRAY_SIZE(res->bitmap)); |
660 | if (unlikely(status != 0)) | 635 | if (unlikely(status != 0)) |
661 | goto out; | 636 | goto out; |
637 | status = cpu_to_be32(NFS4ERR_RESOURCE); | ||
638 | savep = xdr_reserve_space(xdr, sizeof(*savep)); | ||
639 | if (unlikely(!savep)) | ||
640 | goto out; | ||
662 | status = encode_attr_change(xdr, res->bitmap, res->change_attr); | 641 | status = encode_attr_change(xdr, res->bitmap, res->change_attr); |
663 | if (unlikely(status != 0)) | 642 | if (unlikely(status != 0)) |
664 | goto out; | 643 | goto out; |