From nobody Sat Feb 7 08:23:17 2026 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 C36D4314D12; Fri, 26 Dec 2025 09:45:39 +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=1766742342; cv=none; b=hJW7gK+8EbxUV9Hu7kqI6A7es5wdx6GTeUSAB7vQZPoFbqwGGsysb6Cs1QLjmBZ+jul612cHOsp6zEPJ8zY2/5f3nd8NqZsqpKIEfNxuN2+f8dhqkepT7e6rwUhh8zWS+Qs/2WNsJjqwTQXT7T5XDa1unVq0JlGtqzlxL/Qa/us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766742342; c=relaxed/simple; bh=Xb8C2JLdNadFXnGNd/14DTutB+ouyLvTF+ynAxnMW9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NXS+V3srleGVk7hgEt4R931h5KGpnt5spGm+PE7OmfKRXDim4B0bTHPNk/AzwmX6QvHhREprsm4BU22JzTbF6AdNMwJSnE0rYhxLXMmriq24vLnQNee/Vavdqz02F+jpmpuKF9qid9a4XLDxPpcTfHWrAWb8Wh6iF7Tqpx3Qenk= 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=CvDIGtZV; 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="CvDIGtZV" 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=0v htbSvbnQVcK4ilcpDDyTdPLbheiLDwPIzUu6QCadA=; b=CvDIGtZVkBYLyVrzFe 0LXMhQROtoPXVr4L72bvG5/Lh9hCWhDOkn7ej2Y1a3pbejy3hjgm8XKj1gXXfCms 5Xd5hnR52GlPySWxkwcyaheGEnM49iU+Dv6/uNvSlHbvUvtvyLZRfpMbfKEifJG0 WbwhQx818NbPscwX7tWUBotas= Received: from chi-Redmi-Book.. (unknown []) by gzsmtp5 (Coremail) with SMTP id QCgvCgCnlXIPWU5p9JFCJA--.53S3; Fri, 26 Dec 2025 17:44:50 +0800 (CST) From: Chi Zhiling To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Namjae Jeon , Sungjong Seo , Yuezhang Mo , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , Chi Zhiling Subject: [PATCH v1 1/9] exfat: add cache option for __exfat_ent_get Date: Fri, 26 Dec 2025 17:44:32 +0800 Message-ID: <20251226094440.455563-2-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251226094440.455563-1-chizhiling@163.com> References: <20251226094440.455563-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: QCgvCgCnlXIPWU5p9JFCJA--.53S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF13XFyrZFy8WF1DKFy3Arb_yoW8Zry5pr ZxK34fKr4UX3W2v3ZFyrs5Zw1rC397GFyDGw45Cws3Jryrtr4kZryxtryYqF4xJ3y8AFWY vF1UtF15CwsrWa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jz2NtUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC9xNI5WlOWROHCgAA3p 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 c9c5f2e3a05e..0cfbc0b435bd 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -36,18 +36,23 @@ 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 (last) + *last =3D bh; + if (unlikely(!bh)) + return -EIO; + } =20 *content =3D le32_to_cpu(*(__le32 *)(&bh->b_data[off])); =20 @@ -55,7 +60,8 @@ static int __exfat_ent_get(struct super_block *sb, unsign= ed int loc, if (*content > EXFAT_BAD_CLUSTER) *content =3D EXFAT_EOF_CLUSTER; =20 - brelse(bh); + if (!last) + 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