public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Zhang Yi <yi.zhang@huaweicloud.com>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
	ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org,
	willy@infradead.org, yi.zhang@huawei.com,
	chengzhihao1@huawei.com, yukuai3@huawei.com,
	wangkefeng.wang@huawei.com
Subject: Re: [RFC PATCH v2 05/25] ext4: make ext4_map_blocks() distinguish delalloc only extent
Date: Wed, 3 Jan 2024 12:31:31 +0100	[thread overview]
Message-ID: <20240103113131.z4jhwim7bzynhrlx@quack3> (raw)
In-Reply-To: <20240102123918.799062-6-yi.zhang@huaweicloud.com>

On Tue 02-01-24 20:38:58, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> Add a new map flag EXT4_MAP_DELAYED to indicate the mapping range is a
> delayed allocated only (not unwritten) one, and making
> ext4_map_blocks() can distinguish it, no longer mixing it with holes.
> 
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>

One small comment below.

> ---
>  fs/ext4/ext4.h    | 4 +++-
>  fs/ext4/extents.c | 5 +++--
>  fs/ext4/inode.c   | 2 ++
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index a5d784872303..55195909d32f 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -252,8 +252,10 @@ struct ext4_allocation_request {
>  #define EXT4_MAP_MAPPED		BIT(BH_Mapped)
>  #define EXT4_MAP_UNWRITTEN	BIT(BH_Unwritten)
>  #define EXT4_MAP_BOUNDARY	BIT(BH_Boundary)
> +#define EXT4_MAP_DELAYED	BIT(BH_Delay)
>  #define EXT4_MAP_FLAGS		(EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
> -				 EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY)
> +				 EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\
> +				 EXT4_MAP_DELAYED)
>  
>  struct ext4_map_blocks {
>  	ext4_fsblk_t m_pblk;
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 0892d0568013..fc69f13cf510 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4073,9 +4073,10 @@ static void ext4_ext_determine_hole(struct inode *inode,
>  	} else if (in_range(map->m_lblk, es.es_lblk, es.es_len)) {
>  		/*
>  		 * Straddle the beginning of the queried range, it's no
> -		 * longer a hole, adjust the length to the delayed extent's
> -		 * after map->m_lblk.
> +		 * longer a hole, mark it is a delalloc and adjust the
> +		 * length to the delayed extent's after map->m_lblk.
>  		 */
> +		map->m_flags |= EXT4_MAP_DELAYED;

I wouldn't set delalloc bit here. If there's delalloc extent containing
lblk now, it means the caller of ext4_map_blocks() is not holding i_rwsem
(otherwise we would have found already in ext4_map_blocks()) and thus
delalloc info is unreliable anyway. So I wouldn't bother. But it's worth a
comment here like:

		/*
		 * There's delalloc extent containing lblk. It must have
		 * been added after ext4_map_blocks() checked the extent
		 * status tree so we are not holding i_rwsem and delalloc
		 * info is only stabilized by i_data_sem we are going to
		 * release soon. Don't modify the extent status tree and
		 * report extent as a hole.
		 */

								Honza

>  		len = es.es_lblk + es.es_len - map->m_lblk;
>  		goto out;
>  	} else {
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 1b5e6409f958..c141bf6d8db2 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -515,6 +515,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
>  			map->m_len = retval;
>  		} else if (ext4_es_is_delayed(&es) || ext4_es_is_hole(&es)) {
>  			map->m_pblk = 0;
> +			map->m_flags |= ext4_es_is_delayed(&es) ?
> +					EXT4_MAP_DELAYED : 0;
>  			retval = es.es_len - (map->m_lblk - es.es_lblk);
>  			if (retval > map->m_len)
>  				retval = map->m_len;
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2024-01-03 11:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 12:38 [RFC PATCH v2 00/25] ext4: use iomap for regular file's buffered IO path and enable large foilo Zhang Yi
2024-01-02 12:38 ` [RFC PATCH v2 01/25] ext4: refactor ext4_da_map_blocks() Zhang Yi
2024-01-03  9:56   ` Jan Kara
2024-01-02 12:38 ` [RFC PATCH v2 02/25] ext4: convert to exclusive lock while inserting delalloc extents Zhang Yi
2024-01-03 10:03   ` Jan Kara
2024-01-02 12:38 ` [RFC PATCH v2 03/25] ext4: correct the hole length returned by ext4_map_blocks() Zhang Yi
2024-01-03 11:02   ` Jan Kara
2024-01-02 12:38 ` [RFC PATCH v2 04/25] ext4: add a hole extent entry in cache after punch Zhang Yi
2024-01-03 11:04   ` Jan Kara
2024-01-02 12:38 ` [RFC PATCH v2 05/25] ext4: make ext4_map_blocks() distinguish delalloc only extent Zhang Yi
2024-01-03 11:31   ` Jan Kara [this message]
2024-01-03 13:20     ` Zhang Yi
2024-01-02 12:38 ` [RFC PATCH v2 06/25] ext4: make ext4_set_iomap() recognize IOMAP_DELALLOC map type Zhang Yi
2024-01-03 11:35   ` Jan Kara
2024-01-02 12:39 ` [RFC PATCH v2 07/25] iomap: don't increase i_size if it's not a write operation Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 08/25] iomap: add pos and dirty_len into trace_iomap_writepage_map Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 09/25] ext4: allow inserting delalloc extents with multi-blocks Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 10/25] ext4: correct delalloc extent length Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 11/25] ext4: also mark extent as delalloc if it's been unwritten Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 12/25] ext4: factor out bh handles to ext4_da_get_block_prep() Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 13/25] ext4: use reserved metadata blocks when splitting extent in endio Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 14/25] ext4: introduce seq counter for extent entry Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 15/25] ext4: add a new iomap aops for regular file's buffered IO path Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 16/25] ext4: implement buffered read iomap path Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 17/25] ext4: implement buffered write " Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 18/25] ext4: implement writeback " Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 19/25] ext4: implement mmap " Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 20/25] ext4: implement zero_range " Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 21/25] ext4: writeback partial blocks before zero range Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 22/25] ext4: fall back to buffer_head path for defrag Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 23/25] ext4: partially enable iomap for regular file's buffered IO path Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 24/25] filemap: support disable large folios on active inode Zhang Yi
2024-01-02 12:39 ` [RFC PATCH v2 25/25] ext4: enable large folio for regular file with iomap buffered IO path Zhang Yi

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=20240103113131.z4jhwim7bzynhrlx@quack3 \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=chengzhihao1@huawei.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=yi.zhang@huawei.com \
    --cc=yi.zhang@huaweicloud.com \
    --cc=yukuai3@huawei.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