[PATCH RFC v3 01/12] fs/configfs: rework configfs_is_root()
Breno Leitao
leitao at debian.org
Tue Jun 23 05:50:46 PDT 2026
hello hannes,
On Tue, Jun 23, 2026 at 11:15:46AM +0200, Hannes Reinecke wrote:
> In preparation for making configfs namespace-aware rework
> configfs_is_root() to not rely on static structures but
> rather use the information in the structures themselves.>
Thanks for the cleanup. The approach looks fine: CONFIGFS_ROOT is
only ever set on the single static configfs_root dirent.
Nit: "namespace-aware rework configfs_is_root()" reads as if a comma is
missing -- "... namespace-aware, rework configfs_is_root() ...".
> Signed-off-by: Hannes Reinecke <hare at kernel.org>
> ---
> fs/configfs/configfs_internal.h | 2 +-
> fs/configfs/mount.c | 9 +++++++--
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
> index acdeea8e2d69ac9d621e1a42b039719811c31757..6261e1f3ec201a58a5d46b08dfbced8c2a44d82b 100644
> --- a/fs/configfs/configfs_internal.h
> +++ b/fs/configfs/configfs_internal.h
> @@ -63,7 +63,7 @@ extern spinlock_t configfs_dirent_lock;
>
> extern struct kmem_cache *configfs_dir_cachep;
>
> -extern int configfs_is_root(struct config_item *item);
> +extern bool configfs_is_root(struct config_item *item);
>
> extern struct inode * configfs_new_inode(umode_t mode, struct configfs_dirent *, struct super_block *);
> extern struct inode *configfs_create(struct dentry *, umode_t mode);
> diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
> index 4929f343118946eaa55a539db4192e9c6621a8dc..88da7b428e52f2f4ab139ad3907101f685d617b1 100644
> --- a/fs/configfs/mount.c
> +++ b/fs/configfs/mount.c
> @@ -47,9 +47,14 @@ static struct config_group configfs_root_group = {
> },
> };
>
> -int configfs_is_root(struct config_item *item)
> +bool configfs_is_root(struct config_item *item)
> {
> - return item == &configfs_root_group.cg_item;
> + struct configfs_dirent *sd;
> +
> + if (!item->ci_dentry)
> + return false;
> + sd = item->ci_dentry->d_fsdata;
> + return !!(sd->s_type & CONFIGFS_ROOT);
The old helper was a pure pointer comparison and never touched item, so it
tolerated a NULL or not-yet-attached item. The new one dereferences
it (item). I suppose that item is never being called as NULL?!
Thanks
--breno
More information about the Linux-nvme
mailing list