Btrfs: incompatible format change to remove hole extents V4
PATCH 1/1 Btrfs: incompatible format change to remove hole extents V4
Btrfs has always had these filler extent data items for holes in inodes. This has made somethings very easy, like logging hole punches and sending hole punches. However for large holey files these extent data items are pure overhead. So add an incompatible feature to no longer add hole extents to reduce the amount of metadata used by these sort of files. This has a few changes for logging and send obviously since they will need to detect holes and log/send the holes if there are any. I've tested this thoroughly with xfstests and it doesn't cause any issues with and without the incompat format set. Thanks,
---V3->V4: fix a fsync bug where we'd think there was a hole because the last extent was on an unchanged leaf.
fs/btrfs/ctree.c | 3 +- fs/btrfs/ctree.h | 5 +- fs/btrfs/file.c | 13 ++-- fs/btrfs/inode.c | 78 +++++++++++++++--------- fs/btrfs/send.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++--- fs/btrfs/tree-log.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 377 insertions(+), 56 deletions(-)
fs/btrfs/ctree.c +1 -2
@@ -41,7 +41,6 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, int level, int slot);static void tree_mod_log_free_eb (struct btrfs_fs_info *fs_info,struct extent_buffer *eb); -static int btrfs_prev_leaf (struct btrfs_root *root,struct btrfs_path *path);struct btrfs_path *btrfs_alloc_path (void ) {
@@ -4819,7 +4818,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,* This may release the path, and so you may lose any locks held at the * time you call it. */ -static int btrfs_prev_leaf (struct btrfs_root *root,struct btrfs_path *path) +int btrfs_prev_leaf (struct btrfs_root *root,struct btrfs_path *path) {struct btrfs_key key;struct btrfs_disk_key found_key;
fs/btrfs/ctree.h +4 -1
@@ -521,6 +521,7 @@ struct btrfs_super_block {#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8) +#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)#define BTRFS_FEATURE_COMPAT_SUPP 0ULL#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
@@ -532,7 +533,8 @@ struct btrfs_super_block {BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \BTRFS_FEATURE_INCOMPAT_RAID56 | \BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF | \ - BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA) +BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA | \ + BTRFS_FEATURE_INCOMPAT_NO_HOLES)/* * A leaf is full of items. offset and size tell us where to find
@@ -3405,6 +3407,7 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, }int btrfs_next_leaf (struct btrfs_root *root,struct btrfs_path *path); +int btrfs_prev_leaf (struct btrfs_root *root,struct btrfs_path *path);int btrfs_next_old_leaf (struct btrfs_root *root,struct btrfs_path *path,u64 time_seq); static inline int btrfs_next_old_item(struct btrfs_root *root,
fs/btrfs/file.c +9 -4
@@ -1963,11 +1963,13 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,struct btrfs_key key;int ret; +if (btrfs_fs_incompat (root->fs_info,NO_HOLES )) + goto out; + key.objectid =btrfs_ino (inode); key.type =BTRFS_EXTENT_DATA_KEY ; key.offset = offset; - ret =btrfs_search_slot (trans, root, &key, path,0 ,1 );if (ret <0 )return ret;
@@ -2064,8 +2066,10 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)u64 drop_end;int ret =0 ;int err =0 ; +int rsv_count;bool same_page = ((offset >>PAGE_CACHE_SHIFT ) == ((offset + len -1 ) >>PAGE_CACHE_SHIFT )); +bool no_holes =btrfs_fs_incompat (root->fs_info,NO_HOLES );btrfs_wait_ordered_range (inode, offset, len);
@@ -2157,9 +2161,10 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)/* * 1 - update the inode * 1 - removing the extents in the range -* 1 - adding the hole extent +* 1 - adding the hole extent if no_holes isn't set */ - trans =btrfs_start_transaction (root,3 ); + rsv_count = no_holes ?2 :3 ; + trans =btrfs_start_transaction (root, rsv_count);if (IS_ERR (trans)) { err =PTR_ERR (trans); goto out_free;
@@ -2196,7 +2201,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)btrfs_end_transaction (trans, root);btrfs_btree_balance_dirty (root); - trans =btrfs_start_transaction (root,3 ); + trans =btrfs_start_transaction (root, rsv_count);if (IS_ERR (trans)) { ret =PTR_ERR (trans); trans =NULL ;
fs/btrfs/inode.c +48 -30
116 lines not on this page · raw message
fs/btrfs/send.c +153 -9
217 lines not on this page · raw message
fs/btrfs/tree-log.c +162 -10
247 lines not on this page · raw message
Signature · 1 line
1.8.3.1