Skip to content

RFC copy-on-write extents mapping

Jeff Liu linux-fsdevel ocfs2-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3fiemap: Introduce FIEMAP_FLAG_COW flag to map shared extentsinclude/uapi/linux/fiemap.h+3 -10 replies
2/3fiemap: document updateDocumentation/filesystems/fiemap.txt+3 -00 replies
3/3ocfs2: only return the shared extents if FIEMAP_FLAG_COW is setfs/ocfs2/extent_map.c+10 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/3] copy-on-write extents mapping

Hello,

We have the user requests to show the real disk usage for OCFS2/Btrfs with reflinked/cloned files. AFAICS, integrate the existing fiemap interface to du(1) is fine to solve this issue because OCFS2 can return an extent in FIEMAP_EXTENT_SHARED state which is used to indicate the extent is reflinked, and Btrfs can be improved in the similar approach in the future.

Now another issue is regarding the performance when call fiemap ioctl(2) against a large file(like virtual disk images). Assuming we created a 20Gb reflinked file, the first 19Gb has been written(COWed), and the left 1Gb is still in shared status, the user space has to call fiemap for multiple times to fetch the ending shared extents, that is not good if the target disk have many reflinked files in such situations.

I'd like to introduce a new flag FIEMAP_FLAG_COW to the fiemap interface, if this flag is set, the kernel space will only return the mapped extents in shared state, as a result, we can reduce the overheads for calling fiemap again an again.

Test program to verify the FIEMAP_FLAG_COW flag:
https://github.com/pibroch/fiemap_cow/blob/master/cow_test.c

Create reflink file on OCFS2:
https://github.com/pibroch/fiemap_cow/blob/master/ocfs2_reflink.c

Any comments are appreciated, thanks!

-Jeff