gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer
PATCH 1/1 gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer
From: Youling Tang <[email protected]>
vfs_{link, rename, mkdir} will check i_nlink. When sb->s_max_links is set, set sb->s_max_links in gfs2 to simplify the code.
--- fs/gfs2/gfs2.h | 1 + fs/gfs2/inode.c | 10 ---------- fs/gfs2/ops_fstype.c | 1 + 3 files changed, 2 insertions(+), 10 deletions(-)
fs/gfs2/gfs2.h +1 -0
@@ -18,6 +18,7 @@ enum { };#define GFS2_FAST_NAME_SIZE 8 +#define GFS2_LINK_MAX 0xffffffff#endif /* __GFS2_DOT_H__ */
fs/gfs2/inode.c +0 -10
@@ -373,8 +373,6 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,if (dip->i_entries == (u32)-1 )return -EFBIG ; -if (S_ISDIR (mode) && dip->i_inode.i_nlink == (u32)-1 ) -return -EMLINK ;return 0 ; }
@@ -1079,9 +1077,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, error = -EPERM ;if (IS_IMMUTABLE (inode) ||IS_APPEND (inode)) goto out_gunlock; - error = -EMLINK ; -if (ip->i_inode.i_nlink == (u32)-1 ) - goto out_gunlock; error =gfs2_diradd_alloc_required (dir, &dentry->d_name, &da);if (error <0 )
@@ -1623,11 +1618,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, error = -EFBIG ; goto out_gunlock; } -if (S_ISDIR (ip->i_inode.i_mode) && - ndip->i_inode.i_nlink == (u32)-1 ) { - error = -EMLINK ; - goto out_gunlock; - } } }
fs/gfs2/ops_fstype.c +1 -0
@@ -1152,6 +1152,7 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)sb_dqopt (sb)->flags |=DQUOT_QUOTA_SYS_FILE ; sb->s_time_gran =1 ; sb->s_maxbytes =MAX_LFS_FILESIZE ; + sb->s_max_links =GFS2_LINK_MAX ;/* Set up the buffer cache and fill in some fake block size values to allow us to read-in the on-disk superblock. */
Signature · 1 line
2.43.0
Quoted 4 lines · Youling Tang
From: Youling Tang <[email protected]>
vfs_{link, rename, mkdir} will check
i_nlink. Whensb->s_max_linksis set, setsb->s_max_linksin gfs2 to simplify the code.
For gfs2 you are going to run into a problem - link count is not stable until you take gfs2 locks; checks in vfs_link() et.al. will be inevitably racy for cluster filesystems.
Quoted 8 lines · Al Viro
Quoted 4 lines · Youling Tang
From: Youling Tang <[email protected]>
vfs_{link, rename, mkdir} will check
i_nlink. Whensb->s_max_linksis set, setsb->s_max_linksin gfs2 to simplify the code.For gfs2 you are going to run into a problem - link count is not stable until you take gfs2 locks; checks in
vfs_link()et.al. will be inevitably racy for cluster filesystems.
Thank you for pointing out this important issue. Let's discard this patch.
Thanks,
Youling.