diff mbox series

[3/3] ext4: Add support for FS_IOC_GETFSSYSFSPATH

Message ID 20240315035308.3563511-4-kent.overstreet@linux.dev (mailing list archive)
State New
Headers show
Series bit more FS_IOC_GETFSUUID, FS_IOC_GETFSSYSFSPATH | expand

Commit Message

Kent Overstreet March 15, 2024, 3:53 a.m. UTC
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.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org
---
 fs/ext4/super.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Theodore Ts'o March 15, 2024, 4:45 p.m. UTC | #1
On Thu, Mar 14, 2024 at 11:53:02PM -0400, Kent Overstreet wrote:
> 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.
> 
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -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
Kent Overstreet March 15, 2024, 4:50 p.m. UTC | #2
On Fri, Mar 15, 2024 at 12:45:50PM -0400, Theodore Ts'o wrote:
> On Thu, Mar 14, 2024 at 11:53:02PM -0400, Kent Overstreet wrote:
> > 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.
> > 
> > --- a/fs/ext4/super.c
> > +++ b/fs/ext4/super.c
> > @@ -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.
Kiselev, Oleg March 18, 2024, 9:51 p.m. UTC | #3
On 3/15/24, 09:51, "Kent Overstreet" <kent.overstreet@linux.dev <mailto:kent.overstreet@linux.dev>> wrote:
> On Fri, Mar 15, 2024 at 12:45:50PM -0400, Theodore Ts'o wrote:
> > On Thu, Mar 14, 2024 at 11:53:02PM -0400, Kent Overstreet wrote:
> > > 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.
> > >
> > > --- a/fs/ext4/super.c
> > > +++ b/fs/ext4/super.c
> > > @@ -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.

Why not use the fs UUID for all cases, single device and multi device?
Dave Chinner March 18, 2024, 10:22 p.m. UTC | #4
On Mon, Mar 18, 2024 at 09:51:04PM +0000, Kiselev, Oleg wrote:
> On 3/15/24, 09:51, "Kent Overstreet" <kent.overstreet@linux.dev <mailto:kent.overstreet@linux.dev>> wrote:
> > On Fri, Mar 15, 2024 at 12:45:50PM -0400, Theodore Ts'o wrote:
> > > On Thu, Mar 14, 2024 at 11:53:02PM -0400, Kent Overstreet wrote:
> > > > 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.
> > > >
> > > > --- a/fs/ext4/super.c
> > > > +++ b/fs/ext4/super.c
> > > > @@ -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.
> 
> 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.
Darrick J. Wong March 20, 2024, 1:49 a.m. UTC | #5
On Tue, Mar 19, 2024 at 09:22:55AM +1100, Dave Chinner wrote:
> On Mon, Mar 18, 2024 at 09:51:04PM +0000, Kiselev, Oleg wrote:
> > On 3/15/24, 09:51, "Kent Overstreet" <kent.overstreet@linux.dev <mailto:kent.overstreet@linux.dev>> wrote:
> > > On Fri, Mar 15, 2024 at 12:45:50PM -0400, Theodore Ts'o wrote:
> > > > On Thu, Mar 14, 2024 at 11:53:02PM -0400, Kent Overstreet wrote:
> > > > > 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.
> > > > >
> > > > > --- a/fs/ext4/super.c
> > > > > +++ b/fs/ext4/super.c
> > > > > @@ -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.
> > 
> > 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.

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

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
>
Andreas Dilger March 22, 2024, 11:03 p.m. UTC | #6
On Mar 14, 2024, at 9:53 PM, Kent Overstreet <kent.overstreet@linux.dev> wrote:
> 
> 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

> 
> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Cc: Andreas Dilger <adilger.kernel@dilger.ca>
> Cc: linux-ext4@vger.kernel.org
> ---
> fs/ext4/super.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index f5e5a44778cf..cb82b23a4d98 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -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);
> --
> 2.43.0
> 


Cheers, Andreas
diff mbox series

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f5e5a44778cf..cb82b23a4d98 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -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);