From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (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 9D63030EF82; Tue, 18 Nov 2025 08:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454406; cv=none; b=ofLgc4bhaVPrm5qFIzmaIoyG+GcRvpNfXYJcpAGzH2j4sEZWjSogSWCAmwlgcgAixxZqBFh49IlCwqQtDSIP9kebKPYfd4V4KsRiaYPaJzYGrr2L3kAWMl4FDWUsRlcJXWvmfzuyb+ow1fZgwZxxAw6/fFlXwMcO682b+oDN3Kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454406; c=relaxed/simple; bh=4gg5VKImBGmYgPHL0iIJTSRE65yrULHZ2zCk5PapxfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KPttZX8ugMGduORgye8Y0gYnWHJN6cfXx9xomZaXt8Qnz+PiaU3mQy1Mm+bZUhtL7zA6c1RwgdCpgKueXGnzZKuZxQOzA921nAB16MOtR7yOYouFySMRhxNLRGTOxmFVn43xXfdyCbBZWgUcHOvklyfkyJXhwNy2uM+AdzeVmNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=iBJzTgqi; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="iBJzTgqi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=yb KPUqQ1A+oPrBVH99WIJIcNNPghHfyNmGDMMwRDSe4=; b=iBJzTgqiry3a7YweYm EBoD2bLS77N3zU9iquRHVhxVUH0JGfug9fI10SXRUoeD6O3bf+tqmmS8Qd6hlNAj g4Mtw8HA5feb0eaoBnza70BuzA7qq3AOtpMYE6stdR28TnO2ki5wBRz+qWnhaLii yuI6R+eCphPWWg6cv3AhvrpOI= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S3; Tue, 18 Nov 2025 16:25:44 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 1/7] exfat: add cache option for __exfat_ent_get Date: Tue, 18 Nov 2025 16:22:02 +0800 Message-ID: <20251118082208.1034186-2-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF13XFyrZFy8WF1DKFy3Arb_yoW8Zr1Dpr ZxK34fKr4UX3WIvwnFyrs5Zw1fC397GFykG3y5Cw4fJF98trs5ZFyxtryYqF4xG3y8AFyY vF18tF1rCwsrWaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jzFALUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/1tbiFAMKnWkcJbehNgAEs0 Content-Type: text/plain; charset="utf-8" From: Chi Zhiling When multiple entries are obtained consecutively, these entries are mostly stored adjacent to each other. this patch introduces a "last" parameter to cache the last opened buffer head, and reuse it when possible, which reduces the number of sb_bread() calls. When the passed parameter "last" is NULL, it means cache option is disabled, the behavior unchanged as it was. Signed-off-by: Chi Zhiling --- fs/exfat/fatent.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index 825083634ba2..f9c5d3485865 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -36,18 +36,21 @@ static int exfat_mirror_bh(struct super_block *sb, sect= or_t sec, } =20 static int __exfat_ent_get(struct super_block *sb, unsigned int loc, - unsigned int *content) + unsigned int *content, struct buffer_head **last) { unsigned int off; sector_t sec; - struct buffer_head *bh; + struct buffer_head *bh =3D last ? *last : NULL; =20 sec =3D FAT_ENT_OFFSET_SECTOR(sb, loc); off =3D FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc); =20 - bh =3D sb_bread(sb, sec); - if (!bh) - return -EIO; + if (!bh || bh->b_blocknr !=3D sec || !buffer_uptodate(bh)) { + brelse(bh); + bh =3D sb_bread(sb, sec); + if (!bh) + return -EIO; + } =20 *content =3D le32_to_cpu(*(__le32 *)(&bh->b_data[off])); =20 @@ -55,7 +58,10 @@ static int __exfat_ent_get(struct super_block *sb, unsig= ned int loc, if (*content > EXFAT_BAD_CLUSTER) *content =3D EXFAT_EOF_CLUSTER; =20 - brelse(bh); + if (last) + *last =3D bh; + else + brelse(bh); return 0; } =20 @@ -95,7 +101,7 @@ int exfat_ent_get(struct super_block *sb, unsigned int l= oc, return -EIO; } =20 - err =3D __exfat_ent_get(sb, loc, content); + err =3D __exfat_ent_get(sb, loc, content, NULL); if (err) { exfat_fs_error_ratelimit(sb, "failed to access to FAT (entry 0x%08x, err:%d)", --=20 2.43.0 From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (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 3DD3F308F23; Tue, 18 Nov 2025 08:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454413; cv=none; b=AWy66Bbn2r9wwEiYUngEBJMEnoiR3Cqt75uqQtAW9qiqTS1ovJfMONOJtBBvpz69kfEWOwNJQVFfLxt4pn5Yt8FjdyNE7PSspvjJsSLGr8nDI8vc1RdPyIbuZ/rKm2sz66QOMXPxCikPBY14y6sI7d6/qFRhV7mOk4ggdD5/D8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454413; c=relaxed/simple; bh=9brJRpO1ekzNPHLdh5MFnRxahxgUUYXD/RRKBpc5xTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=abkeehkt7MUiGJjdhfMNwIWPjUdeoghdmEknEh1raScx0ZwJri0cKK2KXePDjrkwFFVYFvlcu5ZpbV8+nwf2ALn2IZ+Kjy5NbJKhl4eC2vodqYTCNGn9JNllJLHabXlhN5o381S0uiHjY1RJ88JxgVzxipJUEwi32G7QcjEYH5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=H02QeOsm; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="H02QeOsm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Ba /0h4T7IHoa/OO1DwEEs6NptrDdaZ/Jmk1LQMzpQX4=; b=H02QeOsm7CQ5NmaGHg mHdSPoA6vrKonN3K5Nxoll9aLryV8LFyZyCy8z8r86rq6r4nWkBWVCSEo/rA/dDQ /+smUvSl4wywQ5d3UMpWSOCmJNjanlkMg0eleqKKr2ZvWD9aL0hSe3udA8ahKjNp AGhf0T7XxshPukM3VpBnq6gmY= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S4; Tue, 18 Nov 2025 16:25:45 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 2/7] exfat: support reuse buffer head for exfat_ent_get Date: Tue, 18 Nov 2025 16:22:03 +0800 Message-ID: <20251118082208.1034186-3-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxAFW7WFykJr45AF1DKr4rKrg_yoWrCry3pF 4DKa95JrWUJ3W7uwnrtF4kZ3WS93yxWFykGa15A3ZIyryktrn5ur17tryayFWrA3y8C3WY kF1jgF1Uur9xWaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j7a9-UUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbBgAkKnWkcJ5WpfwAAsP Content-Type: text/plain; charset="utf-8" From: Chi Zhiling This patch is part 2 of cached buffer head for exfat_ent_get, it introduces an argument for exfat_ent_get, and make sure this routine releases buffer head refcount when any error return. Signed-off-by: Chi Zhiling --- fs/exfat/cache.c | 2 +- fs/exfat/exfat_fs.h | 4 ++-- fs/exfat/fatent.c | 35 +++++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/fs/exfat/cache.c b/fs/exfat/cache.c index d5ce0ae660ba..61af3fa05ab7 100644 --- a/fs/exfat/cache.c +++ b/fs/exfat/cache.c @@ -287,7 +287,7 @@ int exfat_get_cluster(struct inode *inode, unsigned int= cluster, return -EIO; } =20 - if (exfat_ent_get(sb, *dclus, &content)) + if (exfat_ent_get(sb, *dclus, &content, NULL)) return -EIO; =20 *last_dclus =3D *dclus; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 329697c89d09..d52893276e9a 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -433,13 +433,13 @@ int exfat_set_volume_dirty(struct super_block *sb); int exfat_clear_volume_dirty(struct super_block *sb); =20 /* fatent.c */ -#define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu) +#define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu, = NULL) =20 int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, struct exfat_chain *p_chain, bool sync_bmap); int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain); int exfat_ent_get(struct super_block *sb, unsigned int loc, - unsigned int *content); + unsigned int *content, struct buffer_head **last); int exfat_ent_set(struct super_block *sb, unsigned int loc, unsigned int content); int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain, diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index f9c5d3485865..a3a19c8d2e05 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -88,8 +88,11 @@ int exfat_ent_set(struct super_block *sb, unsigned int l= oc, return 0; } =20 +/* + * Caller must release the buffer_head if no error return. + */ int exfat_ent_get(struct super_block *sb, unsigned int loc, - unsigned int *content) + unsigned int *content, struct buffer_head **last) { struct exfat_sb_info *sbi =3D EXFAT_SB(sb); int err; @@ -98,39 +101,47 @@ int exfat_ent_get(struct super_block *sb, unsigned int= loc, exfat_fs_error_ratelimit(sb, "invalid access to FAT (entry 0x%08x)", loc); - return -EIO; + goto err; } =20 - err =3D __exfat_ent_get(sb, loc, content, NULL); - if (err) { + err =3D __exfat_ent_get(sb, loc, content, last); + if (unlikely(err)) { exfat_fs_error_ratelimit(sb, "failed to access to FAT (entry 0x%08x, err:%d)", loc, err); - return err; + goto err; } =20 - if (*content =3D=3D EXFAT_FREE_CLUSTER) { + if (unlikely(*content =3D=3D EXFAT_FREE_CLUSTER)) { exfat_fs_error_ratelimit(sb, "invalid access to FAT free cluster (entry 0x%08x)", loc); - return -EIO; + goto err; } =20 - if (*content =3D=3D EXFAT_BAD_CLUSTER) { + if (unlikely(*content =3D=3D EXFAT_BAD_CLUSTER)) { exfat_fs_error_ratelimit(sb, "invalid access to FAT bad cluster (entry 0x%08x)", loc); - return -EIO; + goto err; } =20 if (*content !=3D EXFAT_EOF_CLUSTER && !is_valid_cluster(sbi, *content)) { exfat_fs_error_ratelimit(sb, "invalid access to FAT (entry 0x%08x) bogus content (0x%08x)", loc, *content); - return -EIO; + goto err; } =20 return 0; +err: + if (last) { + brelse(*last); + + /* Avoid double release */ + *last =3D NULL; + } + return err; } =20 int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain, @@ -299,7 +310,7 @@ int exfat_find_last_cluster(struct super_block *sb, str= uct exfat_chain *p_chain, do { count++; clu =3D next; - if (exfat_ent_get(sb, clu, &next)) + if (exfat_ent_get(sb, clu, &next, NULL)) return -EIO; } while (next !=3D EXFAT_EOF_CLUSTER && count <=3D p_chain->size); =20 @@ -490,7 +501,7 @@ int exfat_count_num_clusters(struct super_block *sb, count =3D 0; for (i =3D EXFAT_FIRST_CLUSTER; i < sbi->num_clusters; i++) { count++; - if (exfat_ent_get(sb, clu, &clu)) + if (exfat_ent_get(sb, clu, &clu, NULL)) return -EIO; if (clu =3D=3D EXFAT_EOF_CLUSTER) break; --=20 2.43.0 From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (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 40D9E2D641C; Tue, 18 Nov 2025 08:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454413; cv=none; b=RItDNZ7gmFWJNHqRtDi8g3U/x/LE0sfZtafPOQmwcbJ5oo1vPjq1NG1O4A40zS0X8J+5ZXv5hYDeMi1txeMUxQxb8hUlnceqwkvgBH82gFBeXBcqsh56ALl+6e31M0Z3rtNAz2kHa0oBGh04B3sOic62oVAbb5ahZr8uHgb5M/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454413; c=relaxed/simple; bh=83CUkqg3DKZvhqPz7BeX2UXkFHH04US6sL7GjVRTLQc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWkauelo4AG+ZPQs8BMa9J7J2sHlEmrn6ePAQPBb0DdBjkWWUhk870jZQDewF/s6FU2yeyV3ss0ZPhkk2GqUvSSDepZC7cMT7Uj+Z0fnQxH3U5BNxKph73Wxu0rEHfxFOu28++AvG+4UKWBAneHt0uUDWt5qXj+kpqVRy94UxgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=K7Op5jgB; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="K7Op5jgB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=U0 7yPNefwy1OYQZSIN4NA7Tac2w5lWyx5VcfQ4rt6EI=; b=K7Op5jgBAj3tIU6Pnq qp89i4N/LWOMAsgybDgYxbcaowgtQovP4RUAhTGZ4lhwED2miA3SibaNawigFVEu M3McD/jIzBdOuHnDrgRed/6u8lwG2pQTNlYYzXziZhNr0+4B/WmwS909knaG/7k9 wdQO1Td05YF3L1twxz/qPTIGU= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S5; Tue, 18 Nov 2025 16:25:45 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 3/7] exfat: reuse cache to improve exfat_get_cluster Date: Tue, 18 Nov 2025 16:22:04 +0800 Message-ID: <20251118082208.1034186-4-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar15Gr4ftr4fXF43GF43GFg_yoW8Wr4kpr Z8KayUtrW5A397uw48KFn3Z3WS9FZ7Ja1UGa13A3Wjkryqyr4F9r17Kr9xA3WrJw48uF4Y 9r15K3WUurnrG3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jqOJnUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbBcxEKnWkcJZTfwgAAss Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Since exfat_ent_get supports cache buffer head, we can use this option to reduce sb_bread calls when fetching consecutive entries. Signed-off-by: Chi Zhiling --- fs/exfat/cache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/exfat/cache.c b/fs/exfat/cache.c index 61af3fa05ab7..a5e6858e5a20 100644 --- a/fs/exfat/cache.c +++ b/fs/exfat/cache.c @@ -241,6 +241,7 @@ int exfat_get_cluster(struct inode *inode, unsigned int= cluster, struct exfat_sb_info *sbi =3D EXFAT_SB(sb); unsigned int limit =3D sbi->num_clusters; struct exfat_inode_info *ei =3D EXFAT_I(inode); + struct buffer_head *bh =3D NULL; struct exfat_cache_id cid; unsigned int content; =20 @@ -284,10 +285,10 @@ int exfat_get_cluster(struct inode *inode, unsigned i= nt cluster, exfat_fs_error(sb, "detected the cluster chain loop (i_pos %u)", (*fclus)); - return -EIO; + goto err; } =20 - if (exfat_ent_get(sb, *dclus, &content, NULL)) + if (exfat_ent_get(sb, *dclus, &content, &bh)) return -EIO; =20 *last_dclus =3D *dclus; @@ -299,7 +300,7 @@ int exfat_get_cluster(struct inode *inode, unsigned int= cluster, exfat_fs_error(sb, "invalid cluster chain (i_pos %u, last_clus 0x%08x is EOF)", *fclus, (*last_dclus)); - return -EIO; + goto err; } =20 break; @@ -309,6 +310,10 @@ int exfat_get_cluster(struct inode *inode, unsigned in= t cluster, cache_init(&cid, *fclus, *dclus); } =20 + brelse(bh); exfat_cache_add(inode, &cid); return 0; +err: + brelse(bh); + return -EIO; } --=20 2.43.0 From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (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 8F3BE28853E; Tue, 18 Nov 2025 08:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454399; cv=none; b=koSe+cYxdIcgs6+WKFMY/+gmMejKpE0n+MLizJ1A0TSSured3fSM5HMtm9VIteNQ6KwyGJuewN/UsTxtKm+JtYENLrOALIvcmsBcevLLj/ThjaMG49/7Ds7QEE/2SdUb3VJkgj/Q6l0Bi3QdxgZI0dw9GzZobP5GIicpWK0i9ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454399; c=relaxed/simple; bh=LrHdiqncaiGkqgbMxf7vpgk5u6IgsktQ7bpm8tDO5hI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cC6I9yw07LLctiM+OZJu1DgGnK4Mtu3DE+owJ9ZgdadrLbR8VVpE9adm4WUdwPuvJoRXAIwqZuAuTy64Guiu1xLCOTQmbg+6MgaWXYU6q4hI2eQUrusj+jD4FjpMe1HyhvBjwnafpZcrNiGsqTYt8DC5L0sJo19XsYOnuzO5guo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=dwUzS+cq; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="dwUzS+cq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=i0 pTdxSxY6ivc8rRFGVjO1a7BjENNltMxXKjdwWAtSg=; b=dwUzS+cqx1GiOABNLc VlpVv7mxaoEicOgoOrbKowzZoZRIGpzLEXkVCqPD0zl58YfN4e1rYno9M13EFdWy ugAPbTbBlQHtJrPJwyqf5PbFrtRbOvZZGNebp2Zao8ZrMg4Tzl2YJ0Tr8aNi7uw6 xHA19t+XR7yM+YZCGraVVPR6Q= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S6; Tue, 18 Nov 2025 16:25:45 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 4/7] exfat: improve exfat_count_num_clusters Date: Tue, 18 Nov 2025 16:22:05 +0800 Message-ID: <20251118082208.1034186-5-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S6 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jw4UAryfAw48WF4fGryxGrg_yoWDuFbEkF 1IvryDWr4jyF1Syr1vy3yakFy2qa1xC34qvrW2yFyqg3srJ3y7XFyUJFy7Cw42krs3Jr98 JrZ3Jrn3G3W0yjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUb9mR5UUUUU== X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbBcxEKnWkcJZTfwgABst Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Since exfat_ent_get support cache buffer head, let's apply it to exfat_count_num_clusters. Signed-off-by: Chi Zhiling --- fs/exfat/fatent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index a3a19c8d2e05..08f9a817af28 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -486,6 +486,7 @@ int exfat_count_num_clusters(struct super_block *sb, unsigned int i, count; unsigned int clu; struct exfat_sb_info *sbi =3D EXFAT_SB(sb); + struct buffer_head *bh =3D NULL; =20 if (!p_chain->dir || p_chain->dir =3D=3D EXFAT_EOF_CLUSTER) { *ret_count =3D 0; @@ -501,12 +502,13 @@ int exfat_count_num_clusters(struct super_block *sb, count =3D 0; for (i =3D EXFAT_FIRST_CLUSTER; i < sbi->num_clusters; i++) { count++; - if (exfat_ent_get(sb, clu, &clu, NULL)) + if (exfat_ent_get(sb, clu, &clu, &bh)) return -EIO; if (clu =3D=3D EXFAT_EOF_CLUSTER) break; } =20 + brelse(bh); *ret_count =3D count; =20 /* --=20 2.43.0 From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) (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 53278309EEB; Tue, 18 Nov 2025 08:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454407; cv=none; b=UdT5WIwyfpkoRdE4ikOXcb8EUX9y/b9Zv9Sv8z/hA0EVXrKlsIeTF+HMwZoNoJpqVkYODijlabswTW3uSzPh/rVjVwBVz5L3hipc6qRUnGdA62YbXLmgFUyEFcJfNyUJffwARfuZ01J0PNineH8ksPdvJufQs+5Sxgp45BIMgTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454407; c=relaxed/simple; bh=cTR2HfbxWKCzKckLSvc1kTIfiBdM++AQ4VcXTDmra74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GSLVmpJvOZdsHJU8vbrU5ADqjIOSWWkhqZUgJKI/o5ANazPtSZGBOvmLB2Xk61aRWbtokNMut0jsrVeZE3HdHUUqT91niakjBAgXVKbVdi5sPzA4k8+wlTYQ/rWWH6t5LRZPl7gAzefHExSFxU6V0xn2A1/nvfS5gCC8zmO+GzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=mrCISs1m; arc=none smtp.client-ip=117.135.210.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="mrCISs1m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Uv /YobMX5Vm4b7+G2HN+8lcF5mEX1FDlwqmc0s4H2ig=; b=mrCISs1mOW0g2yn7nG W1coujKxtfBSwOpk/YPeW9h1o8HslkQB5koGHKYIbip6IItPmAwR9OkvgWIYV38A Qt4+dmfTcYPwu7iEQ9ejdGXmI4cH39PU9SHcrwtUt6YQHWiR4d40Hg3s2AKNyM9d 337uAKEpBBElaXuvoAHhOrK/o= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S7; Tue, 18 Nov 2025 16:25:46 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 5/7] exfat: improve exfat_find_last_cluster Date: Tue, 18 Nov 2025 16:22:06 +0800 Message-ID: <20251118082208.1034186-6-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S7 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jw4UAryfCr15ZFy8Cw1xKrg_yoWkZFc_uw 18KrykWryYyr1Syr1DC3yayFWSya1DZ3y8urW7tr9Fq3s8J397ZF4DXF9rurWjkrs7AF95 Jr95Ar93Ga48ujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUb9mR5UUUUU== X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/1tbiFB8KnWkcJbfcyQAAsu Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Since exfat_ent_get support cache buffer head, let's apply it to exfat_find_last_cluster. Signed-off-by: Chi Zhiling --- fs/exfat/fatent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index 08f9a817af28..d980d17176c2 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -298,6 +298,7 @@ int exfat_free_cluster(struct inode *inode, struct exfa= t_chain *p_chain) int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_= chain, unsigned int *ret_clu) { + struct buffer_head *bh =3D NULL; unsigned int clu, next; unsigned int count =3D 0; =20 @@ -310,10 +311,11 @@ int exfat_find_last_cluster(struct super_block *sb, s= truct exfat_chain *p_chain, do { count++; clu =3D next; - if (exfat_ent_get(sb, clu, &next, NULL)) + if (exfat_ent_get(sb, clu, &next, &bh)) return -EIO; } while (next !=3D EXFAT_EOF_CLUSTER && count <=3D p_chain->size); =20 + brelse(bh); if (p_chain->size !=3D count) { exfat_fs_error(sb, "bogus directory size (clus : ondisk(%d) !=3D counted(%d))", --=20 2.43.0 From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (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 D3C46308F25; Tue, 18 Nov 2025 08:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454405; cv=none; b=PKSuRo9qWxDZspjacR3ZAM1pFCcDk+Rlez1qFKMW3vLiDFNQ2dGkHG0Sk9MA5ue/7Om0VfpX1hKijmrOnvupOKttYs4+qElyxY9+DToOzOObR2+DnD/+Y62LH9xdCCWQarxytCNldPNMvRoDjpwe9QkaQdaHcB+2cox4CrBUXvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454405; c=relaxed/simple; bh=xO3DdKtZm2GDO6q7bPI75O/Ok01ThLO7wRgQXObHvw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NIIU/pXETzg2+5ZKPXjkEFVj9cu3dgkefC0tUWkHP68Jm2NROBVVISbR/gThxepXaB6OhJlpwjivIq03Wm0f4vImjp6MbgMNuoqGVqElY0dhxlzkxC0teVlx7KFMPw9pI53lLrTMJInYtar75Fn3m8XaLi10MyRZcyErFNasKcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=ZDPyw+n1; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="ZDPyw+n1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=6a 3Qr5pnCBxhdQPyLBRaNx2IzXP1rmnmnWeyJtAHnXA=; b=ZDPyw+n1h9kJ03b941 cKLn55f5UafpBi+/MW/j5Dd7tZgVlF/phjbxjDG17oIMLlqjNVhN0guI6J0zxU31 cXxlqpZxtmTtt448nTfTIZhp78lhOz5tP1buu1URVUD3XKuTK7+MvNChUOSIUoSs 0C6DnoF+whbT+DvxhckzM8cG0= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S8; Tue, 18 Nov 2025 16:25:46 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 6/7] exfat: introduce exfat_count_contig_clusters Date: Tue, 18 Nov 2025 16:22:07 +0800 Message-ID: <20251118082208.1034186-7-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S8 X-Coremail-Antispam: 1Uf129KBjvJXoW7KrykAryUCF4UKFWDGF45KFg_yoW8Cw1kpF 4xJw4rJrW8X3Z7W3W3Jws5Z3W3Cwn7CFyDtayfA345trZIvrn5Cr9xK343tFWrtw1DGFy2 q3WFgr1j9rsxGaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UmQ6XUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbBgAYKnWkcJ5WpogAAsd Content-Type: text/plain; charset="utf-8" From: Chi Zhiling This patch introduces exfat_count_contig_clusters to obtain batch entries, which is an infrastructure used to support iomap. Signed-off-by: Chi Zhiling --- fs/exfat/exfat_fs.h | 2 ++ fs/exfat/fatent.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index d52893276e9a..421dd7c61cca 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -449,6 +449,8 @@ int exfat_find_last_cluster(struct super_block *sb, str= uct exfat_chain *p_chain, unsigned int *ret_clu); int exfat_count_num_clusters(struct super_block *sb, struct exfat_chain *p_chain, unsigned int *ret_count); +int exfat_count_contig_clusters(struct super_block *sb, + struct exfat_chain *p_chain, unsigned int *ret_count); =20 /* balloc.c */ int exfat_load_bitmap(struct super_block *sb); diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index d980d17176c2..9dcee9524155 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -524,3 +524,36 @@ int exfat_count_num_clusters(struct super_block *sb, =20 return 0; } + +int exfat_count_contig_clusters(struct super_block *sb, + struct exfat_chain *p_chain, unsigned int *ret_count) +{ + struct buffer_head *bh =3D NULL; + unsigned int clu, next_clu; + unsigned int count; + + if (!p_chain->dir || p_chain->dir =3D=3D EXFAT_EOF_CLUSTER) { + *ret_count =3D 0; + return 0; + } + + if (p_chain->flags =3D=3D ALLOC_NO_FAT_CHAIN) { + *ret_count =3D p_chain->size; + return 0; + } + + clu =3D p_chain->dir; + for (count =3D 1; count < p_chain->size; count++) { + if (exfat_ent_get(sb, clu, &next_clu, &bh)) + return -EIO; + if (++clu !=3D next_clu) + break; + } + + /* TODO: Update p_claim to help caller read ahead the next block */ + + brelse(bh); + *ret_count =3D count; + + return 0; +} --=20 2.43.0 From nobody Tue Dec 2 02:43:30 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (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 0E06430E855; Tue, 18 Nov 2025 08:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454405; cv=none; b=T8AiZlOKEGVU0p3vI7RKeSJi81DdvkMwh5c5Et0OOA8n+yMvjNAViCuOj+eqAuokQph4yWypri1LRFYvLmcK7EJbncG1OAFE8r6DFMfRD1eivzMJa88lv/xEqWHFoMR1lj07cirwiu2rP5dSngH9rSQN4TXEK36npUQOkwGrlC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763454405; c=relaxed/simple; bh=SWHI6+KQNwTARRsMofGlnQxP3zRdoyS5+c3T1zuIi/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lGMzw6uF00Pn2tG+TRCtCEwmqRUm91UYP96bPeukkcs5uYzR2muJjryieYLESKTEt8e1Rq3w9rgel87C1+XcTuOTBMKXkJSDD5k8gMUw8DYIPhktEtNg4L/+Ecxk4oLrFSQK7hFZwIWDMiE0hCHyT0JIF41j06ppLtAlxQo8rQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=YAA7K6Q+; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="YAA7K6Q+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Bi LtkTp8vGas+r+wZ19/Ti3OnkocVUM3pHmHDrrYUwg=; b=YAA7K6Q+IKmnft3eNs v7QkwS/6scqBY6mk95zhrCd5rJ2R4KR+/dgDHahAgVf6kTXjAi6nM/dBfsd91nc/ E23IuS0+gh7NmfdSHlSbOGY1R6fxhMdpOrUp3Kq/dBf+XdM8orLnywCP/fYuGgYF Cq9JvoXTCXvAuPl9BscWQnCNM= Received: from czl-ubuntu-pc.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnu_KILRxpyC6zEQ--.29019S9; Tue, 18 Nov 2025 16:25:46 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Namjae Jeon , Sungjong Seo , Yuezhang Mo , Chi Zhiling Subject: [RFC PATCH 7/7] exfat: get mutil-clusters in exfat_get_block Date: Tue, 18 Nov 2025 16:22:08 +0800 Message-ID: <20251118082208.1034186-8-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118082208.1034186-1-chizhiling@163.com> References: <20251118082208.1034186-1-chizhiling@163.com> 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-CM-TRANSID: PigvCgAnu_KILRxpyC6zEQ--.29019S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw43Kw15KF43WFyfZF17GFg_yoW8Zry5p3 ykGa4rGw45W3srWa1xtrs5WF1S93ykGFy8Jr4xXF1Ykr9YqrnavFWqyr9xA3Wrt3Z5Xrn0 q3WrKr1j9wnrG3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UmApOUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/1tbiFA4KnWkcJbfc6AAAse Content-Type: text/plain; charset="utf-8" From: Chi Zhiling mpage uses the get_block of the file system to obtain the mapping of a file or allocate blocks for writes. Currently exfat only supports obtaining one cluster in each get_block call. Since exfat_count_contig_clusters can obtain multiple consecutive clusters, it can be used to improve exfat_get_block when page size is larger than cluster size. Signed-off-by: Chi Zhiling --- fs/exfat/inode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index f9501c3a3666..256ba2af34eb 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -264,13 +264,14 @@ static int exfat_map_cluster(struct inode *inode, uns= igned int clu_offset, static int exfat_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { + struct exfat_chain chain; struct exfat_inode_info *ei =3D EXFAT_I(inode); struct super_block *sb =3D inode->i_sb; struct exfat_sb_info *sbi =3D EXFAT_SB(sb); unsigned long max_blocks =3D bh_result->b_size >> inode->i_blkbits; int err =3D 0; unsigned long mapped_blocks =3D 0; - unsigned int cluster, sec_offset; + unsigned int cluster, sec_offset, count; sector_t last_block; sector_t phys =3D 0; sector_t valid_blks; @@ -301,6 +302,17 @@ static int exfat_get_block(struct inode *inode, sector= _t iblock, =20 phys =3D exfat_cluster_to_sector(sbi, cluster) + sec_offset; mapped_blocks =3D sbi->sect_per_clus - sec_offset; + + if (max_blocks > mapped_blocks && !create) { + chain.dir =3D cluster; + chain.size =3D (max_blocks >> sbi->sect_per_clus_bits) + 1; + chain.flags =3D ei->flags; + + err =3D exfat_count_contig_clusters(sb, &chain, &count); + if (err) + return err; + max_blocks =3D (count << sbi->sect_per_clus_bits) - sec_offset; + } max_blocks =3D min(mapped_blocks, max_blocks); =20 map_bh(bh_result, sb, phys); --=20 2.43.0