mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sungjong Seo <sj1557.seo@samsung.com>
To: Chi Zhiling <chizhiling@163.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Matthew Wilcox <willy@infradead.org>,
	Namjae Jeon <linkinjeon@kernel.org>,
	Yuezhang Mo <yuezhang.mo@sony.com>,
	Chi Zhiling <chizhiling@kylinos.cn>,
	Sungjong Seo <sj1557.seo@samsung.com>
Subject: Re: [RFC PATCH 7/7] exfat: get mutil-clusters in exfat_get_block
Date: Fri, 28 Nov 2025 11:48:58 +0900	[thread overview]
Message-ID: <5db1b061-56ef-4013-9d1e-aac04175aa8d@samsung.com> (raw)
In-Reply-To: <20251118082208.1034186-8-chizhiling@163.com>


Hi, Chi,
On 25. 11. 18. 17:22, Chi Zhiling wrote:
> From: Chi Zhiling <chizhiling@kylinos.cn>
> 
> 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.

I think reusing buffer_head is a good approach!
However, for obtaining multiple clusters, it would be better to handle
them in exfat_map_cluster.

> 
> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
> ---
>  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, unsigned 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 = EXFAT_I(inode);
>  	struct super_block *sb = inode->i_sb;
>  	struct exfat_sb_info *sbi = EXFAT_SB(sb);
>  	unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
>  	int err = 0;
>  	unsigned long mapped_blocks = 0;
> -	unsigned int cluster, sec_offset;
> +	unsigned int cluster, sec_offset, count;
>  	sector_t last_block;
>  	sector_t phys = 0;
>  	sector_t valid_blks;
> @@ -301,6 +302,17 @@ static int exfat_get_block(struct inode *inode, sector_t iblock,
>  
>  	phys = exfat_cluster_to_sector(sbi, cluster) + sec_offset;
>  	mapped_blocks = sbi->sect_per_clus - sec_offset;
> +
> +	if (max_blocks > mapped_blocks && !create) {
> +		chain.dir = cluster;
> +		chain.size = (max_blocks >> sbi->sect_per_clus_bits) + 1;

There seems to be an issue where the code sets chain.size to be one greater than the actual cluster count.

For example, assuming a 16KiB page, 512B sector, and 4KiB cluster,
for a 16KiB file, chain.size becomes 5 instead of 4.
Is this the intended behavior?

> +		chain.flags = ei->flags;
> +
> +		err = exfat_count_contig_clusters(sb, &chain, &count);
> +		if (err)
> +			return err;
> +		max_blocks = (count << sbi->sect_per_clus_bits) - sec_offset;

You already said mapped_blocks is correct.

> +	}
>  	max_blocks = min(mapped_blocks, max_blocks);
>  
>  	map_bh(bh_result, sb, phys);


  reply	other threads:[~2025-11-28  2:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18  8:22 [RFC PATCH 0/7] Enable exfat_get_block to support obtaining multiple clusters Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 1/7] exfat: add cache option for __exfat_ent_get Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 2/7] exfat: support reuse buffer head for exfat_ent_get Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 3/7] exfat: reuse cache to improve exfat_get_cluster Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 4/7] exfat: improve exfat_count_num_clusters Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 5/7] exfat: improve exfat_find_last_cluster Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 6/7] exfat: introduce exfat_count_contig_clusters Chi Zhiling
2025-11-28 11:09   ` Yuezhang.Mo
2025-11-29  1:56     ` Chi Zhiling
2025-11-18  8:22 ` [RFC PATCH 7/7] exfat: get mutil-clusters in exfat_get_block Chi Zhiling
2025-11-28  2:48   ` Sungjong Seo [this message]
2025-11-28  6:18     ` Chi Zhiling
2025-12-04 12:18       ` Sungjong Seo
2025-12-05 11:36         ` Chi Zhiling
2025-11-21  1:17 ` [RFC PATCH 0/7] Enable exfat_get_block to support obtaining multiple clusters Namjae Jeon
2025-11-21  5:51   ` Chi Zhiling

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=5db1b061-56ef-4013-9d1e-aac04175aa8d@samsung.com \
    --to=sj1557.seo@samsung.com \
    --cc=brauner@kernel.org \
    --cc=chizhiling@163.com \
    --cc=chizhiling@kylinos.cn \
    --cc=jack@suse.cz \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=yuezhang.mo@sony.com \
    /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®