VFS: improve interface for lookup_one functions
authorNeilBrown <neil@brown.name>
Wed, 19 Mar 2025 03:01:32 +0000 (14:01 +1100)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Apr 2025 07:25:32 +0000 (09:25 +0200)
commit5741909697a31cfb08e45d56b4211959fb791487
treee81a2c045b8e1ff496d2553b982c1f2c6a676268
parent0af2f6be1b4281385b618cb86ad946eded089ac8
VFS: improve interface for lookup_one functions

The family of functions:
  lookup_one()
  lookup_one_unlocked()
  lookup_one_positive_unlocked()

appear designed to be used by external clients of the filesystem rather
than by filesystems acting on themselves as the lookup_one_len family
are used.

They are used by:
   btrfs/ioctl - which is a user-space interface rather than an internal
     activity
   exportfs - i.e. from nfsd or the open_by_handle_at interface
   overlayfs - at access the underlying filesystems
   smb/server - for file service

They should be used by nfsd (more than just the exportfs path) and
cachefs but aren't.

It would help if the documentation didn't claim they should "not be
called by generic code".

Also the path component name is passed as "name" and "len" which are
(confusingly?) separate by the "base".  In some cases the len in simply
"strlen" and so passing a qstr using QSTR() would make the calling
clearer.
Other callers do pass separate name and len which are stored in a
struct.  Sometimes these are already stored in a qstr, other times it
easily could be.

So this patch changes these three functions to receive a 'struct qstr *',
and improves the documentation.

QSTR_LEN() is added to make it easy to pass a QSTR containing a known
len.

[brauner@kernel.org: take a struct qstr pointer]
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://lore.kernel.org/r/20250319031545.2999807-2-neil@brown.name
Signed-off-by: Christian Brauner <brauner@kernel.org>
Documentation/filesystems/porting.rst
fs/btrfs/ioctl.c
fs/exportfs/expfs.c
fs/namei.c
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h
fs/overlayfs/readdir.c
fs/smb/server/smb2pdu.c
include/linux/dcache.h
include/linux/namei.h