bit more FS_IOC_GETFSUUID, FS_IOC_GETFSSYSFSPATH
Subsystems (2)
cover bit more FS_IOC_GETFSUUID, FS_IOC_GETFSSYSFSPATH
implement FS_IOC_GETFSUUID, FS_IOC_GETFSSYSFSPATH a bit more
also: https://evilpiepirate.org/git/bcachefs.git/commit/?h=bcachefs-sysfs-ioctls
Kent Overstreet (3):
bcachefs: Switch to uuid_to_fsid()
bcachefs: Initialize super_block->s_uuid
ext4: Add support for FS_IOC_GETFSSYSFSPATH
fs/bcachefs/fs.c | 9 ++++----- fs/ext4/super.c | 1 + 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 bcachefs: Switch to uuid_to_fsid()
switch the statfs code from something horrible and open coded to the more standard uuid_to_fsid()
--- fs/bcachefs/fs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/bcachefs/fs.c +1 -5
@@ -1572,7 +1572,6 @@ static int bch2_statfs(struct dentry *dentry, struct kstatfs *buf)* number: */ u64 avail_inodes = ((usage.capacity - usage.used) <<3 ); -u64 fsid; buf->f_type =BCACHEFS_STATFS_MAGIC ; buf->f_bsize = sb->s_blocksize;
@@ -1583,10 +1582,7 @@ static int bch2_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_files = usage.nr_inodes + avail_inodes; buf->f_ffree = avail_inodes; - fsid =le64_to_cpup ((void *) c->sb.user_uuid.b) ^ -le64_to_cpup ((void *) c->sb.user_uuid.b +sizeof (u64)); - buf->f_fsid.val[0 ] = fsid &0xFFFFFFFFUL ; - buf->f_fsid.val[1 ] = (fsid >>32 ) &0xFFFFFFFFUL ; + buf->f_fsid =uuid_to_fsid (c->sb.user_uuid.b); buf->f_namelen =BCH_NAME_MAX ;return 0 ;
Signature · 1 line
2.43.0
PATCH 2/3 bcachefs: Initialize super_block->s_uuid
In reply to Kent OverstreetNeed to fix this oversight for the new UUID/sysfspath ioctls; also, initialize the sysfs path.
--- fs/bcachefs/fs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/bcachefs/fs.c +3 -0
@@ -1881,6 +1881,9 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, c->vfs_sb = sb;strscpy (sb->s_id, c->name,sizeof (sb->s_id)); +super_set_uuid (sb, c->sb.user_uuid.b,16 ); +super_set_sysfs_name_uuid (sb); + ret =super_setup_bdi (sb);if (ret) goto err_put_super;
Signature · 1 line
2.43.0
PATCH 3/3 ext4: Add support for FS_IOC_GETFSSYSFSPATH
In reply to Kent Overstreetthe new sysfs path ioctl lets us get the /sys/fs/ path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.
--- fs/ext4/super.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/super.c +1 -0
@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ mutex_init (&sbi->s_orphan_lock);
Signature · 1 line
2.43.0
Theodore Ts'o
maintainerRe: [PATCH 3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
fs/ext4/super.c static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · line 5349
Quoted 11 lines · Kent Overstreet
the new sysfs path ioctl lets us get the
/sys/fs/path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.fs/ext4/super.c +1
-0@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);
Should we perhaps be hoisting this call up to the VFS layer, so that all file systems would benefit?
- Ted
Re: [PATCH 3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
Quoted 5 lines · Theodore Ts'o
Quoted 4 lines · Kent Overstreet
the new sysfs path ioctl lets us get the
/sys/fs/path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.
Quoted 10 lines
fs/ext4/super.c static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · line 5349
Quoted 7 lines
fs/ext4/super.c +1
-0@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);Should we perhaps be hoisting this call up to the VFS layer, so that all file systems would benefit?
I did as much hoisting as I could. For some filesystems (single device filesystems) the sysfs name is the block device, for the multi device filesystems I've looked at it's the UUID.
Re: [PATCH 3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
Quoted 18 lines · On 3/15/24, 09:51, "Kent Overstreet" <[email protected]…
Quoted 5 lines · Theodore Ts'o
Quoted 4 lines · Kent Overstreet
the new sysfs path ioctl lets us get the
/sys/fs/path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.Quoted 10 lines
fs/ext4/super.c static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · line 5349
Quoted 7 lines
fs/ext4/super.c +1
-0@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);Should we perhaps be hoisting this call up to the VFS layer, so that all file systems would benefit?
Quoted 3 lines
I did as much hoisting as I could. For some filesystems (single device filesystems) the sysfs name is the block device, for the multi device filesystems I've looked at it's the UUID.
Why not use the fs UUID for all cases, single device and multi device?
Signature · 1 line
Oleg Kiselev
Re: [PATCH 3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
Quoted 19 lines · Oleg
Quoted 18 lines · On 3/15/24, 09:51, "Kent Overstreet" <[email protected]…
Quoted 15 lines · Theodore Ts'o
fs/ext4/super.c static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · line 5349
Quoted 11 lines · Kent Overstreet
the new sysfs path ioctl lets us get the
/sys/fs/path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.fs/ext4/super.c +1
-0@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);Should we perhaps be hoisting this call up to the VFS layer, so that all file systems would benefit?
Quoted 5 lines
Quoted 3 lines
I did as much hoisting as I could. For some filesystems (single device filesystems) the sysfs name is the block device, for the multi device filesystems I've looked at it's the UUID.
Why not use the fs UUID for all cases, single device and multi device?
Because the sysfs directory heirachy has already been defined for many filesystems, and technically sysfs represents a KABI that we can't just break for the hell of it.
e.g. changing everything to use uuid will break fstests infrastructure because it assumes that it can derive the sysfs dir location for the filesystem from the *device name* the filesystem is mounted on. btrfs has a special implementation of that derivation that runs the btrfs command to retreive the UUID of the filesysem.
So, yes, while we could technically change it, we break anything in userspace that has introduced a dependency on bdev name as the sysfs fs identifier. We're not going to break userspace like this, especially as it is trivial to avoid.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
Quoted 36 lines · Dave Chinner
Quoted 19 lines · Oleg
Quoted 18 lines · On 3/15/24, 09:51, "Kent Overstreet" <[email protected]…
Quoted 15 lines · Theodore Ts'o
fs/ext4/super.c static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · line 5349
Quoted 11 lines · Kent Overstreet
the new sysfs path ioctl lets us get the
/sys/fs/path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.fs/ext4/super.c +1
-0@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);Should we perhaps be hoisting this call up to the VFS layer, so that all file systems would benefit?
Quoted 5 lines
Quoted 3 lines
I did as much hoisting as I could. For some filesystems (single device filesystems) the sysfs name is the block device, for the multi device filesystems I've looked at it's the UUID.
Why not use the fs UUID for all cases, single device and multi device?
Because the sysfs directory heirachy has already been defined for many filesystems, and technically sysfs represents a KABI that we can't just break for the hell of it.
e.g. changing everything to use uuid will break fstests infrastructure because it assumes that it can derive the sysfs dir location for the filesystem from the *device name* the filesystem is mounted on. btrfs has a special implementation of that derivation that runs the btrfs command to retreive the UUID of the filesysem.
Quoted 4 lines
So, yes, while we could technically change it, we break anything in userspace that has introduced a dependency on bdev name as the sysfs fs identifier. We're not going to break userspace like this, especially as it is trivial to avoid.
Wellll... some day in the far kumbaya future, everyone will call GETSYSFSPATH and they won't have to know or care what each fs does under the covers. So who cares? 8-)
How about using sysfs_create_link for non -o nouuid filesystems so that /sys/fs/xfs/$uuid actually goes somewhere?
<shrug> Don't really care much myself either way.
--D
Quoted 7 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
In reply to Kent OverstreetQuoted 4 lines · Kent Overstreet
the new sysfs path ioctl lets us get the
/sys/fs/path for a given filesystem in a fs agnostic way, potentially nudging us towards standarizing some of our reporting.
I find it ironic that we are adding an ioctl to be able to get the sysfs path, which was originally created to avoid adding ioctls... But, the days of jumping through hoops to find stuff in sysfs for each filesystem arrived long ago, so we may as well make it easier. :-)
Cheers, Andreas
Quoted 22 lines
Signed-off-by Kent Overstreet <[email protected]>Cc "Theodore Ts'o" <[email protected]>Cc Andreas Dilger <[email protected]>---
fs/ext4/super.c| 1 +1 file changed, 1 insertion(+)fs/ext4/super.c +1
-1@@ -5346,6 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid)); +super_set_sysfs_name_bdev (sb);INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ mutex_init (&sbi->s_orphan_lock); --
Quoted 2 lines
2.43.0
Cheers, Andreas
Quoted 8 lines · Kent Overstreet
implement
FS_IOC_GETFSUUID,FS_IOC_GETFSSYSFSPATHa bit morealso: https://evilpiepirate.org/git/bcachefs.git/commit/?h=bcachefs-sysfs-ioctls
Kent Overstreet (3):
ext4: Add support forFS_IOC_GETFSSYSFSPATH[...]
Applied, thanks!
[3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH
commit: fb092d407262eb4278f3d1ca24da54396a038c62
Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>