The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhiguo Niu <zhiguo.niu@unisoc.com>, jaegeuk@kernel.org
Cc: Chao Yu <chao@kernel.org>,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com,
	ke.wang@unisoc.com, Hao_hao.Wang@unisoc.com
Subject: Re: [PATCH 2/2] f2fs: fix to adjust appropriate length for fiemap
Date: Fri, 1 Nov 2024 10:36:05 +0800	[thread overview]
Message-ID: <bf348748-46ba-47dd-a12d-5111be2df95e@kernel.org> (raw)
In-Reply-To: <1730354393-19672-2-git-send-email-zhiguo.niu@unisoc.com>

On 2024/10/31 13:59, Zhiguo Niu wrote:
> If user give a file size as "length" parameter for fiemap
> operations, but this size is non-block size aligned,
> it will show 2 segments fiemap results even this whole file
> is contiguous on disk, such as the following results, please
> note that this f2fs_io has been modified for testing.
> 
>   ./f2fs_io fiemap 0 19304 ylog/analyzer.py
> Fiemap: offset = 0 len = 19304
>          logical addr.    physical addr.   length           flags
> 0       0000000000000000 0000000020baa000 0000000000004000 00001000
> 1       0000000000004000 0000000020bae000 0000000000001000 00001001
> 
> after this patch:
>   ./f2fs_io fiemap 0 19304 ylog/analyzer.py
> Fiemap: offset = 0 len = 19304
> 	logical addr.    physical addr.   length           flags
> 0	0000000000000000 00000000315f3000 0000000000005000 00001000

Why is FIEMAP_EXTENT_LAST missing in #0 extent? As we can see it
in #1 extent before your change.

1       0000000000004000 0000000020bae000 0000000000001000 00001001

Thanks,

> 
> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> ---
> f2fs_io has been modified for testing, the length for fiemap is
> real file size, not block number
> ---
>   fs/f2fs/data.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 90fa8ab..8c9bb42 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1966,8 +1966,8 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>   			goto out;
>   	}
>   
> -	if (bytes_to_blks(inode, len) == 0)
> -		len = blks_to_bytes(inode, 1);
> +	if (len & (blks_to_bytes(inode, 1) - 1))
> +		len = round_up(len, blks_to_bytes(inode, 1));
>   
>   	start_blk = bytes_to_blks(inode, start);
>   	last_blk = bytes_to_blks(inode, start + len - 1);


  reply	other threads:[~2024-11-01  2:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31  5:59 [PATCH 1/2] f2fs: remove redundant atomic file check in defragment Zhiguo Niu
2024-10-31  5:59 ` [PATCH 2/2] f2fs: fix to adjust appropriate length for fiemap Zhiguo Niu
2024-11-01  2:36   ` Chao Yu [this message]
2024-11-01  3:27     ` Zhiguo Niu
2024-11-01  5:48       ` Zhiguo Niu
2024-11-01  8:00     ` Zhiguo Niu
2024-10-31  7:52 ` [f2fs-dev] [PATCH 1/2] f2fs: remove redundant atomic file check in defragment Chao Yu
2024-11-07 20:30 ` patchwork-bot+f2fs

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=bf348748-46ba-47dd-a12d-5111be2df95e@kernel.org \
    --to=chao@kernel.org \
    --cc=Hao_hao.Wang@unisoc.com \
    --cc=jaegeuk@kernel.org \
    --cc=ke.wang@unisoc.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niuzhiguo84@gmail.com \
    --cc=zhiguo.niu@unisoc.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