Message ID | 20230405144359.930253-1-chao@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp444903vqo; Wed, 5 Apr 2023 09:41:41 -0700 (PDT) X-Google-Smtp-Source: AKy350YGISXTkQ6InxLX90kDI+oDweF79KVgc8IbRU7JeycJ+LMfRQ7rtqceehHBOu8FWDWvotFB X-Received: by 2002:a17:903:1c3:b0:1a1:956e:5417 with SMTP id e3-20020a17090301c300b001a1956e5417mr7884039plh.22.1680712900903; Wed, 05 Apr 2023 09:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680712900; cv=none; d=google.com; s=arc-20160816; b=r+G1jwnFU55v2b4mt/Ov5AyL+lPKE7k4d+/JJ8q3CBds6WFRgvOsnweXywPesCpOXy 8PDJkA9lyB+kWO7+r2A2QtWPDBGTFUo10OH4Xhp3ZTL1xApwIPeABx+9sCZgi/CTzMmu 0hgJyMszUaBbVrw0yW0ge0Oeyh2oZ6HUZCgq6e5pGr/re/GgPhknH2onLJBcsXF5Z4yi PQwZPB2ovgYq7op7NynFGRoJqC0gqRvnCzO5eBwzy4RcgCWZ1MhIBkm7fGIjaANANFsp v+rTEK+ZKqoxL3u5swYto2s9jTQKoOytxfZayQsLgPgbDwn+GRVtN6NTf/TJoDWlQ4M1 HthQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1KHuoOHO4Pp4VgnkuM2R0x0IoDrKVIg9RgiS8cWT1qw=; b=i0xdvZJrgINC/yLJHPrbcYiZhSdYd5/U+NfSi7VVVHQ/ZkiMpm+WL1PUSR6j+jAu0a fx57ySOx5yht4TF5R0X4/ACRn13U5k8BGPq+kuol7XWx0csSWounlXLXgZYGs2aixn2W Kvcu9xUZrIK3MlMAEZB9omYDK7jZqJpFvRqzwVpeu18zzArZZoKsgpSHf8yUr1AhR4lA /bZpoBEdNIe2Bb4+pz9Q2vYOZSRkflrmrTafGeYmP3kMbQxiPqMMWQFYoDG4PHeVUrMD cmJu8QwIOp/PdHwwjrQSEKylI00nz0sK6Vh7gIklJeXyn9kz2TEDaeE2uh83ZvJ0solX RTFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DSOaLTHW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t1-20020a170902e84100b0019ad22c40c7si13391019plg.132.2023.04.05.09.41.28; Wed, 05 Apr 2023 09:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DSOaLTHW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbjDEQVp (ORCPT <rfc822;lkml4gm@gmail.com> + 99 others); Wed, 5 Apr 2023 12:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbjDEQVn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 5 Apr 2023 12:21:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B0A7689 for <linux-kernel@vger.kernel.org>; Wed, 5 Apr 2023 09:21:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 172F163F87 for <linux-kernel@vger.kernel.org>; Wed, 5 Apr 2023 16:21:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACCDBC433EF; Wed, 5 Apr 2023 16:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680711660; bh=GzJotDDyx4YLgFNr3TBry5o3drZWZVKpvv5e3qKlLUQ=; h=From:To:Cc:Subject:Date:From; b=DSOaLTHWUE4O2oIJGxfOpv2NKBLHCKFSXvv6mQCkqTsX3FMjQgDSazRsx67j1FA6k 6iQlM6slmxke4aiKaIHdPDSFYDqq559jMGPHwrw7a0OVco7dv4D7moVwcxTpFRiDl0 DLMpCIQUQPV/sD6QmYE7DOwWWIW9cDecpS0E606XkLdSfcrmJ8yb4KgI7QQbJllxu0 JBWz2RVtA1AKHtUe0AdggOim/K4/e+VikwPbI2gFsZXhGm9SlJVWuZGidmhScvMWS5 DH6Hoc80zXsaW5cHiqkmKWfxiM1qS+fHUJvMezK3TlBRrEEhU+xFmI8u3nLGLsQBqP HK/pIreXffQtQ== From: Chao Yu <chao@kernel.org> To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org> Subject: [PATCH] f2fs: fix to tag FIEMAP_EXTENT_DELALLOC in fiemap() for delay allocated extent Date: Wed, 5 Apr 2023 22:43:59 +0800 Message-Id: <20230405144359.930253-1-chao@kernel.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762355210861563399?= X-GMAIL-MSGID: =?utf-8?q?1762355210861563399?= |
Series |
f2fs: fix to tag FIEMAP_EXTENT_DELALLOC in fiemap() for delay allocated extent
|
|
Commit Message
Chao Yu
April 5, 2023, 2:43 p.m. UTC
xfstest generic/614 fails to run due below reason:
generic/614 1s ... [not run] test requires delayed allocation buffered writes
The root cause is f2fs tags wrong fiemap flag for delay allocated
extent.
Quoted from fiemap.h:
FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
* Sets EXTENT_UNKNOWN. */
FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
* no data (i.e. zero). */
FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o
been written any data, which status f2fs is not supported now, for all
NEW_ADDR block addresses, it means delay allocated blocks, so let's
tag FIEMAP_EXTENT_DELALLOC instead.
Testcase:
xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file;
filefrag -v /mnt/f2fs/file
Output:
- Before
Filesystem type is: f2f52010
Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof
/mnt/f2fs/file: 1 extent found
After:
Filesystem type is: f2f52010
File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof
/mnt/f2fs/file: 1 extent found
Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap")
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/data.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Comments
This breaks generic/009? On 04/05, Chao Yu wrote: > xfstest generic/614 fails to run due below reason: > > generic/614 1s ... [not run] test requires delayed allocation buffered writes > > The root cause is f2fs tags wrong fiemap flag for delay allocated > extent. > > Quoted from fiemap.h: > FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ > FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. > * Sets EXTENT_UNKNOWN. */ > FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but > * no data (i.e. zero). */ > > FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o > been written any data, which status f2fs is not supported now, for all > NEW_ADDR block addresses, it means delay allocated blocks, so let's > tag FIEMAP_EXTENT_DELALLOC instead. > > Testcase: > xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; > filefrag -v /mnt/f2fs/file > > Output: > - Before > Filesystem type is: f2f52010 > Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) > ext: logical_offset: physical_offset: length: expected: flags: > 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof > /mnt/f2fs/file: 1 extent found > > After: > Filesystem type is: f2f52010 > File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) > ext: logical_offset: physical_offset: length: expected: flags: > 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof > /mnt/f2fs/file: 1 extent found > > Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/data.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 359de650772e..3afc9764743e 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > } > > if (size) { > - flags |= FIEMAP_EXTENT_MERGED; > + if (flags & FIEMAP_EXTENT_DELALLOC) > + phys = 0; > + else > + flags |= FIEMAP_EXTENT_MERGED; > if (IS_ENCRYPTED(inode)) > flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; > > @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > size += blks_to_bytes(inode, 1); > } > } else if (map.m_flags & F2FS_MAP_DELALLOC) { > - flags = FIEMAP_EXTENT_UNWRITTEN; > + flags = FIEMAP_EXTENT_DELALLOC; > } > > start_blk += bytes_to_blks(inode, size); > -- > 2.36.1
On 2023/4/8 4:59, Jaegeuk Kim wrote: > This breaks generic/009? I guess it is as expected? Please check description of fiemap ioctl manual from [1]: FIEMAP_EXTENT_UNKNOWN The location of this extent is currently unknown. This may indicate the data is stored on an inaccessible volume or that no storage has been allocated for the file yet. FIEMAP_EXTENT_DELALLOC This will also set FIEMAP_EXTENT_UNKNOWN. Delayed allocation - while there is data for this extent, its physical location has not been allocated yet. FIEMAP_EXTENT_UNWRITTEN Unwritten extent - the extent is allocated but its data has not been initialized. This indicates the extent’s data will be all zero if read through the filesystem but the contents are undefined if read directly from the device. [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html According to its description, f2fs only support FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support FIEMAP_EXTENT_UNWRITTEN. So 009, 092, 094 .. which expects unwritten status from extent will fail. How about disabling those testcase? Thanks, > > On 04/05, Chao Yu wrote: >> xfstest generic/614 fails to run due below reason: >> >> generic/614 1s ... [not run] test requires delayed allocation buffered writes >> >> The root cause is f2fs tags wrong fiemap flag for delay allocated >> extent. >> >> Quoted from fiemap.h: >> FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ >> FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. >> * Sets EXTENT_UNKNOWN. */ >> FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but >> * no data (i.e. zero). */ >> >> FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o >> been written any data, which status f2fs is not supported now, for all >> NEW_ADDR block addresses, it means delay allocated blocks, so let's >> tag FIEMAP_EXTENT_DELALLOC instead. >> >> Testcase: >> xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; >> filefrag -v /mnt/f2fs/file >> >> Output: >> - Before >> Filesystem type is: f2f52010 >> Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >> ext: logical_offset: physical_offset: length: expected: flags: >> 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof >> /mnt/f2fs/file: 1 extent found >> >> After: >> Filesystem type is: f2f52010 >> File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >> ext: logical_offset: physical_offset: length: expected: flags: >> 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof >> /mnt/f2fs/file: 1 extent found >> >> Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/data.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >> index 359de650772e..3afc9764743e 100644 >> --- a/fs/f2fs/data.c >> +++ b/fs/f2fs/data.c >> @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >> } >> >> if (size) { >> - flags |= FIEMAP_EXTENT_MERGED; >> + if (flags & FIEMAP_EXTENT_DELALLOC) >> + phys = 0; >> + else >> + flags |= FIEMAP_EXTENT_MERGED; >> if (IS_ENCRYPTED(inode)) >> flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; >> >> @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >> size += blks_to_bytes(inode, 1); >> } >> } else if (map.m_flags & F2FS_MAP_DELALLOC) { >> - flags = FIEMAP_EXTENT_UNWRITTEN; >> + flags = FIEMAP_EXTENT_DELALLOC; >> } >> >> start_blk += bytes_to_blks(inode, size); >> -- >> 2.36.1
On 04/08, Chao Yu wrote: > On 2023/4/8 4:59, Jaegeuk Kim wrote: > > This breaks generic/009? > > I guess it is as expected? > > Please check description of fiemap ioctl manual from [1]: > > FIEMAP_EXTENT_UNKNOWN > The location of this extent is currently unknown. This may > indicate the data is stored on an inaccessible volume or that > no storage has been allocated for the file yet. > > FIEMAP_EXTENT_DELALLOC > This will also set FIEMAP_EXTENT_UNKNOWN. > > Delayed allocation - while there is data for this extent, its > physical location has not been allocated yet. > > FIEMAP_EXTENT_UNWRITTEN > Unwritten extent - the extent is allocated but its data has not > been initialized. This indicates the extent’s data will be all > zero if read through the filesystem but the contents are undefined > if read directly from the device. > > [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html > > According to its description, f2fs only support > FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support > FIEMAP_EXTENT_UNWRITTEN. No, I don't think so. > > So 009, 092, 094 .. which expects unwritten status from extent will > fail. > > How about disabling those testcase? > > Thanks, > > > > > On 04/05, Chao Yu wrote: > > > xfstest generic/614 fails to run due below reason: > > > > > > generic/614 1s ... [not run] test requires delayed allocation buffered writes > > > > > > The root cause is f2fs tags wrong fiemap flag for delay allocated > > > extent. > > > > > > Quoted from fiemap.h: > > > FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ > > > FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. > > > * Sets EXTENT_UNKNOWN. */ > > > FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but > > > * no data (i.e. zero). */ > > > > > > FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o > > > been written any data, which status f2fs is not supported now, for all > > > NEW_ADDR block addresses, it means delay allocated blocks, so let's > > > tag FIEMAP_EXTENT_DELALLOC instead. > > > > > > Testcase: > > > xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; > > > filefrag -v /mnt/f2fs/file > > > > > > Output: > > > - Before > > > Filesystem type is: f2f52010 > > > Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) > > > ext: logical_offset: physical_offset: length: expected: flags: > > > 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof > > > /mnt/f2fs/file: 1 extent found > > > > > > After: > > > Filesystem type is: f2f52010 > > > File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) > > > ext: logical_offset: physical_offset: length: expected: flags: > > > 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof > > > /mnt/f2fs/file: 1 extent found > > > > > > Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") > > > Signed-off-by: Chao Yu <chao@kernel.org> > > > --- > > > fs/f2fs/data.c | 7 +++++-- > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > > index 359de650772e..3afc9764743e 100644 > > > --- a/fs/f2fs/data.c > > > +++ b/fs/f2fs/data.c > > > @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > > > } > > > if (size) { > > > - flags |= FIEMAP_EXTENT_MERGED; > > > + if (flags & FIEMAP_EXTENT_DELALLOC) > > > + phys = 0; > > > + else > > > + flags |= FIEMAP_EXTENT_MERGED; > > > if (IS_ENCRYPTED(inode)) > > > flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; > > > @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > > > size += blks_to_bytes(inode, 1); > > > } > > > } else if (map.m_flags & F2FS_MAP_DELALLOC) { > > > - flags = FIEMAP_EXTENT_UNWRITTEN; > > > + flags = FIEMAP_EXTENT_DELALLOC; > > > } > > > start_blk += bytes_to_blks(inode, size); > > > -- > > > 2.36.1
On 2023/4/11 1:57, Jaegeuk Kim wrote: > On 04/08, Chao Yu wrote: >> On 2023/4/8 4:59, Jaegeuk Kim wrote: >>> This breaks generic/009? >> >> I guess it is as expected? >> >> Please check description of fiemap ioctl manual from [1]: >> >> FIEMAP_EXTENT_UNKNOWN >> The location of this extent is currently unknown. This may >> indicate the data is stored on an inaccessible volume or that >> no storage has been allocated for the file yet. >> >> FIEMAP_EXTENT_DELALLOC >> This will also set FIEMAP_EXTENT_UNKNOWN. >> >> Delayed allocation - while there is data for this extent, its >> physical location has not been allocated yet. >> >> FIEMAP_EXTENT_UNWRITTEN >> Unwritten extent - the extent is allocated but its data has not >> been initialized. This indicates the extent’s data will be all >> zero if read through the filesystem but the contents are undefined >> if read directly from the device. >> >> [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html >> >> According to its description, f2fs only support >> FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support >> FIEMAP_EXTENT_UNWRITTEN. > > No, I don't think so. Jaegeuk, Could you please check the detailed description of FIEMAP_EXTENT_UNWRITTEN? The flag indicates two conditions: 1. on-disk blkaddrs were allocated for extent, and the extent is tagged as unwritten status. 2. data readed on those blocks will be all zero. So, let's check f2fs' status: - fallocate only reserve valid block count and set NEW_ADDR in dnode, so it does not match condition 1) - pin & fallocate preallocates blkaddrs and set blkaddrs in dnode, but content on those blkaddrs may contain zero or random data, so it does not match condition 2) Christoph describes this issue in below patch as well, you can check it. da8c7fecc9c7 ("f2fs: rename F2FS_MAP_UNWRITTEN to F2FS_MAP_DELALLOC") Am I missing something? Thanks, > >> >> So 009, 092, 094 .. which expects unwritten status from extent will >> fail. >> >> How about disabling those testcase? >> >> Thanks, >> >>> >>> On 04/05, Chao Yu wrote: >>>> xfstest generic/614 fails to run due below reason: >>>> >>>> generic/614 1s ... [not run] test requires delayed allocation buffered writes >>>> >>>> The root cause is f2fs tags wrong fiemap flag for delay allocated >>>> extent. >>>> >>>> Quoted from fiemap.h: >>>> FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ >>>> FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. >>>> * Sets EXTENT_UNKNOWN. */ >>>> FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but >>>> * no data (i.e. zero). */ >>>> >>>> FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o >>>> been written any data, which status f2fs is not supported now, for all >>>> NEW_ADDR block addresses, it means delay allocated blocks, so let's >>>> tag FIEMAP_EXTENT_DELALLOC instead. >>>> >>>> Testcase: >>>> xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; >>>> filefrag -v /mnt/f2fs/file >>>> >>>> Output: >>>> - Before >>>> Filesystem type is: f2f52010 >>>> Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>> ext: logical_offset: physical_offset: length: expected: flags: >>>> 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof >>>> /mnt/f2fs/file: 1 extent found >>>> >>>> After: >>>> Filesystem type is: f2f52010 >>>> File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>> ext: logical_offset: physical_offset: length: expected: flags: >>>> 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof >>>> /mnt/f2fs/file: 1 extent found >>>> >>>> Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") >>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>> --- >>>> fs/f2fs/data.c | 7 +++++-- >>>> 1 file changed, 5 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>> index 359de650772e..3afc9764743e 100644 >>>> --- a/fs/f2fs/data.c >>>> +++ b/fs/f2fs/data.c >>>> @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>> } >>>> if (size) { >>>> - flags |= FIEMAP_EXTENT_MERGED; >>>> + if (flags & FIEMAP_EXTENT_DELALLOC) >>>> + phys = 0; >>>> + else >>>> + flags |= FIEMAP_EXTENT_MERGED; >>>> if (IS_ENCRYPTED(inode)) >>>> flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; >>>> @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>> size += blks_to_bytes(inode, 1); >>>> } >>>> } else if (map.m_flags & F2FS_MAP_DELALLOC) { >>>> - flags = FIEMAP_EXTENT_UNWRITTEN; >>>> + flags = FIEMAP_EXTENT_DELALLOC; >>>> } >>>> start_blk += bytes_to_blks(inode, size); >>>> -- >>>> 2.36.1
On 2023/4/11 16:14, Chao Yu wrote: > On 2023/4/11 1:57, Jaegeuk Kim wrote: >> On 04/08, Chao Yu wrote: >>> On 2023/4/8 4:59, Jaegeuk Kim wrote: >>>> This breaks generic/009? >>> >>> I guess it is as expected? >>> >>> Please check description of fiemap ioctl manual from [1]: >>> >>> FIEMAP_EXTENT_UNKNOWN >>> The location of this extent is currently unknown. This may >>> indicate the data is stored on an inaccessible volume or that >>> no storage has been allocated for the file yet. >>> >>> FIEMAP_EXTENT_DELALLOC >>> This will also set FIEMAP_EXTENT_UNKNOWN. >>> >>> Delayed allocation - while there is data for this extent, its >>> physical location has not been allocated yet. >>> >>> FIEMAP_EXTENT_UNWRITTEN >>> Unwritten extent - the extent is allocated but its data has not >>> been initialized. This indicates the extent’s data will be all >>> zero if read through the filesystem but the contents are undefined >>> if read directly from the device. >>> >>> [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html >>> >>> According to its description, f2fs only support >>> FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support >>> FIEMAP_EXTENT_UNWRITTEN. >> >> No, I don't think so. > > Jaegeuk, > > Could you please check the detailed description of FIEMAP_EXTENT_UNWRITTEN? > The flag indicates two conditions: > 1. on-disk blkaddrs were allocated for extent, and the extent is tagged as > unwritten status. > 2. data readed on those blocks will be all zero. Sorry, I mean: 1. on-disk blkaddrs were allocated for extent; 2. extent is tagged as unwritten status, data readed on those blocks will be all zero. Thanks, > > So, let's check f2fs' status: > - fallocate only reserve valid block count and set NEW_ADDR in dnode, so > it does not match condition 1) > - pin & fallocate preallocates blkaddrs and set blkaddrs in dnode, but > content on those blkaddrs may contain zero or random data, so it does not > match condition 2) > > Christoph describes this issue in below patch as well, you can check it. > da8c7fecc9c7 ("f2fs: rename F2FS_MAP_UNWRITTEN to F2FS_MAP_DELALLOC") > > Am I missing something? > > Thanks, > >> >>> >>> So 009, 092, 094 .. which expects unwritten status from extent will >>> fail. >>> >>> How about disabling those testcase? >>> >>> Thanks, >>> >>>> >>>> On 04/05, Chao Yu wrote: >>>>> xfstest generic/614 fails to run due below reason: >>>>> >>>>> generic/614 1s ... [not run] test requires delayed allocation buffered writes >>>>> >>>>> The root cause is f2fs tags wrong fiemap flag for delay allocated >>>>> extent. >>>>> >>>>> Quoted from fiemap.h: >>>>> FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ >>>>> FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. >>>>> * Sets EXTENT_UNKNOWN. */ >>>>> FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but >>>>> * no data (i.e. zero). */ >>>>> >>>>> FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o >>>>> been written any data, which status f2fs is not supported now, for all >>>>> NEW_ADDR block addresses, it means delay allocated blocks, so let's >>>>> tag FIEMAP_EXTENT_DELALLOC instead. >>>>> >>>>> Testcase: >>>>> xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; >>>>> filefrag -v /mnt/f2fs/file >>>>> >>>>> Output: >>>>> - Before >>>>> Filesystem type is: f2f52010 >>>>> Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>>> ext: logical_offset: physical_offset: length: expected: flags: >>>>> 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof >>>>> /mnt/f2fs/file: 1 extent found >>>>> >>>>> After: >>>>> Filesystem type is: f2f52010 >>>>> File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>>> ext: logical_offset: physical_offset: length: expected: flags: >>>>> 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof >>>>> /mnt/f2fs/file: 1 extent found >>>>> >>>>> Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") >>>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>>> --- >>>>> fs/f2fs/data.c | 7 +++++-- >>>>> 1 file changed, 5 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>>> index 359de650772e..3afc9764743e 100644 >>>>> --- a/fs/f2fs/data.c >>>>> +++ b/fs/f2fs/data.c >>>>> @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>>> } >>>>> if (size) { >>>>> - flags |= FIEMAP_EXTENT_MERGED; >>>>> + if (flags & FIEMAP_EXTENT_DELALLOC) >>>>> + phys = 0; >>>>> + else >>>>> + flags |= FIEMAP_EXTENT_MERGED; >>>>> if (IS_ENCRYPTED(inode)) >>>>> flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; >>>>> @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>>> size += blks_to_bytes(inode, 1); >>>>> } >>>>> } else if (map.m_flags & F2FS_MAP_DELALLOC) { >>>>> - flags = FIEMAP_EXTENT_UNWRITTEN; >>>>> + flags = FIEMAP_EXTENT_DELALLOC; >>>>> } >>>>> start_blk += bytes_to_blks(inode, size); >>>>> -- >>>>> 2.36.1 > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 04/11, Chao Yu wrote: > On 2023/4/11 16:14, Chao Yu wrote: > > On 2023/4/11 1:57, Jaegeuk Kim wrote: > > > On 04/08, Chao Yu wrote: > > > > On 2023/4/8 4:59, Jaegeuk Kim wrote: > > > > > This breaks generic/009? > > > > > > > > I guess it is as expected? > > > > > > > > Please check description of fiemap ioctl manual from [1]: > > > > > > > > FIEMAP_EXTENT_UNKNOWN > > > > The location of this extent is currently unknown. This may > > > > indicate the data is stored on an inaccessible volume or that > > > > no storage has been allocated for the file yet. > > > > > > > > FIEMAP_EXTENT_DELALLOC > > > > This will also set FIEMAP_EXTENT_UNKNOWN. > > > > > > > > Delayed allocation - while there is data for this extent, its > > > > physical location has not been allocated yet. > > > > > > > > FIEMAP_EXTENT_UNWRITTEN > > > > Unwritten extent - the extent is allocated but its data has not > > > > been initialized. This indicates the extent’s data will be all > > > > zero if read through the filesystem but the contents are undefined > > > > if read directly from the device. > > > > > > > > [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html > > > > > > > > According to its description, f2fs only support > > > > FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support > > > > FIEMAP_EXTENT_UNWRITTEN. > > > > > > No, I don't think so. > > > > Jaegeuk, > > > > Could you please check the detailed description of FIEMAP_EXTENT_UNWRITTEN? > > The flag indicates two conditions: > > 1. on-disk blkaddrs were allocated for extent, and the extent is tagged as > > unwritten status. > > 2. data readed on those blocks will be all zero. > > Sorry, I mean: > > 1. on-disk blkaddrs were allocated for extent; > 2. extent is tagged as unwritten status, data readed on those blocks will be > all zero. I was thinking fallocate/pin cases to give zero data. But, we may need to check the space discarded securely or disk support? > > Thanks, > > > > > So, let's check f2fs' status: > > - fallocate only reserve valid block count and set NEW_ADDR in dnode, so > > it does not match condition 1) > > - pin & fallocate preallocates blkaddrs and set blkaddrs in dnode, but > > content on those blkaddrs may contain zero or random data, so it does not > > match condition 2) > > > > Christoph describes this issue in below patch as well, you can check it. > > da8c7fecc9c7 ("f2fs: rename F2FS_MAP_UNWRITTEN to F2FS_MAP_DELALLOC") > > > > Am I missing something? > > > > Thanks, > > > > > > > > > > > > > So 009, 092, 094 .. which expects unwritten status from extent will > > > > fail. > > > > > > > > How about disabling those testcase? > > > > > > > > Thanks, > > > > > > > > > > > > > > On 04/05, Chao Yu wrote: > > > > > > xfstest generic/614 fails to run due below reason: > > > > > > > > > > > > generic/614 1s ... [not run] test requires delayed allocation buffered writes > > > > > > > > > > > > The root cause is f2fs tags wrong fiemap flag for delay allocated > > > > > > extent. > > > > > > > > > > > > Quoted from fiemap.h: > > > > > > FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ > > > > > > FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. > > > > > > * Sets EXTENT_UNKNOWN. */ > > > > > > FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but > > > > > > * no data (i.e. zero). */ > > > > > > > > > > > > FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o > > > > > > been written any data, which status f2fs is not supported now, for all > > > > > > NEW_ADDR block addresses, it means delay allocated blocks, so let's > > > > > > tag FIEMAP_EXTENT_DELALLOC instead. > > > > > > > > > > > > Testcase: > > > > > > xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; > > > > > > filefrag -v /mnt/f2fs/file > > > > > > > > > > > > Output: > > > > > > - Before > > > > > > Filesystem type is: f2f52010 > > > > > > Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) > > > > > > ext: logical_offset: physical_offset: length: expected: flags: > > > > > > 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof > > > > > > /mnt/f2fs/file: 1 extent found > > > > > > > > > > > > After: > > > > > > Filesystem type is: f2f52010 > > > > > > File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) > > > > > > ext: logical_offset: physical_offset: length: expected: flags: > > > > > > 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof > > > > > > /mnt/f2fs/file: 1 extent found > > > > > > > > > > > > Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") > > > > > > Signed-off-by: Chao Yu <chao@kernel.org> > > > > > > --- > > > > > > fs/f2fs/data.c | 7 +++++-- > > > > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > > > > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > > > > > index 359de650772e..3afc9764743e 100644 > > > > > > --- a/fs/f2fs/data.c > > > > > > +++ b/fs/f2fs/data.c > > > > > > @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > > > > > > } > > > > > > if (size) { > > > > > > - flags |= FIEMAP_EXTENT_MERGED; > > > > > > + if (flags & FIEMAP_EXTENT_DELALLOC) > > > > > > + phys = 0; > > > > > > + else > > > > > > + flags |= FIEMAP_EXTENT_MERGED; > > > > > > if (IS_ENCRYPTED(inode)) > > > > > > flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; > > > > > > @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > > > > > > size += blks_to_bytes(inode, 1); > > > > > > } > > > > > > } else if (map.m_flags & F2FS_MAP_DELALLOC) { > > > > > > - flags = FIEMAP_EXTENT_UNWRITTEN; > > > > > > + flags = FIEMAP_EXTENT_DELALLOC; > > > > > > } > > > > > > start_blk += bytes_to_blks(inode, size); > > > > > > -- > > > > > > 2.36.1 > > > > > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 2023/4/12 1:08, Jaegeuk Kim wrote: > On 04/11, Chao Yu wrote: >> On 2023/4/11 16:14, Chao Yu wrote: >>> On 2023/4/11 1:57, Jaegeuk Kim wrote: >>>> On 04/08, Chao Yu wrote: >>>>> On 2023/4/8 4:59, Jaegeuk Kim wrote: >>>>>> This breaks generic/009? >>>>> >>>>> I guess it is as expected? >>>>> >>>>> Please check description of fiemap ioctl manual from [1]: >>>>> >>>>> FIEMAP_EXTENT_UNKNOWN >>>>> The location of this extent is currently unknown. This may >>>>> indicate the data is stored on an inaccessible volume or that >>>>> no storage has been allocated for the file yet. >>>>> >>>>> FIEMAP_EXTENT_DELALLOC >>>>> This will also set FIEMAP_EXTENT_UNKNOWN. >>>>> >>>>> Delayed allocation - while there is data for this extent, its >>>>> physical location has not been allocated yet. >>>>> >>>>> FIEMAP_EXTENT_UNWRITTEN >>>>> Unwritten extent - the extent is allocated but its data has not >>>>> been initialized. This indicates the extent’s data will be all >>>>> zero if read through the filesystem but the contents are undefined >>>>> if read directly from the device. >>>>> >>>>> [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html >>>>> >>>>> According to its description, f2fs only support >>>>> FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support >>>>> FIEMAP_EXTENT_UNWRITTEN. >>>> >>>> No, I don't think so. >>> >>> Jaegeuk, >>> >>> Could you please check the detailed description of FIEMAP_EXTENT_UNWRITTEN? >>> The flag indicates two conditions: >>> 1. on-disk blkaddrs were allocated for extent, and the extent is tagged as >>> unwritten status. >>> 2. data readed on those blocks will be all zero. >> >> Sorry, I mean: >> >> 1. on-disk blkaddrs were allocated for extent; >> 2. extent is tagged as unwritten status, data readed on those blocks will be >> all zero. > > I was thinking fallocate/pin cases to give zero data. But, we may need to check > the space discarded securely or disk support? I thought about similar scheme, we can add F2FS_GET_BLOCK_ZERO for fallocate/pin case to zero data in valid block address, but the problem is how can we distinguish zero/valid data from valid block address w/o additional unwritten flag of metadata. e.g. 1. write page [0,511] w/ valid data; 2. fallocate/pin page [512,1023] w/ zero data; 3. fiemap file --- what output should it be? Thanks, > >> >> Thanks, >> >>> >>> So, let's check f2fs' status: >>> - fallocate only reserve valid block count and set NEW_ADDR in dnode, so >>> it does not match condition 1) >>> - pin & fallocate preallocates blkaddrs and set blkaddrs in dnode, but >>> content on those blkaddrs may contain zero or random data, so it does not >>> match condition 2) >>> >>> Christoph describes this issue in below patch as well, you can check it. >>> da8c7fecc9c7 ("f2fs: rename F2FS_MAP_UNWRITTEN to F2FS_MAP_DELALLOC") >>> >>> Am I missing something? >>> >>> Thanks, >>> >>>> >>>>> >>>>> So 009, 092, 094 .. which expects unwritten status from extent will >>>>> fail. >>>>> >>>>> How about disabling those testcase? >>>>> >>>>> Thanks, >>>>> >>>>>> >>>>>> On 04/05, Chao Yu wrote: >>>>>>> xfstest generic/614 fails to run due below reason: >>>>>>> >>>>>>> generic/614 1s ... [not run] test requires delayed allocation buffered writes >>>>>>> >>>>>>> The root cause is f2fs tags wrong fiemap flag for delay allocated >>>>>>> extent. >>>>>>> >>>>>>> Quoted from fiemap.h: >>>>>>> FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ >>>>>>> FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. >>>>>>> * Sets EXTENT_UNKNOWN. */ >>>>>>> FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but >>>>>>> * no data (i.e. zero). */ >>>>>>> >>>>>>> FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o >>>>>>> been written any data, which status f2fs is not supported now, for all >>>>>>> NEW_ADDR block addresses, it means delay allocated blocks, so let's >>>>>>> tag FIEMAP_EXTENT_DELALLOC instead. >>>>>>> >>>>>>> Testcase: >>>>>>> xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; >>>>>>> filefrag -v /mnt/f2fs/file >>>>>>> >>>>>>> Output: >>>>>>> - Before >>>>>>> Filesystem type is: f2f52010 >>>>>>> Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>>>>> ext: logical_offset: physical_offset: length: expected: flags: >>>>>>> 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof >>>>>>> /mnt/f2fs/file: 1 extent found >>>>>>> >>>>>>> After: >>>>>>> Filesystem type is: f2f52010 >>>>>>> File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>>>>> ext: logical_offset: physical_offset: length: expected: flags: >>>>>>> 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof >>>>>>> /mnt/f2fs/file: 1 extent found >>>>>>> >>>>>>> Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") >>>>>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>>>>> --- >>>>>>> fs/f2fs/data.c | 7 +++++-- >>>>>>> 1 file changed, 5 insertions(+), 2 deletions(-) >>>>>>> >>>>>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>>>>> index 359de650772e..3afc9764743e 100644 >>>>>>> --- a/fs/f2fs/data.c >>>>>>> +++ b/fs/f2fs/data.c >>>>>>> @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>>>>> } >>>>>>> if (size) { >>>>>>> - flags |= FIEMAP_EXTENT_MERGED; >>>>>>> + if (flags & FIEMAP_EXTENT_DELALLOC) >>>>>>> + phys = 0; >>>>>>> + else >>>>>>> + flags |= FIEMAP_EXTENT_MERGED; >>>>>>> if (IS_ENCRYPTED(inode)) >>>>>>> flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; >>>>>>> @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>>>>> size += blks_to_bytes(inode, 1); >>>>>>> } >>>>>>> } else if (map.m_flags & F2FS_MAP_DELALLOC) { >>>>>>> - flags = FIEMAP_EXTENT_UNWRITTEN; >>>>>>> + flags = FIEMAP_EXTENT_DELALLOC; >>>>>>> } >>>>>>> start_blk += bytes_to_blks(inode, size); >>>>>>> -- >>>>>>> 2.36.1 >>> >>> >>> _______________________________________________ >>> Linux-f2fs-devel mailing list >>> Linux-f2fs-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 2023/4/13 17:49, Chao Yu wrote: > On 2023/4/12 1:08, Jaegeuk Kim wrote: >> On 04/11, Chao Yu wrote: >>> On 2023/4/11 16:14, Chao Yu wrote: >>>> On 2023/4/11 1:57, Jaegeuk Kim wrote: >>>>> On 04/08, Chao Yu wrote: >>>>>> On 2023/4/8 4:59, Jaegeuk Kim wrote: >>>>>>> This breaks generic/009? >>>>>> >>>>>> I guess it is as expected? >>>>>> >>>>>> Please check description of fiemap ioctl manual from [1]: >>>>>> >>>>>> FIEMAP_EXTENT_UNKNOWN >>>>>> The location of this extent is currently unknown. This may >>>>>> indicate the data is stored on an inaccessible volume or that >>>>>> no storage has been allocated for the file yet. >>>>>> >>>>>> FIEMAP_EXTENT_DELALLOC >>>>>> This will also set FIEMAP_EXTENT_UNKNOWN. >>>>>> >>>>>> Delayed allocation - while there is data for this extent, its >>>>>> physical location has not been allocated yet. >>>>>> >>>>>> FIEMAP_EXTENT_UNWRITTEN >>>>>> Unwritten extent - the extent is allocated but its data has not >>>>>> been initialized. This indicates the extent’s data will be all >>>>>> zero if read through the filesystem but the contents are undefined >>>>>> if read directly from the device. >>>>>> >>>>>> [1] https://www.kernel.org/doc/html/latest/filesystems/fiemap.html >>>>>> >>>>>> According to its description, f2fs only support >>>>>> FIEMAP_EXTENT_{UNKNOWN, DELALLOC}, but not support >>>>>> FIEMAP_EXTENT_UNWRITTEN. >>>>> >>>>> No, I don't think so. >>>> >>>> Jaegeuk, >>>> >>>> Could you please check the detailed description of FIEMAP_EXTENT_UNWRITTEN? >>>> The flag indicates two conditions: >>>> 1. on-disk blkaddrs were allocated for extent, and the extent is tagged as >>>> unwritten status. >>>> 2. data readed on those blocks will be all zero. >>> >>> Sorry, I mean: >>> >>> 1. on-disk blkaddrs were allocated for extent; >>> 2. extent is tagged as unwritten status, data readed on those blocks will be >>> all zero. >> >> I was thinking fallocate/pin cases to give zero data. But, we may need to check >> the space discarded securely or disk support? > > I thought about similar scheme, we can add F2FS_GET_BLOCK_ZERO for fallocate/pin > case to zero data in valid block address, but the problem is how can we distinguish > zero/valid data from valid block address w/o additional unwritten flag of metadata. > > e.g. > 1. write page [0,511] w/ valid data; > 2. fallocate/pin page [512,1023] w/ zero data; > 3. fiemap file --- what output should it be? Thoughts? Thanks, > > Thanks, > >> >>> >>> Thanks, >>> >>>> >>>> So, let's check f2fs' status: >>>> - fallocate only reserve valid block count and set NEW_ADDR in dnode, so >>>> it does not match condition 1) >>>> - pin & fallocate preallocates blkaddrs and set blkaddrs in dnode, but >>>> content on those blkaddrs may contain zero or random data, so it does not >>>> match condition 2) >>>> >>>> Christoph describes this issue in below patch as well, you can check it. >>>> da8c7fecc9c7 ("f2fs: rename F2FS_MAP_UNWRITTEN to F2FS_MAP_DELALLOC") >>>> >>>> Am I missing something? >>>> >>>> Thanks, >>>> >>>>> >>>>>> >>>>>> So 009, 092, 094 .. which expects unwritten status from extent will >>>>>> fail. >>>>>> >>>>>> How about disabling those testcase? >>>>>> >>>>>> Thanks, >>>>>> >>>>>>> >>>>>>> On 04/05, Chao Yu wrote: >>>>>>>> xfstest generic/614 fails to run due below reason: >>>>>>>> >>>>>>>> generic/614 1s ... [not run] test requires delayed allocation buffered writes >>>>>>>> >>>>>>>> The root cause is f2fs tags wrong fiemap flag for delay allocated >>>>>>>> extent. >>>>>>>> >>>>>>>> Quoted from fiemap.h: >>>>>>>> FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ >>>>>>>> FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. >>>>>>>> * Sets EXTENT_UNKNOWN. */ >>>>>>>> FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but >>>>>>>> * no data (i.e. zero). */ >>>>>>>> >>>>>>>> FIEMAP_EXTENT_UNWRITTEN means block address is preallocated, but w/o >>>>>>>> been written any data, which status f2fs is not supported now, for all >>>>>>>> NEW_ADDR block addresses, it means delay allocated blocks, so let's >>>>>>>> tag FIEMAP_EXTENT_DELALLOC instead. >>>>>>>> >>>>>>>> Testcase: >>>>>>>> xfs_io -f -c 'pwrite 0 64k' /mnt/f2fs/file; >>>>>>>> filefrag -v /mnt/f2fs/file >>>>>>>> >>>>>>>> Output: >>>>>>>> - Before >>>>>>>> Filesystem type is: f2f52010 >>>>>>>> Fize of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>>>>>> ext: logical_offset: physical_offset: length: expected: flags: >>>>>>>> 0: 0.. 15: 0.. 15: 16: last,unwritten,merged,eof >>>>>>>> /mnt/f2fs/file: 1 extent found >>>>>>>> >>>>>>>> After: >>>>>>>> Filesystem type is: f2f52010 >>>>>>>> File size of /mnt/f2fs/file is 65536 (16 blocks of 4096 bytes) >>>>>>>> ext: logical_offset: physical_offset: length: expected: flags: >>>>>>>> 0: 0.. 15: 0.. 0: 0: last,unknown_loc,delalloc,eof >>>>>>>> /mnt/f2fs/file: 1 extent found >>>>>>>> >>>>>>>> Fixes: 7f63eb77af7b ("f2fs: report unwritten area in f2fs_fiemap") >>>>>>>> Signed-off-by: Chao Yu <chao@kernel.org> >>>>>>>> --- >>>>>>>> fs/f2fs/data.c | 7 +++++-- >>>>>>>> 1 file changed, 5 insertions(+), 2 deletions(-) >>>>>>>> >>>>>>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>>>>>> index 359de650772e..3afc9764743e 100644 >>>>>>>> --- a/fs/f2fs/data.c >>>>>>>> +++ b/fs/f2fs/data.c >>>>>>>> @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>>>>>> } >>>>>>>> if (size) { >>>>>>>> - flags |= FIEMAP_EXTENT_MERGED; >>>>>>>> + if (flags & FIEMAP_EXTENT_DELALLOC) >>>>>>>> + phys = 0; >>>>>>>> + else >>>>>>>> + flags |= FIEMAP_EXTENT_MERGED; >>>>>>>> if (IS_ENCRYPTED(inode)) >>>>>>>> flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; >>>>>>>> @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, >>>>>>>> size += blks_to_bytes(inode, 1); >>>>>>>> } >>>>>>>> } else if (map.m_flags & F2FS_MAP_DELALLOC) { >>>>>>>> - flags = FIEMAP_EXTENT_UNWRITTEN; >>>>>>>> + flags = FIEMAP_EXTENT_DELALLOC; >>>>>>>> } >>>>>>>> start_blk += bytes_to_blks(inode, size); >>>>>>>> -- >>>>>>>> 2.36.1 >>>> >>>> >>>> _______________________________________________ >>>> Linux-f2fs-devel mailing list >>>> Linux-f2fs-devel@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 359de650772e..3afc9764743e 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1995,7 +1995,10 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, } if (size) { - flags |= FIEMAP_EXTENT_MERGED; + if (flags & FIEMAP_EXTENT_DELALLOC) + phys = 0; + else + flags |= FIEMAP_EXTENT_MERGED; if (IS_ENCRYPTED(inode)) flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; @@ -2035,7 +2038,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, size += blks_to_bytes(inode, 1); } } else if (map.m_flags & F2FS_MAP_DELALLOC) { - flags = FIEMAP_EXTENT_UNWRITTEN; + flags = FIEMAP_EXTENT_DELALLOC; } start_blk += bytes_to_blks(inode, size);