linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: daejun7.park@samsung.com,
	"jaegeuk@kernel.org" <jaegeuk@kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Nayeon Kim <nayeoni.kim@samsung.com>,
	Siwoo Jung <siu.jung@samsung.com>,
	Seokhwan Kim <sukka.kim@samsung.com>,
	Jeuk Kim <jeuk20.kim@samsung.com>,
	Dongjin Kim <dongjin_.kim@samsung.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid unused block when dio write in LFS mode
Date: Wed, 14 Aug 2024 17:50:07 +0800	[thread overview]
Message-ID: <7860b050-3948-4e23-b40f-a3df522477cd@kernel.org> (raw)
In-Reply-To: <20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b@epcms2p7>

On 2024/8/1 15:47, Daejun Park wrote:
> This patch addresses the problem that when using LFS mode, unused blocks
> may occur in f2fs_map_blocks() during block allocation for dio writes.
> 
> If a new section is allocated during block allocation, it will not be
> included in the map struct by map_is_mergeable() if the LBA of the

I didn't get it, why below condition in map_is_mergeable() can not catch this
case? Can you please explain more?

	if (map->m_pblk != NEW_ADDR && blkaddr == (map->m_pblk + ofs))
		return true;

Thanks,

> allocated block is not contiguous. However, the block already allocated
> in this process will remain unused due to the LFS mode.
> 
> This patch avoids the possibility of unused blocks by escaping
> f2fs_map_blocks() when allocating the last block in a section.
> 
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> ---
>   fs/f2fs/data.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index b6dcb3bcaef7..b27a3f448f32 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1711,6 +1711,19 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
>   		dn.ofs_in_node = end_offset;
>   	}
>   
> +	if (flag == F2FS_GET_BLOCK_DIO && f2fs_lfs_mode(sbi)) {
> +		int segno = GET_SEGNO(sbi, blkaddr);
> +		bool last_seg, last_blk;
> +
> +		last_seg = !((segno + 1) % SEGS_PER_SEC(sbi));
> +		last_blk = (f2fs_usable_blks_in_seg(sbi, segno) - 1) ==
> +				GET_BLKOFF_FROM_SEG0(sbi, blkaddr);
> +
> +		/* LBA of the next block to be allocated may not be contiguous. */
> +		if (last_seg && last_blk)
> +			goto sync_out;
> +	}
> +
>   	if (pgofs >= end)
>   		goto sync_out;
>   	else if (dn.ofs_in_node < end_offset)



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

  reply	other threads:[~2024-08-14  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b@epcms2p7>
2024-08-01  7:47 ` [f2fs-dev] [PATCH] f2fs: avoid unused block when dio write in LFS mode Daejun Park
2024-08-14  9:50   ` Chao Yu [this message]
     [not found]   ` <CGME20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b@epcms2p3>
2024-08-16  0:17     ` [f2fs-dev] (2) " Daejun Park
2024-08-16  1:56       ` Chao Yu
     [not found]       ` <CGME20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b@epcms2p6>
2024-08-16  3:36         ` [f2fs-dev] (2) " Daejun Park

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=7860b050-3948-4e23-b40f-a3df522477cd@kernel.org \
    --to=chao@kernel.org \
    --cc=daejun7.park@samsung.com \
    --cc=dongjin_.kim@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=jeuk20.kim@samsung.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nayeoni.kim@samsung.com \
    --cc=siu.jung@samsung.com \
    --cc=sukka.kim@samsung.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;
as well as URLs for NNTP newsgroup(s).