All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Yongpeng Yang <yangyongpeng.storage@gmail.com>,
	Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Yongpeng Yang <yangyongpeng@xiaomi.com>,
	Yongpeng Yang <monty_pavel@sina.com>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH RESEND 3/5] f2fs: punch largest extent instead of dropping it entirely on overlap
Date: Mon, 15 Jun 2026 20:05:25 +0800	[thread overview]
Message-ID: <b380cd69-66db-4ef1-8d33-92ed6c34d263@kernel.org> (raw)
In-Reply-To: <20260612115839.2065903-4-yangyongpeng.storage@gmail.com>

On 6/12/26 19:58, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
> 
> Previously, when an extent being inserted overlaps with the largest
> extent, the largest extent is dropped entirely. This was done to handle

Please correct me if I missed anything, I remember that we will add largest
extent in below path?

- __update_extent_tree_range
 - __insert_extent_tree
  - __try_update_largest_extent : update largest w/ right extent
 - __try_update_largest_extent : update largest w/ left extent

Thanks,

> the case where the largest extent is not in memory, avoiding
> inconsistency between the largest extent and the extent tree.
> 
> This patch changes the semantics of __drop_largest_extent (renamed to
> __punch_largest_extent): instead of discarding the entire largest
> extent when any overlap is detected, keep the larger remaining portion
> (left or right) after the punch. This preserves extent cache coverage
> for truncate and overwrite operations that only partially overlap the
> largest extent.
> 
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
> ---
>  fs/f2fs/extent_cache.c | 31 ++++++++++++++++++++++++-------
>  1 file changed, 24 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
> index f8d94db60dc6..82d84c4e98b2 100644
> --- a/fs/f2fs/extent_cache.c
> +++ b/fs/f2fs/extent_cache.c
> @@ -397,14 +397,31 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi,
>  	return count;
>  }
>  
> -static void __drop_largest_extent(struct extent_tree *et,
> +static void __punch_largest_extent(struct extent_tree *et,
>  					pgoff_t fofs, unsigned int len)
>  {
> -	if (fofs < (pgoff_t)et->largest.fofs + et->largest.len &&
> -			fofs + len > et->largest.fofs) {
> -		et->largest.len = 0;
> -		et->largest_updated = true;
> +	unsigned int largest_end, punch_end;
> +	unsigned int left_len, right_len;
> +
> +	if (fofs >= (pgoff_t)et->largest.fofs + et->largest.len ||
> +			fofs + len <= et->largest.fofs)
> +		return;
> +
> +	/* Punch [fofs, fofs + len) from largest extent. */
> +	largest_end = et->largest.fofs + et->largest.len;
> +	punch_end = fofs + len;
> +
> +	left_len = fofs > et->largest.fofs ? fofs - et->largest.fofs : 0;
> +	right_len = largest_end > punch_end ? largest_end - punch_end : 0;
> +
> +	if (left_len >= right_len) {
> +		et->largest.len = left_len;
> +	} else {
> +		et->largest.blk += punch_end - et->largest.fofs;
> +		et->largest.fofs = punch_end;
> +		et->largest.len = right_len;
>  	}
> +	et->largest_updated = true;
>  }
>  
>  void f2fs_init_read_extent_tree(struct inode *inode, struct folio *ifolio)
> @@ -680,10 +697,10 @@ static void __update_extent_tree_range(struct inode *inode,
>  		dei.len = 0;
>  
>  		/*
> -		 * drop largest extent before lookup, in case it's already
> +		 * punch largest extent before lookup, in case it's already
>  		 * been shrunk from extent tree
>  		 */
> -		__drop_largest_extent(et, fofs, len);
> +		__punch_largest_extent(et, fofs, len);
>  	}
>  
>  	if (et->largest.len != 0 &&



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2026-06-15 12:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12 11:58 [f2fs-dev] [PATCH RESEND 1/5] f2fs: fix extent merge failure when largest extent is not in rb-tree Yongpeng Yang
2026-06-12 11:58 ` [f2fs-dev] [PATCH RESEND 2/5] f2fs: only initialize largest extent without extent_node at inode init Yongpeng Yang
2026-06-15 11:55   ` Chao Yu via Linux-f2fs-devel
2026-06-12 11:58 ` [f2fs-dev] [PATCH RESEND 3/5] f2fs: punch largest extent instead of dropping it entirely on overlap Yongpeng Yang
2026-06-15 12:05   ` Chao Yu via Linux-f2fs-devel [this message]
2026-06-12 11:58 ` [f2fs-dev] [PATCH RESEND 4/5] f2fs: add extent_access_mode to track extent cache access patterns Yongpeng Yang
2026-06-15 12:05   ` Chao Yu via Linux-f2fs-devel
2026-06-12 11:58 ` [f2fs-dev] [PATCH RESEND 5/5] f2fs: add ioctl to export read extent cache to userspace for debug Yongpeng Yang
2026-06-15 12:20   ` Chao Yu via Linux-f2fs-devel
2026-06-15 15:51     ` Jaegeuk Kim via Linux-f2fs-devel
2026-06-15 11:26 ` [f2fs-dev] [PATCH RESEND 1/5] f2fs: fix extent merge failure when largest extent is not in rb-tree Chao Yu via Linux-f2fs-devel

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=b380cd69-66db-4ef1-8d33-92ed6c34d263@kernel.org \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=monty_pavel@sina.com \
    --cc=yangyongpeng.storage@gmail.com \
    --cc=yangyongpeng@xiaomi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.