Re: [RFC PATCH] fs: obtain the inode generation number from vfs directly

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

 



On Tue, Aug 27, 2024 at 10:32:38AM +0800, Hongbo Li wrote:
> 
> 
> On 2024/8/27 10:13, Darrick J. Wong wrote:
> > On Tue, Aug 27, 2024 at 01:41:08AM +0000, Hongbo Li wrote:
> > > Many mainstream file systems already support the GETVERSION ioctl,
> > > and their implementations are completely the same, essentially
> > > just obtain the value of i_generation. We think this ioctl can be
> > > implemented at the VFS layer, so the file systems do not need to
> > > implement it individually.
> > 
> > What if a filesystem never touches i_generation?  Is it ok to advertise
> > a generation number of zero when that's really meaningless?  Or should
> > we gate the generic ioctl on (say) whether or not the fs implements file
> > handles and/or supports nfs?
> 
> This ioctl mainly returns the i_generation, and whether it has meaning is up
> to the specific file system. Some tools will invoke IOC_GETVERSION, such as
> `lsattr -v`(but if it's lattr, it won't), but users may not necessarily
> actually use this value.

That's not how that works.  If the kernel starts exporting a datum,
people will start using it, and then the expectation that it will
*continue* to work becomes ingrained in the userspace ABI forever.
Be careful about establishing new behaviors for vfat.

--D

> Thanks,
> Hongbo
> 
> > 
> > --D
> > 
> > > Signed-off-by: Hongbo Li <lihongbo22@xxxxxxxxxx>
> > > ---
> > >   fs/ioctl.c | 6 ++++++
> > >   1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/fs/ioctl.c b/fs/ioctl.c
> > > index 64776891120c..dff887ec52c4 100644
> > > --- a/fs/ioctl.c
> > > +++ b/fs/ioctl.c
> > > @@ -878,6 +878,9 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,
> > >   	case FS_IOC_GETFSUUID:
> > >   		return ioctl_getfsuuid(filp, argp);
> > > +	case FS_IOC_GETVERSION:
> > > +		return put_user(inode->i_generation, (int __user *)argp);
> > > +
> > >   	case FS_IOC_GETFSSYSFSPATH:
> > >   		return ioctl_get_fs_sysfs_path(filp, argp);
> > > @@ -992,6 +995,9 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
> > >   		cmd = (cmd == FS_IOC32_GETFLAGS) ?
> > >   			FS_IOC_GETFLAGS : FS_IOC_SETFLAGS;
> > >   		fallthrough;
> > > +	case FS_IOC32_GETVERSION:
> > > +		cmd = FS_IOC_GETVERSION;
> > > +		fallthrough;
> > >   	/*
> > >   	 * everything else in do_vfs_ioctl() takes either a compatible
> > >   	 * pointer argument or no argument -- call it with a modified
> > > -- 
> > > 2.34.1
> > > 
> > > 
> > 
> 




[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