Message ID | 20211011101019.1409855-6-nborisov@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Make real_root used only in ref-verify | expand |
On Mon, Oct 11, 2021 at 01:10:19PM +0300, Nikolay Borisov wrote: > @@ -273,9 +266,10 @@ static inline void btrfs_init_generic_ref(struct btrfs_ref *generic_ref, > static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, > int level, u64 root, u64 mod_root, bool skip_qgroup) > { > +#ifdef CONFIG_BTRFS_FS_REF_VERIFY > /* If @real_root not set, use @root as fallback */ > - if (!generic_ref->real_root) > - generic_ref->real_root = root; > + generic_ref->real_root = mod_root ? mod_root : root; generic_ref->real_root = mod_root ?: root; Ie. the short form where the true branch only repeats the condition.
On 11.10.21 г. 18:05, David Sterba wrote: > On Mon, Oct 11, 2021 at 01:10:19PM +0300, Nikolay Borisov wrote: >> @@ -273,9 +266,10 @@ static inline void btrfs_init_generic_ref(struct btrfs_ref *generic_ref, >> static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, >> int level, u64 root, u64 mod_root, bool skip_qgroup) >> { >> +#ifdef CONFIG_BTRFS_FS_REF_VERIFY >> /* If @real_root not set, use @root as fallback */ >> - if (!generic_ref->real_root) >> - generic_ref->real_root = root; >> + generic_ref->real_root = mod_root ? mod_root : root; > > generic_ref->real_root = mod_root ?: root; > > Ie. the short form where the true branch only repeats the condition. Ah, this is a GNU extension which I had to go an read up on explicitly, but will keep it in mind :) >
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index 6bb299c66e1e..ddc82caf7b82 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -231,17 +231,10 @@ struct btrfs_ref { */ bool skip_qgroup; - /* - * Optional. For which root is this modification. - * Mostly used for qgroup optimization. - * - * When unset, data/tree ref init code will populate it. - * In certain cases, we're modifying reference for a different root. - * E.g. COW fs tree blocks for balance. - * In that case, tree_ref::root will be fs tree, but we're doing this - * for reloc tree, then we should set @real_root to reloc tree. - */ +#ifdef CONFIG_BTRFS_FS_REF_VERIFY + /* Through which root is this modification. */ u64 real_root; +#endif u64 bytenr; u64 len; @@ -273,9 +266,10 @@ static inline void btrfs_init_generic_ref(struct btrfs_ref *generic_ref, static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 root, u64 mod_root, bool skip_qgroup) { +#ifdef CONFIG_BTRFS_FS_REF_VERIFY /* If @real_root not set, use @root as fallback */ - if (!generic_ref->real_root) - generic_ref->real_root = root; + generic_ref->real_root = mod_root ? mod_root : root; +#endif generic_ref->tree_ref.level = level; generic_ref->tree_ref.owning_root = root; generic_ref->type = BTRFS_REF_METADATA; @@ -287,9 +281,10 @@ static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ref_root, u64 ino, u64 offset, u64 mod_root, bool skip_qgroup) { +#ifdef CONFIG_BTRFS_FS_REF_VERIFY /* If @real_root not set, use @root as fallback */ - if (!generic_ref->real_root) - generic_ref->real_root = ref_root; + generic_ref->real_root = mod_root ? mod_root : ref_root; +#endif generic_ref->data_ref.owning_root = ref_root; generic_ref->data_ref.ino = ino; generic_ref->data_ref.offset = offset;
Now that real_root is only used in ref-verify core gate it behind CONFIG_BTRFS_FS_REF_VERIFY ifdef. This shrinks the size of pending delayed refs by 8 bytes per ref, of which we can have many at any one time depending on intensity of the workload. Also change the comment about the member as it no longer deals with qgroups. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- fs/btrfs/delayed-ref.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)