public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* RFC: return d_type for non-plus READDIR
@ 2021-03-23  1:00 Geert Jansen
  2021-03-23 15:26 ` Chuck Lever III
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Jansen @ 2021-03-23  1:00 UTC (permalink / raw)
  To: linux-nfs

Hi,

recursively listing a directory tree requires that you know which entries are
directories so that you can recurse into them. The getdents() API can provide
this information through the d_type field.

Today, d_type is available if we use READDIRPLUS. A non-plus READDIR requests
only the "rdattr_error" and "mounted_on_fileid" attributes, but not "type", and
consequently sets d_type to DT_UNKNOWN.

Requesting the "type" attribute for regular, non-plus READDIR would allow us to
always return d_type, even for large directories where we switch to a non-plus
READDIR. It would allow the user to recursively list directories of any size
without the need for GETATTRs, and, if the server supports this, without any
stat() or equivalent calls on the server. For some use cases, you could also
mount with '-o nordirplus' to scan an entire file system efficiently.

Since not all file servers may be able to produce the directory entry type
efficiently, this could be implemented as a mount option that defaults off.

Some local file systems offer a similar choice. For example, both ext4 and xfs
have an (in this case mkfs-time) option to store the inode type in the
directory. If this option is set, then getdents() always returns d_type.

Would a patch that adds such a mount option be acceptable?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-25 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-23  1:00 RFC: return d_type for non-plus READDIR Geert Jansen
2021-03-23 15:26 ` Chuck Lever III
2021-03-24  1:47   ` Geert Jansen
2021-03-24 13:50     ` Chuck Lever III
2021-03-25 17:26       ` Geert Jansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox