Re: [PATCH 2/2] btrfs: Introduce new tree block flag, BTRFS_HEADER_FLAG_LOG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 19.03.19 г. 8:04 ч., Qu Wenruo wrote:
> This new tree block flag is to indicate the tree block belongs to a log
> tree.
> 
> For btrfs on-disk format, there are several different trees could use
> the same owner number:
> - ordinary subvolume tree
> - log tree for ordinary subvolume
> - reloc tree for ordinary subvolume
> 
> It's possible to do the backref walk or use the content to determine the
> real owner of the tree block.
> But backref walk is too expensive, content detection is not reliable.
> 
> So adding a new flag to explicitly show the owner of log tree.
> 
> Thankfully, tree-checker hasn't checked header flags yet, and there is
> no real user for this flag yet.
> So we don't need to introduce any compatibility flag for this
> modification.
> 
> The introduction of this new flag makes tree block owner easier to
> distinguish, making life easier for:
> - tree checker on log tree
>   Log tree could contain some items impossible for regular trees
> - performance profiler
>   Now it's much easier to distinguish log tree.
> 
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
> ---
>  fs/btrfs/disk-io.c              | 1 +
>  include/uapi/linux/btrfs_tree.h | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 6fe9197f6ee4..8cffdb7789d8 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -1362,6 +1362,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
>  		return ERR_CAST(leaf);
>  	}
>  
> +	btrfs_set_header_flag(leaf, BTRFS_HEADER_FLAG_LOG);
>  	root->node = leaf;

Unless you are going to tag ALL extent buffers which are allocated as
part of the log tree this patch is redundant, because even now you can
detect the root of the log tree by simply checking for the
root->root_key.objectid. Alternatively if you are going to be tagging
all such blocks then those 2 patches need to be part of a larger series
so the intended usage is more clear.

>  
>  	btrfs_mark_buffer_dirty(root->node);
> diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
> index e974f4bb5378..d4ef80b702a0 100644
> --- a/include/uapi/linux/btrfs_tree.h
> +++ b/include/uapi/linux/btrfs_tree.h
> @@ -447,9 +447,15 @@ struct btrfs_free_space_header {
>  	__le64 num_bitmaps;
>  } __attribute__ ((__packed__));
>  
> +/* Tree/super has written to disk */
tree block has been correctly written to disk

>  #define BTRFS_HEADER_FLAG_WRITTEN	(1ULL << 0)
> +
> +/* Tree block which gets relocated */

tree block belongs to a relocation tree

>  #define BTRFS_HEADER_FLAG_RELOC		(1ULL << 1)
>  
> +/* Tree block which belows to log tree */
> +#define BTRFS_HEADER_FLAG_LOG		(1ULL << 2)
> +
>  /* Super block flags */
>  /* Errors detected */
>  #define BTRFS_SUPER_FLAG_ERROR		(1ULL << 2)
> 



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux