From nobody Thu Oct 2 00:49:25 2025 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD8F68287E for ; Fri, 26 Sep 2025 02:57:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758855454; cv=none; b=rnzqDZuvpSLaQ3XXnP40K+ROgwCqM8v8pfQ55bdBgsf0bpMfR6zuF5oLuUa3AwwGT7za9Q9YrSIr7t1XmC4KAr1PP2h/gUy60bNVL2AXsuhpNO4Ug+P9kLmUIo3TPLqq84sTeJ9mLkhvUQCtCXctLPzMI27SijMIJsyjPGA70Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758855454; c=relaxed/simple; bh=0seR/PPCeNmqCqEO+CWxl4vQFh/Swbrz7dNPOFg2U8A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NYu/52SFRbTi2hDMxcbRlP9Q43BkjduHqS8K1XJxF4P7vjkGG/isM6OqotNjuwPPpttwFQuZxZqyDrTR4cmlie1S9QRIHB4vrkAWy1GPS7qYcnta1FtIDGgvkOe5GHZxtRBPJrt/AU9xRBrLmum/ZtWuRYeukGwKE3kYgwb8jwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ErkBwIxn; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ErkBwIxn" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1758855449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KMI3PZUF0sh3zSd/02iYpfvXrjt5XLvTI4LxgYH0VXg=; b=ErkBwIxniq2ZxzhmdPHgOou7mR8kgIHkwtskgQaDy9V/FGhbFnOyVVnrBzuT+F4NiFAiI7 +jSJd3wxQJbdNeefgRygLePWLrxMkSj/OvrNAH2WsWKnwT3Bs2jLOo0ZO1RgXlMZfgQZ2y LJEPJyPfI0IOwlSrcJ6X9WNFd5M6gao= From: Youling Tang To: Andreas Gruenbacher Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, youling.tang@linux.dev, Youling Tang Subject: [PATCH] gfs2: Move i_nlink checks from gfs2_{link,rename,mkdir} to VFS layer Date: Fri, 26 Sep 2025 10:56:04 +0800 Message-ID: <20250926025604.500713-1-youling.tang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Youling Tang 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 --- 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 { }; =20 #define GFS2_FAST_NAME_SIZE 8 +#define GFS2_LINK_MAX 0xffffffff =20 #endif /* __GFS2_DOT_H__ */ =20 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 stru= ct qstr *name, =20 if (dip->i_entries =3D=3D (u32)-1) return -EFBIG; - if (S_ISDIR(mode) && dip->i_inode.i_nlink =3D=3D (u32)-1) - return -EMLINK; =20 return 0; } @@ -1079,9 +1077,6 @@ static int gfs2_link(struct dentry *old_dentry, struc= t inode *dir, error =3D -EPERM; if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) goto out_gunlock; - error =3D -EMLINK; - if (ip->i_inode.i_nlink =3D=3D (u32)-1) - goto out_gunlock; =20 error =3D gfs2_diradd_alloc_required(dir, &dentry->d_name, &da); if (error < 0) @@ -1623,11 +1618,6 @@ static int gfs2_rename(struct inode *odir, struct de= ntry *odentry, error =3D -EFBIG; goto out_gunlock; } - if (S_ISDIR(ip->i_inode.i_mode) && - ndip->i_inode.i_nlink =3D=3D (u32)-1) { - error =3D -EMLINK; - goto out_gunlock; - } } } =20 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, st= ruct fs_context *fc) sb_dqopt(sb)->flags |=3D DQUOT_QUOTA_SYS_FILE; sb->s_time_gran =3D 1; sb->s_maxbytes =3D MAX_LFS_FILESIZE; + sb->s_max_links =3D GFS2_LINK_MAX; =20 /* Set up the buffer cache and fill in some fake block size values to allow us to read-in the on-disk superblock. */ --=20 2.43.0