Re: [PATCH 2/3] shmem: Introduce /sys/fs/tmpfs support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[+fsdevel please CC on next versions]

On Wed, Mar 23, 2022 at 12:27 AM Gabriel Krisman Bertazi
<krisman@xxxxxxxxxxxxx> wrote:
>
> In order to expose tmpfs statistics on sysfs, add the boilerplate code
> to create the /sys/fs/tmpfs structure.  Other filesystems usually do
> /sys/fs/<fs>/<disk>, but since this is a nodev filesystem, I'm proposing
> to use fsid as <disk>.

I am proposing st_dev minor.

>
> This takes care of not exposing SB_NOUSER mounts.  I don't think we have
> a usecase for showing them and, since they don't appear elsewhere, they
> might be confusing to users.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxx>
> ---
>  include/linux/shmem_fs.h |  4 +++
>  mm/shmem.c               | 73 +++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 76 insertions(+), 1 deletion(-)
>
[...]

> +static int shmem_register_sysfs(struct super_block *sb)
> +{
> +       int err;
> +       struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
> +       __kernel_fsid_t fsid = uuid_to_fsid(sb->s_uuid.b);
> +
> +       init_completion(&sbinfo->s_kobj_unregister);
> +       err = kobject_init_and_add(&sbinfo->s_kobj, &tmpfs_sb_ktype, shmem_root,
> +                                  "%x%x", fsid.val[0], fsid.val[1]);

uuid (and fsid) try to be unique across tmpfs instances from different times.
You don't need that.
I think you'd rather use s_dev (minor number) which is unique among all tmpfs
instances at a given time and also much easier from user scripts to read from
(e.g. stat or /proc/self/mountinfo).

That's btw the same number is used as an entry in /sys/fs/fuse/connections
(fusectl pseudo fs).

Thanks,
Amir.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux