* [PATCH] xfs: xfs_nfs_get_inode support zero generation @ 2023-05-11 10:17 renlei1 2023-05-11 23:22 ` Darrick J. Wong 0 siblings, 1 reply; 5+ messages in thread From: renlei1 @ 2023-05-11 10:17 UTC (permalink / raw) To: djwong; +Cc: linux-xfs, linux-kernel, Ren Lei From: Ren Lei <renlei1@chinatelecom.cn> If generation is zero, bypass the verification of generation number to avoid stale file error. (Be consistent with other fs, such as ext4, fat, jfs, etc.) Signed-off-by: Ren Lei<renlei1@chinatelecom.cn> --- fs/xfs/xfs_export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index 1064c2342876..cbee32c5ad37 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c @@ -146,7 +146,7 @@ xfs_nfs_get_inode( return ERR_PTR(error); } - if (VFS_I(ip)->i_generation != generation) { + if (generation && VFS_I(ip)->i_generation != generation) { xfs_irele(ip); return ERR_PTR(-ESTALE); } -- 2.27.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: xfs_nfs_get_inode support zero generation 2023-05-11 10:17 [PATCH] xfs: xfs_nfs_get_inode support zero generation renlei1 @ 2023-05-11 23:22 ` Darrick J. Wong 2023-05-12 2:00 ` Dave Chinner 0 siblings, 1 reply; 5+ messages in thread From: Darrick J. Wong @ 2023-05-11 23:22 UTC (permalink / raw) To: renlei1; +Cc: linux-xfs, linux-kernel On Thu, May 11, 2023 at 06:17:21PM +0800, renlei1@chinatelecom.cn wrote: > From: Ren Lei <renlei1@chinatelecom.cn> > > If generation is zero, bypass the verification of generation number > to avoid stale file error. (Be consistent with other fs, such as > ext4, fat, jfs, etc.) What code is affected by the gen==0 handles being rejected? Is there a user program or test case where this is required? --D > Signed-off-by: Ren Lei<renlei1@chinatelecom.cn> > --- > fs/xfs/xfs_export.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c > index 1064c2342876..cbee32c5ad37 100644 > --- a/fs/xfs/xfs_export.c > +++ b/fs/xfs/xfs_export.c > @@ -146,7 +146,7 @@ xfs_nfs_get_inode( > return ERR_PTR(error); > } > > - if (VFS_I(ip)->i_generation != generation) { > + if (generation && VFS_I(ip)->i_generation != generation) { > xfs_irele(ip); > return ERR_PTR(-ESTALE); > } > -- > 2.27.0 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: xfs_nfs_get_inode support zero generation 2023-05-11 23:22 ` Darrick J. Wong @ 2023-05-12 2:00 ` Dave Chinner [not found] ` <2023051210532845432129@chinatelecom.cn> 0 siblings, 1 reply; 5+ messages in thread From: Dave Chinner @ 2023-05-12 2:00 UTC (permalink / raw) To: Darrick J. Wong; +Cc: renlei1, linux-xfs, linux-kernel On Thu, May 11, 2023 at 04:22:06PM -0700, Darrick J. Wong wrote: > On Thu, May 11, 2023 at 06:17:21PM +0800, renlei1@chinatelecom.cn wrote: > > From: Ren Lei <renlei1@chinatelecom.cn> > > > > If generation is zero, bypass the verification of generation number > > to avoid stale file error. (Be consistent with other fs, such as > > ext4, fat, jfs, etc.) > > What code is affected by the gen==0 handles being rejected? Is there a > user program or test case where this is required? A generation number of 0 is perfectly valid in XFS. We've been creating them in XFS filesystems since 1993 and never had a problem with filehandle verification. Indeed, every root inode in every XFS filesystem ever made will have a generation number of 0. Yup, a random XFS filesystem recently made from a current xfsprogs: # xfs_db /dev/vdc xfs_db> sb 0 xfs_db> a rootino xfs_db> p core.gen core.gen = 0 xfs_db> -Dave. -- Dave Chinner david@fromorbit.com ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <2023051210532845432129@chinatelecom.cn>]
* Re: Re: [PATCH] xfs: xfs_nfs_get_inode support zero generation [not found] ` <2023051210532845432129@chinatelecom.cn> @ 2023-05-12 3:31 ` Darrick J. Wong 2023-05-12 6:02 ` Dave Chinner 1 sibling, 0 replies; 5+ messages in thread From: Darrick J. Wong @ 2023-05-12 3:31 UTC (permalink / raw) To: renlei1@chinatelecom.cn; +Cc: Dave Chinner, linux-xfs, linux-kernel On Fri, May 12, 2023 at 10:53:29AM +0800, renlei1@chinatelecom.cn wrote: > Yup, gen is 0 for the inodes created by libxfs, such as rootino, rbmino, rsumino. > but those inodes will never be freed, and gen will always zero. > so I think bypass the verification if gen==0 is still valid. I disagree. Handles have long encoded inode and generation to prevent users from unintentionally modifying a file when the inode number is recycled as a result of an unlink/create cycle. --D > Regards, > Lei > > From: Dave Chinner > Date: 2023-05-12 10:00 > To: Darrick J. Wong > CC: renlei1; linux-xfs; linux-kernel > Subject: Re: [PATCH] xfs: xfs_nfs_get_inode support zero generation > On Thu, May 11, 2023 at 04:22:06PM -0700, Darrick J. Wong wrote: > > On Thu, May 11, 2023 at 06:17:21PM +0800, renlei1@chinatelecom.cn wrote: > > > From: Ren Lei <renlei1@chinatelecom.cn> > > > > > > If generation is zero, bypass the verification of generation number > > > to avoid stale file error. (Be consistent with other fs, such as > > > ext4, fat, jfs, etc.) > > > > What code is affected by the gen==0 handles being rejected? Is there a > > user program or test case where this is required? > > A generation number of 0 is perfectly valid in XFS. We've been > creating them in XFS filesystems since 1993 and never had a problem > with filehandle verification. Indeed, every root inode in every XFS > filesystem ever made will have a generation number of 0. > > Yup, a random XFS filesystem recently made from a current xfsprogs: > > # xfs_db /dev/vdc > xfs_db> sb 0 > xfs_db> a rootino > xfs_db> p core.gen > core.gen = 0 > xfs_db> > > -Dave. > -- > Dave Chinner > david@fromorbit.com > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH] xfs: xfs_nfs_get_inode support zero generation [not found] ` <2023051210532845432129@chinatelecom.cn> 2023-05-12 3:31 ` Darrick J. Wong @ 2023-05-12 6:02 ` Dave Chinner 1 sibling, 0 replies; 5+ messages in thread From: Dave Chinner @ 2023-05-12 6:02 UTC (permalink / raw) To: renlei1@chinatelecom.cn; +Cc: Darrick J. Wong, linux-xfs, linux-kernel On Fri, May 12, 2023 at 10:53:29AM +0800, renlei1@chinatelecom.cn wrote: > Yup, gen is 0 for the inodes created by libxfs, such as rootino, rbmino, rsumino. > but those inodes will never be freed, and gen will always zero. Yes, but why does that even matter for file handle verification? > so I think bypass the verification if gen==0 is still valid. Did you think about what happens when an inode->gen overflows from 0xffffffff to 0 as part of a normal unlink/create cycle? -Dave. -- Dave Chinner david@fromorbit.com ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-12 6:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-11 10:17 [PATCH] xfs: xfs_nfs_get_inode support zero generation renlei1
2023-05-11 23:22 ` Darrick J. Wong
2023-05-12 2:00 ` Dave Chinner
[not found] ` <2023051210532845432129@chinatelecom.cn>
2023-05-12 3:31 ` Darrick J. Wong
2023-05-12 6:02 ` Dave Chinner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox