[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250926025604.500713-1-youling.tang@linux.dev>
Date: Fri, 26 Sep 2025 10:56:04 +0800
From: Youling Tang <youling.tang@...ux.dev>
To: Andreas Gruenbacher <agruenba@...hat.com>
Cc: gfs2@...ts.linux.dev,
linux-kernel@...r.kernel.org,
youling.tang@...ux.dev,
Youling Tang <tangyouling@...inos.cn>
Subject: [PATCH] gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer
From: Youling Tang <tangyouling@...inos.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@...inos.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
Powered by blists - more mailing lists