mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Youling Tang <youling.tang@linux.dev>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org,
	youling.tang@linux.dev, Youling Tang <tangyouling@kylinos.cn>
Subject: [PATCH] gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer
Date: Fri, 26 Sep 2025 10:56:04 +0800	[thread overview]
Message-ID: <20250926025604.500713-1-youling.tang@linux.dev> (raw)

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


             reply	other threads:[~2025-09-26  2:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26  2:56 Youling Tang [this message]
2025-09-26  4:48 ` Al Viro
2025-09-26  5:37   ` Youling Tang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250926025604.500713-1-youling.tang@linux.dev \
    --to=youling.tang@linux.dev \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tangyouling@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®