NFSv4: Ask for a full XDR buffer of readdir goodness
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 18 Feb 2022 17:04:06 +0000 (12:04 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 2 Mar 2022 13:43:38 +0000 (08:43 -0500)
Instead of pretending that we know the ratio of directory info vs
readdirplus attribute info, just set the 'dircount' field to the same
value as the 'maxcount' field.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs3xdr.c
fs/nfs/nfs4xdr.c

index 7ab60ad98776fb35a52ff63b9b1b015ae94495ae..d6779ceeb39eda150edba4084a5bee505df727d5 100644 (file)
@@ -1261,6 +1261,8 @@ static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req,
 static void encode_readdirplus3args(struct xdr_stream *xdr,
                                    const struct nfs3_readdirargs *args)
 {
+       uint32_t dircount = args->count;
+       uint32_t maxcount = args->count;
        __be32 *p;
 
        encode_nfs_fh3(xdr, args->fh);
@@ -1273,9 +1275,8 @@ static void encode_readdirplus3args(struct xdr_stream *xdr,
         * readdirplus: need dircount + buffer size.
         * We just make sure we make dircount big enough
         */
-       *p++ = cpu_to_be32(args->count >> 3);
-
-       *p = cpu_to_be32(args->count);
+       *p++ = cpu_to_be32(dircount);
+       *p = cpu_to_be32(maxcount);
 }
 
 static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req,
index 8e70b92df4cc8a946674af1a58c32c0cf634c9e0..b7780b97dc4df8c0afc1a5f11b0ee293c33a153c 100644 (file)
@@ -1605,7 +1605,8 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
                FATTR4_WORD0_RDATTR_ERROR,
                FATTR4_WORD1_MOUNTED_ON_FILEID,
        };
-       uint32_t dircount = readdir->count >> 1;
+       uint32_t dircount = readdir->count;
+       uint32_t maxcount = readdir->count;
        __be32 *p, verf[2];
        uint32_t attrlen = 0;
        unsigned int i;
@@ -1618,7 +1619,6 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
                        FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
                        FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
                attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
-               dircount >>= 1;
        }
        /* Use mounted_on_fileid only if the server supports it */
        if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID))
@@ -1634,7 +1634,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
        encode_nfs4_verifier(xdr, &readdir->verifier);
        p = reserve_space(xdr, 12 + (attrlen << 2));
        *p++ = cpu_to_be32(dircount);
-       *p++ = cpu_to_be32(readdir->count);
+       *p++ = cpu_to_be32(maxcount);
        *p++ = cpu_to_be32(attrlen);
        for (i = 0; i < attrlen; i++)
                *p++ = cpu_to_be32(attrs[i]);