On Thu, Jul 22, 2021 at 10:55:01AM -0700, Daeho Jeong wrote: > On Thu, Jul 22, 2021 at 10:36 AM Eric Biggers <[email protected]> wrote: > > > > On Thu, Jul 22, 2021 at 09:33:59AM -0700, Daeho Jeong wrote: > > > On Thu, Jul 22, 2021 at 9:26 AM Eric Biggers <[email protected]> wrote: > > > > > > > > On Thu, Jul 22, 2021 at 09:17:54AM -0700, Eric Biggers wrote: > > > > > > I think it matches with FIEMAP_EXTENT_UNWRITTEN. Otherwise, we > > > > > > should > > > > > > shorten the last extent like below. > > > > > > > > > > > > fe_logical=0 fe_physical=16384 length=4096 > > > > > > fe_logical=4096 fe_physical=81920 length=4096 > > > > > > fe_logical=8192 fe_physical=147456 length=4096 > > > > > > > > > > > > > > > > > > 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. > > > > > > > > > > Well, as I said before, using UNWRITTEN isn't appropriate because it > > > > > indicates > > > > > that the data is all zeroes, which in this case it is not. > > > > > Similarly, reporting > > > > > a hole isn't appropriate because it also indicates that the data is > > > > > all zeroes > > > > > and also that it has no space allocated on-disk at all. > > > > > > > > > > I think we should just over-report the physical length of the last > > > > > extent in the > > > > > cluster, which is what btrfs does... > > > > > > > > > > > > > Also keep in mind that as far as fiemap is concerned, when > > > > FIEMAP_EXTENT_ENCODED > > > > is set (indicating that the data is compressed or encrypted), then > > > > reading the > > > > data from disk will have "undefined results"; see > > > > Documentation/filesystems/fiemap.rst. As such, when someone decides to > > > > do so > > > > anyway (which is necessary for encryption testing), they really need to > > > > know > > > > *exactly* what they're doing. So I think it's less bad to bend the > > > > rules on > > > > extents where FIEMAP_EXTENT_ENCODED is already set. > > > > > > > > In contrast, your suggestion would incorreectly report some parts of > > > > the file as > > > > standard extents (or holes) without FIEMAP_EXTENT_ENCODED, so it would > > > > be > > > > expected that the standard meaning would apply to those parts. > > > > > > > > - Eric > > > > > > I also think it is okay with the FIEMAP_EXTENT_ENCODED flag. > > > It is actually all zero in a view of the filesystem internal and still > > > undefined if read directly from the device. > > > If we remove this extent, it might be confusing to understand the layout > > > of it. > > > > FIEMAP_EXTENT_ENCODED | FIEMAP_EXTENT_UNWRITTEN is contradictory, so that > > doesn't seem like a good option. And no, the range is *not* zero when read > > from > > the file by userspace, which is what UNWRITTEN is supposed to indicate. > > > > Compressed data is terminated by an end-of-stream marker, so it is possible > > to > > decompress even if extra data is appended to it. So that's another reason > > why I > > feel that my suggestion is not as bad as the other options. > > > > > Plus, I think we need to remove the last extent, when we return back > > > the block to the free space pool to filesystem using releasing > > > reserved space ioctl. > > > > This seems to be a filesystem implementation detail. Again, FS_IOC_FIEMAP > > is > > just about returning the actual extent mapping, not about other filesystem > > implementation details. > > > > - Eric > > Understood. For confirmation, is this your final suggestion? > > fe_logical=0 fe_physical=16384 length=4096 > fe_logical=4096 fe_physical=81920 length=4096 > fe_logical=8192 fe_physical=147456 length=8192
Yes. - Eric _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
