Skip to contentSkip to conversation

Add full support for cloning inline extents

PATCH Superseded [email protected] 2 participants 3 messages Feb 21, 2020 Btrfs file system

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add full support for cloning inline extents

From: Filipe Manana <[email protected]>

This patchset adds support for currently unsupported cases of reflink operations that cover a file range that has inline extents, more details on why/how in patch 4/4.

It also starts by moving all the reflink code out of ioctl.c into a new file named reflink.c (like xfs does) since this code is quite significant in size and has grown over the years.

V2: Removed third patch from the previous patchset version. Since the full
page ends up getting written, it's not necessary to read it before writing to it in case it's not uptodate. The final patch, which is now patch number 3, ends up being simpler as well.

Filipe Manana (3):
Btrfs: move all reflink implementation code into its own file
Btrfs: simplify inline extent handling when doing reflinks
Btrfs: implement full reflink support for inline extents

 fs/btrfs/Makefile  |   2 +-
 fs/btrfs/ctree.h   |   2 +
 fs/btrfs/ioctl.c   | 733 ------------------------------------------
 fs/btrfs/reflink.c | 783 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 786 insertions(+), 734 deletions(-)
 create mode 100644 fs/btrfs/reflink.c
Signature · 1 line
2.25.0
#1 lore raw

PATCH v2 1/3 Btrfs: move all reflink implementation code into its own file

From: Filipe Manana <[email protected]>

The reflink code is quite large and has been living in ioctl.c since ever. It has grown over the years after many bug fixes and improvements, and since I'm planning on making some further improvements on it, it's time to get it better organized by moving into its own file, reflink.c (similar to what xfs does for example).

This change only moves the code out of ioctl.c into the new file, it doesn't do any other change.

---
 fs/btrfs/Makefile  |   2 +-
 fs/btrfs/ctree.h   |   2 +
 fs/btrfs/ioctl.c   | 733 --------------------------------------------
 fs/btrfs/reflink.c | 736 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 739 insertions(+), 734 deletions(-)
 create mode 100644 fs/btrfs/reflink.c
fs/btrfs/Makefile +1 -1
index 9a0ff3384381..e738f6206ea5 100644
@@ -11,7 +11,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
 	   compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
 	   reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
 	   uuid-tree.o props.o free-space-tree.o tree-checker.o space-info.o \
-	   block-rsv.o delalloc-space.o block-group.o discard.o
+	   block-rsv.o delalloc-space.o block-group.o discard.o reflink.o
 
 btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
 btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
fs/btrfs/ctree.h +2 -0
index bb237d577725..408e60384101 100644
@@ -2989,6 +2989,8 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
 		      size_t num_pages, loff_t pos, size_t write_bytes,
 		      struct extent_state **cached);
 int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end);
+
+/* reflink.c */
 loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in,
 			      struct file *file_out, loff_t pos_out,
 			      loff_t len, unsigned int remap_flags);
fs/btrfs/ioctl.c +0 -733

745 lines not on this page · raw message

fs/btrfs/reflink.c new file +736 -0

736 lines not on this page · raw message

Signature · 1 line
2.25.0
#2 lore raw

Re: [PATCH v2 1/3] Btrfs: move all reflink implementation code into its own file

Quoted 10 lines · On Fri, Feb 21, 2020 at 11:05:08AM +0000, [email protected] wrote:

From: Filipe Manana <[email protected]>

The reflink code is quite large and has been living in ioctl.c since ever. It has grown over the years after many bug fixes and improvements, and since I'm planning on making some further improvements on it, it's time to get it better organized by moving into its own file, reflink.c (similar to what xfs does for example).

This change only moves the code out of ioctl.c into the new file, it doesn't do any other change.

Makes sense.

fs/btrfs/ctree.h int btrfs_dirty_pages(struct inode *inode, struct page **pages, · line 2996

Quoted 11 lines
fs/btrfs/ctree.h +2 -0
@@ -2989,6 +2989,8 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
 		      size_t num_pages, loff_t pos, size_t write_bytes,
 		      struct extent_state **cached);
 int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end);
+
+/* reflink.c */
 loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in,
 			      struct file *file_out, loff_t pos_out,
 			      loff_t len, unsigned int remap_flags);

Let's create reflink.h with all the relevant declarations for reflink moved out of ctree.h too.

I see only BTRFS_MAX_DEDUPE_LEN and declaration of btrfs_remap_file_range, that's not much for now but it's cleaner and for future extensions. Thanks.