diff mbox series

[02/15] btrfs: quit early if the fs has no RAID56 support for raid56 related checks

Message ID 20220517145039.3202184-3-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/15] btrfs: introduce a pure data checksum checking helper | expand

Commit Message

Christoph Hellwig May 17, 2022, 2:50 p.m. UTC
From: Qu Wenruo <wqu@suse.com>

The following functions do special handling for RAID56 chunks:

- btrfs_is_parity_mirror()
  Check if the range is in RAID56 chunks.

- btrfs_full_stripe_len()
  Either return sectorsize for non-RAID56 profiles or full stripe length
  for RAID56 chunks.

But if a filesystem without any RAID56 chunks, it will not have RAID56
incompt flags, and we can skip the chunk tree looking up completely.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/volumes.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Johannes Thumshirn May 17, 2022, 3 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Anand Jain May 18, 2022, 5:07 p.m. UTC | #2
On 5/17/22 20:20, Christoph Hellwig wrote:
> From: Qu Wenruo <wqu@suse.com>
> 
> The following functions do special handling for RAID56 chunks:
> 
> - btrfs_is_parity_mirror()
>    Check if the range is in RAID56 chunks.
> 
> - btrfs_full_stripe_len()
>    Either return sectorsize for non-RAID56 profiles or full stripe length
>    for RAID56 chunks.
> 
> But if a filesystem without any RAID56 chunks, it will not have RAID56
> incompt flags, and we can skip the chunk tree looking up completely.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

LGTM.

Reviewed-by: Anand Jain <anand.jain@oracle.com>



> ---
>   fs/btrfs/volumes.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 58f3eece8a48c..0819db46dbc42 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -5769,6 +5769,9 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info,
>   	struct map_lookup *map;
>   	unsigned long len = fs_info->sectorsize;
>   
> +	if (!btrfs_fs_incompat(fs_info, RAID56))
> +		return len;
> +
>   	em = btrfs_get_chunk_map(fs_info, logical, len);
>   
>   	if (!WARN_ON(IS_ERR(em))) {
> @@ -5786,6 +5789,9 @@ int btrfs_is_parity_mirror(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
>   	struct map_lookup *map;
>   	int ret = 0;
>   
> +	if (!btrfs_fs_incompat(fs_info, RAID56))
> +		return 0;
> +
>   	em = btrfs_get_chunk_map(fs_info, logical, len);
>   
>   	if(!WARN_ON(IS_ERR(em))) {
Nikolay Borisov May 20, 2022, 8:47 a.m. UTC | #3
On 17.05.22 г. 17:50 ч., Christoph Hellwig wrote:
> From: Qu Wenruo <wqu@suse.com>
> 
> The following functions do special handling for RAID56 chunks:
> 
> - btrfs_is_parity_mirror()
>    Check if the range is in RAID56 chunks.
> 
> - btrfs_full_stripe_len()
>    Either return sectorsize for non-RAID56 profiles or full stripe length
>    for RAID56 chunks.
> 
> But if a filesystem without any RAID56 chunks, it will not have RAID56
> incompt flags, and we can skip the chunk tree looking up completely.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>


This seems rather unrelated to the rest of the series so it can go 
independently and ideally should have been a separate patch of its own.
Christoph Hellwig May 20, 2022, 4:25 p.m. UTC | #4
On Fri, May 20, 2022 at 11:47:31AM +0300, Nikolay Borisov wrote:
> This seems rather unrelated to the rest of the series so it can go 
> independently and ideally should have been a separate patch of its own.

As far as I can tell it just speeds up functions used here, so yes.

Qu, do you want to send this out separately?
Qu Wenruo May 20, 2022, 10:36 p.m. UTC | #5
On 2022/5/21 00:25, Christoph Hellwig wrote:
> On Fri, May 20, 2022 at 11:47:31AM +0300, Nikolay Borisov wrote:
>> This seems rather unrelated to the rest of the series so it can go
>> independently and ideally should have been a separate patch of its own.
> 
> As far as I can tell it just speeds up functions used here, so yes.
> 
> Qu, do you want to send this out separately?
> 

I guess if needed, David can pick this up independently?

Thanks,
Qu
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 58f3eece8a48c..0819db46dbc42 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5769,6 +5769,9 @@  unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info,
 	struct map_lookup *map;
 	unsigned long len = fs_info->sectorsize;
 
+	if (!btrfs_fs_incompat(fs_info, RAID56))
+		return len;
+
 	em = btrfs_get_chunk_map(fs_info, logical, len);
 
 	if (!WARN_ON(IS_ERR(em))) {
@@ -5786,6 +5789,9 @@  int btrfs_is_parity_mirror(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
 	struct map_lookup *map;
 	int ret = 0;
 
+	if (!btrfs_fs_incompat(fs_info, RAID56))
+		return 0;
+
 	em = btrfs_get_chunk_map(fs_info, logical, len);
 
 	if(!WARN_ON(IS_ERR(em))) {