Skip to content

Commit b4d4fd6

Browse files
bcodding-rhamschuma-ntap
authored andcommitted
NFSv4: Always ask for type with READDIR
Again we have claimed regressions for walking a directory tree, this time with the "find" utility which always tries to optimize away asking for any attributes until it has a complete list of entries. This behavior makes the readdir plus heuristic do the wrong thing, which causes a storm of GETATTRs to determine each entry's type in order to continue the walk. For v4 add the type attribute to each READDIR request to include it no matter the heuristic. This allows a simple `find` command to proceed quickly through a directory tree. Suggested-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent d76c769 commit b4d4fd6

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

fs/nfs/nfs4xdr.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,8 @@ static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args
16021602
static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
16031603
{
16041604
uint32_t attrs[3] = {
1605-
FATTR4_WORD0_RDATTR_ERROR,
1605+
FATTR4_WORD0_TYPE
1606+
| FATTR4_WORD0_RDATTR_ERROR,
16061607
FATTR4_WORD1_MOUNTED_ON_FILEID,
16071608
};
16081609
uint32_t dircount = readdir->count;
@@ -1612,12 +1613,20 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
16121613
unsigned int i;
16131614

16141615
if (readdir->plus) {
1615-
attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE|
1616-
FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID;
1617-
attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
1618-
FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
1619-
FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
1620-
FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
1616+
attrs[0] |= FATTR4_WORD0_CHANGE
1617+
| FATTR4_WORD0_SIZE
1618+
| FATTR4_WORD0_FSID
1619+
| FATTR4_WORD0_FILEHANDLE
1620+
| FATTR4_WORD0_FILEID;
1621+
attrs[1] |= FATTR4_WORD1_MODE
1622+
| FATTR4_WORD1_NUMLINKS
1623+
| FATTR4_WORD1_OWNER
1624+
| FATTR4_WORD1_OWNER_GROUP
1625+
| FATTR4_WORD1_RAWDEV
1626+
| FATTR4_WORD1_SPACE_USED
1627+
| FATTR4_WORD1_TIME_ACCESS
1628+
| FATTR4_WORD1_TIME_METADATA
1629+
| FATTR4_WORD1_TIME_MODIFY;
16211630
attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
16221631
}
16231632
/* Use mounted_on_fileid only if the server supports it */

0 commit comments

Comments
 (0)