Btrfs: incompatible format change to remove hole extents
PATCH 1/1 Btrfs: incompatible format change to remove hole extents
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,
--- fs/btrfs/ctree.h | 4 +- fs/btrfs/file.c | 13 +++++-- fs/btrfs/inode.c | 78 +++++++++++++++++++++++--------------- fs/btrfs/send.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++------ fs/btrfs/tree-log.c | 48 ++++++++++++++++++++--- 5 files changed, 197 insertions(+), 53 deletions(-)
fs/btrfs/ctree.h +3 -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
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 +95 -12
177 lines not on this page · raw message
fs/btrfs/tree-log.c +42 -6
96 lines not on this page · raw message
Signature · 1 line
1.8.3.1