aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-03-07 14:22:04 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-05-06 15:54:18 -0400
commit3173a18f70554fe7880bb2d85c7da566e364eb3c (patch)
tree0a23b42a8d275d3499fac2b90ded76276c64c1c1 /fs/btrfs/ctree.h
parentbe283b2e674a09457d4563729015adb637ce7cc1 (diff)
Btrfs: add a incompatible format change for smaller metadata extent refs
We currently store the first key of the tree block inside the reference for the tree block in the extent tree. This takes up quite a bit of space. Make a new key type for metadata which holds the level as the offset and completely removes storing the btrfs_tree_block_info inside the extent ref. This reduces the size from 51 bytes to 33 bytes per extent reference for each tree block. In practice this results in a 30-35% decrease in the size of our extent tree, which means we COW less and can keep more of the extent tree in memory which makes our heavy metadata operations go much faster. This is not an automatic format change, you must enable it at mkfs time or with btrfstune. This patch deals with having metadata stored as either the old format or the new format so it is easy to convert. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e2f14b5258b6..efb2feb7cd4a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -509,6 +509,7 @@ struct btrfs_super_block {
509 509
510#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6) 510#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
511#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7) 511#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
512#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
512 513
513#define BTRFS_FEATURE_COMPAT_SUPP 0ULL 514#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
514#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL 515#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
@@ -519,7 +520,8 @@ struct btrfs_super_block {
519 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \ 520 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \
520 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \ 521 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
521 BTRFS_FEATURE_INCOMPAT_RAID56 | \ 522 BTRFS_FEATURE_INCOMPAT_RAID56 | \
522 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF) 523 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF | \
524 BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
523 525
524/* 526/*
525 * A leaf is full of items. offset and size tell us where to find 527 * A leaf is full of items. offset and size tell us where to find
@@ -1809,6 +1811,12 @@ struct btrfs_ioctl_defrag_range_args {
1809 */ 1811 */
1810#define BTRFS_EXTENT_ITEM_KEY 168 1812#define BTRFS_EXTENT_ITEM_KEY 168
1811 1813
1814/*
1815 * The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know
1816 * the length, so we save the level in key->offset instead of the length.
1817 */
1818#define BTRFS_METADATA_ITEM_KEY 169
1819
1812#define BTRFS_TREE_BLOCK_REF_KEY 176 1820#define BTRFS_TREE_BLOCK_REF_KEY 176
1813 1821
1814#define BTRFS_EXTENT_DATA_REF_KEY 178 1822#define BTRFS_EXTENT_DATA_REF_KEY 178
@@ -3006,7 +3014,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
3006int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 3014int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
3007int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, 3015int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
3008 struct btrfs_root *root, u64 bytenr, 3016 struct btrfs_root *root, u64 bytenr,
3009 u64 num_bytes, u64 *refs, u64 *flags); 3017 u64 offset, int metadata, u64 *refs, u64 *flags);
3010int btrfs_pin_extent(struct btrfs_root *root, 3018int btrfs_pin_extent(struct btrfs_root *root,
3011 u64 bytenr, u64 num, int reserved); 3019 u64 bytenr, u64 num, int reserved);
3012int btrfs_pin_extent_for_log_replay(struct btrfs_root *root, 3020int btrfs_pin_extent_for_log_replay(struct btrfs_root *root,
@@ -3669,6 +3677,16 @@ static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
3669 } 3677 }
3670} 3678}
3671 3679
3680#define btrfs_fs_incompat(fs_info, opt) \
3681 __btrfs_fs_incompat((fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
3682
3683static inline int __btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
3684{
3685 struct btrfs_super_block *disk_super;
3686 disk_super = fs_info->super_copy;
3687 return !!(btrfs_super_incompat_flags(disk_super) & flag);
3688}
3689
3672/* 3690/*
3673 * Call btrfs_abort_transaction as early as possible when an error condition is 3691 * Call btrfs_abort_transaction as early as possible when an error condition is
3674 * detected, that way the exact line number is reported. 3692 * detected, that way the exact line number is reported.