Commit b4a2cf76 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Fix a regression against the FreeBSD server

Technically, the Linux client is allowed by the NFSv4 spec to send
3 word bitmaps as part of an OPEN request. However, this causes the
current FreeBSD server to return NFS4ERR_ATTRNOTSUPP errors.

Fix the regression by making the Linux client use a 2 word bitmap unless
doing NFSv4.2 with labeled NFS.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 1540c5d3
...@@ -999,6 +999,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, ...@@ -999,6 +999,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
__be32 *p; __be32 *p;
__be32 *q; __be32 *q;
int len; int len;
uint32_t bmval_len = 2;
uint32_t bmval0 = 0; uint32_t bmval0 = 0;
uint32_t bmval1 = 0; uint32_t bmval1 = 0;
uint32_t bmval2 = 0; uint32_t bmval2 = 0;
...@@ -1010,7 +1011,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, ...@@ -1010,7 +1011,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
* = 40 bytes, plus any contribution from variable-length fields * = 40 bytes, plus any contribution from variable-length fields
* such as owner/group. * such as owner/group.
*/ */
len = 20; len = 8;
/* Sigh */ /* Sigh */
if (iap->ia_valid & ATTR_SIZE) if (iap->ia_valid & ATTR_SIZE)
...@@ -1040,8 +1041,6 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, ...@@ -1040,8 +1041,6 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
} }
len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
} }
if (label)
len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
if (iap->ia_valid & ATTR_ATIME_SET) if (iap->ia_valid & ATTR_ATIME_SET)
len += 16; len += 16;
else if (iap->ia_valid & ATTR_ATIME) else if (iap->ia_valid & ATTR_ATIME)
...@@ -1050,15 +1049,22 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, ...@@ -1050,15 +1049,22 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
len += 16; len += 16;
else if (iap->ia_valid & ATTR_MTIME) else if (iap->ia_valid & ATTR_MTIME)
len += 4; len += 4;
if (label) {
len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
bmval_len = 3;
}
len += bmval_len << 2;
p = reserve_space(xdr, len); p = reserve_space(xdr, len);
/* /*
* We write the bitmap length now, but leave the bitmap and the attribute * We write the bitmap length now, but leave the bitmap and the attribute
* buffer length to be backfilled at the end of this routine. * buffer length to be backfilled at the end of this routine.
*/ */
*p++ = cpu_to_be32(3); *p++ = cpu_to_be32(bmval_len);
q = p; q = p;
p += 4; /* Skip bitmap entries + attrlen */
p += bmval_len + 1;
if (iap->ia_valid & ATTR_SIZE) { if (iap->ia_valid & ATTR_SIZE) {
bmval0 |= FATTR4_WORD0_SIZE; bmval0 |= FATTR4_WORD0_SIZE;
...@@ -1112,10 +1118,11 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, ...@@ -1112,10 +1118,11 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
len, ((char *)p - (char *)q) + 4); len, ((char *)p - (char *)q) + 4);
BUG(); BUG();
} }
len = (char *)p - (char *)q - 16; len = (char *)p - (char *)q - (bmval_len << 2);
*q++ = htonl(bmval0); *q++ = htonl(bmval0);
*q++ = htonl(bmval1); *q++ = htonl(bmval1);
*q++ = htonl(bmval2); if (bmval_len == 3)
*q++ = htonl(bmval2);
*q = htonl(len); *q = htonl(len);
/* out: */ /* out: */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment