From: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-fsdevel@vger.kernel.org, brauner@kernel.org,
djwong@kernel.org, hch@lst.de, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/8] fat: support FIEMAP
Date: Thu, 12 Nov 2026 01:09:42 -0300 [thread overview]
Message-ID: <avU3IRmswObU2pH6@DESKTOP-PJTTJ93.localdomain> (raw)
In-Reply-To: <87tslrtlyu.fsf@mail.parknet.co.jp>
On Sun, Nov 08, 2026 at 11:51:53PM +0900, OGAWA Hirofumi wrote:
>Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br> writes:
>
>> Implement support for ->fiemap() using iomap_fiemap(). Add a read-only
>> fat_iomap_begin() and a fat_get_cont_clusters() helper for finding
>> contiguous clusters.
>
>Not fully reviewed and I'm not understanding iomap fully though.
>
>> Signed-off-by: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
>> ---
>> fs/fat/Kconfig | 1 +
>> fs/fat/Makefile | 2 +-
>> fs/fat/cache.c | 80 ++++++++++++++++++++++++++++++++++++++-----------
>> fs/fat/fat.h | 5 ++++
>> fs/fat/file.c | 12 ++++++++
>> fs/fat/iomap.c | 71 +++++++++++++++++++++++++++++++++++++++++++
>> 6 files changed, 152 insertions(+), 19 deletions(-)
>> create mode 100644 fs/fat/iomap.c
>>
>
>[...]
>
>> diff --git a/fs/fat/cache.c b/fs/fat/cache.c
>> index 1b87354e24ba..f545e1db1d47 100644
>> --- a/fs/fat/cache.c
>> +++ b/fs/fat/cache.c
>> @@ -76,7 +76,7 @@ static int fat_cache_lookup(struct inode *inode, int fclus,
>> struct fat_cache_id *cid,
>> int *cached_fclus, int *cached_dclus)
>> {
>> - static struct fat_cache nohit = { .fcluster = 0, };
>> + static struct fat_cache nohit = { .fcluster = -1, };
>
>Maybe this change is pointless?
>
It is needed for the cache_init() change, as otherwise it would not find
an entry at cluster 0. See below for the rationale as to why I was trying
to do it.
>> struct fat_cache *hit = &nohit, *p;
>> int offset = -1;
>> @@ -217,14 +217,16 @@ static inline void cache_init(struct fat_cache_id *cid, int fclus, int dclus)
>> cid->nr_contig = 0;
>> }
>>
>> -int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
>> +static int __fat_get_cluster(struct inode *inode, int cluster, int *fclus,
>> + int *dclus, int *nr_cont)
>> {
>> struct super_block *sb = inode->i_sb;
>> struct msdos_sb_info *sbi = MSDOS_SB(sb);
>> const int limit = sb->s_maxbytes >> sbi->cluster_bits;
>> struct fat_entry fatent;
>> struct fat_cache_id cid;
>
>[...]
>
>>
>> if (fat_cache_lookup(inode, cluster, &cid, fclus, dclus) < 0) {
>> - /*
>> - * dummy, always not contiguous
>> - * This is reinitialized by cache_init(), later.
>> - */
>> - cache_init(&cid, -1, -1);
>> + /* Cache the contiguous prefix from the known first cluster. */
>> + cache_init(&cid, 0, *dclus);
>
>Doesn't this add a needless cache? 0 is cached in the inode itself,
>isn't it? (and can be waste small fatent cache slots?)
>
This is mostly for caching the number of contiguous clusters starting
from 0. i_start only really tells us the first cluster of the file. I'm
not exactly sure of the best way to approach this, though. I guess we
can skip caching when its a one cluster range in this case?
What do you think?
>> }
>>
>> + fcluster = *fclus;
>> + dcluster = *dclus;
>> fatent_init(&fatent);
>> - while (*fclus < cluster) {
>> + while (fcluster < last) {
>> + if (nr_cont && fcluster == cluster && cid.fcluster != -1) {
>
>cid.fcluster == -1 is possible with this patch?
>
Good catch.
>> + fcluster = min(last, cid.fcluster + cid.nr_contig);
>> + dcluster = cid.dcluster + fcluster - cid.fcluster;
>> + if (fcluster == last)
>> + break;
>> + }
>> +
Thanks,
Matheus
next prev parent reply other threads:[~2026-11-12 4:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 16:43 [RFC PATCH 0/8] fat: convert to iomap Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 1/8] fat: support FIEMAP Matheus Alves de Almeida
2026-11-08 14:51 ` OGAWA Hirofumi
2026-11-12 4:09 ` Matheus Alves de Almeida [this message]
2026-11-12 5:03 ` OGAWA Hirofumi
2026-10-31 16:43 ` [RFC PATCH 2/8] fat: use iomap for ->bmap() Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 3/8] fat: add iomap direct I/O support Matheus Alves de Almeida
2026-11-08 14:56 ` OGAWA Hirofumi
2026-11-12 4:18 ` Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 4/8] fat: clean stale bdev buffers of newly allocated clusters Matheus Alves de Almeida
2026-11-08 14:57 ` OGAWA Hirofumi
2026-11-12 4:22 ` Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 5/8] fat: drop ->write_begin() and ->write_end() usage from fat_cont_expand() Matheus Alves de Almeida
2026-11-08 14:59 ` OGAWA Hirofumi
2026-11-12 4:26 ` Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 6/8] fat: add iomap buffered I/O support Matheus Alves de Almeida
2026-11-08 15:03 ` OGAWA Hirofumi
2026-11-12 4:35 ` Matheus Alves de Almeida
2026-11-12 5:06 ` OGAWA Hirofumi
2026-10-31 16:43 ` [RFC PATCH 7/8] fat: remove ->mmu_private Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 8/8] fat: add multi-cluster allocation for write Matheus Alves de Almeida
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=avU3IRmswObU2pH6@DESKTOP-PJTTJ93.localdomain \
--to=matheus.aalmeida@inf.ufrgs.br \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®