public inbox for gfs2@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer
@ 2025-09-26  2:56 Youling Tang
  2025-09-26  4:48 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Youling Tang @ 2025-09-26  2:56 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: gfs2, linux-kernel, youling.tang, Youling Tang

From: Youling Tang <tangyouling@kylinos.cn>

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.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
 fs/gfs2/gfs2.h       |  1 +
 fs/gfs2/inode.c      | 10 ----------
 fs/gfs2/ops_fstype.c |  1 +
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/gfs2/gfs2.h b/fs/gfs2/gfs2.h
index ed78e5f20f41..06a7f731d34c 100644
--- a/fs/gfs2/gfs2.h
+++ b/fs/gfs2/gfs2.h
@@ -18,6 +18,7 @@ enum {
 };
 
 #define GFS2_FAST_NAME_SIZE 8
+#define GFS2_LINK_MAX	0xffffffff
 
 #endif /* __GFS2_DOT_H__ */
 
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 8760e7e20c9d..f2a6420e1fa8 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -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;
-			}
 		}
 	}
 
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index efe99b732551..823f3d987d6c 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -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. */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-26  5:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26  2:56 [PATCH] gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer Youling Tang
2025-09-26  4:48 ` Al Viro
2025-09-26  5:37   ` Youling Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox