> On Mar 13, 2023, at 10:50 PM, Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > On Tue, Mar 14, 2023 at 6:27 AM Catherine Hoang > <catherine.hoang@xxxxxxxxxx> wrote: >> >> Add a new ioctl to set the uuid of a mounted filesystem. >> >> Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx> >> --- >> fs/xfs/libxfs/xfs_fs.h | 1 + >> fs/xfs/xfs_ioctl.c | 107 +++++++++++++++++++++++++++++++++++++++++ >> fs/xfs/xfs_log.c | 19 ++++++++ >> fs/xfs/xfs_log.h | 2 + >> 4 files changed, 129 insertions(+) >> >> diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h >> index 1cfd5bc6520a..a350966cce99 100644 >> --- a/fs/xfs/libxfs/xfs_fs.h >> +++ b/fs/xfs/libxfs/xfs_fs.h >> @@ -831,6 +831,7 @@ struct xfs_scrub_metadata { >> #define XFS_IOC_FSGEOMETRY _IOR ('X', 126, struct xfs_fsop_geom) >> #define XFS_IOC_BULKSTAT _IOR ('X', 127, struct xfs_bulkstat_req) >> #define XFS_IOC_INUMBERS _IOR ('X', 128, struct xfs_inumbers_req) >> +#define XFS_IOC_SETFSUUID _IOR ('X', 129, uuid_t) > > Should be _IOW. Ok, will fix that. > > Would you consider defining that as FS_IOC_SETFSUUID in fs.h, > so that other fs could implement it later on, instead of hoisting it later? > > It would be easy to add support for FS_IOC_SETFSUUID to ext4 > by generalizing ext4_ioctl_setuuid(). > > Alternatively, we could hoist EXT4_IOC_SETFSUUID and struct fsuuid > to fs.h and use that ioctl also for xfs. I actually did try to hoist the ext4 ioctls previously, but we weren’t able to come to a consensus on the implementation. https://lore.kernel.org/linux-xfs/20221118211408.72796-2-catherine.hoang@xxxxxxxxxx/ I would prefer to keep this defined as an xfs specific ioctl to avoid all of the fsdevel bikeshedding. > > Using an extensible struct with flags for that ioctl may turn out to be useful, > for example, to verify that the new uuid is unique, despite the fact > that xfs was > mounted with -onouuid (useful IMO) or to explicitly request a restore of old > uuid that would fail if new_uuid != meta uuid. I think using a struct is probably a good idea, I can add that in the next version. > > Thanks, > Amir.