2023-09-14 19:06:58 +03:00
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright ( C ) 2023 Western Digital Corporation or its affiliates .
*/
# ifndef BTRFS_RAID_STRIPE_TREE_H
# define BTRFS_RAID_STRIPE_TREE_H
2024-01-27 02:53:06 +03:00
# include <linux/types.h>
# include <uapi/linux/btrfs_tree.h>
# include "fs.h"
2023-09-14 19:07:02 +03:00
# define BTRFS_RST_SUPP_BLOCK_GROUP_MASK (BTRFS_BLOCK_GROUP_DUP | \
BTRFS_BLOCK_GROUP_RAID1_MASK | \
BTRFS_BLOCK_GROUP_RAID0 | \
BTRFS_BLOCK_GROUP_RAID10 )
2023-09-14 19:06:58 +03:00
struct btrfs_io_context ;
struct btrfs_io_stripe ;
2024-01-27 02:53:06 +03:00
struct btrfs_fs_info ;
2023-09-14 19:06:58 +03:00
struct btrfs_ordered_extent ;
struct btrfs_trans_handle ;
2023-09-14 19:06:59 +03:00
int btrfs_delete_raid_extent ( struct btrfs_trans_handle * trans , u64 start , u64 length ) ;
2023-09-14 19:07:00 +03:00
int btrfs_get_raid_extent_offset ( struct btrfs_fs_info * fs_info ,
u64 logical , u64 * length , u64 map_type ,
u32 stripe_index , struct btrfs_io_stripe * stripe ) ;
2023-09-14 19:06:58 +03:00
int btrfs_insert_raid_extent ( struct btrfs_trans_handle * trans ,
struct btrfs_ordered_extent * ordered_extent ) ;
static inline bool btrfs_need_stripe_tree_update ( struct btrfs_fs_info * fs_info ,
u64 map_type )
{
u64 type = map_type & BTRFS_BLOCK_GROUP_TYPE_MASK ;
u64 profile = map_type & BTRFS_BLOCK_GROUP_PROFILE_MASK ;
if ( ! btrfs_fs_incompat ( fs_info , RAID_STRIPE_TREE ) )
return false ;
if ( type ! = BTRFS_BLOCK_GROUP_DATA )
return false ;
2023-09-14 19:07:02 +03:00
if ( profile & BTRFS_RST_SUPP_BLOCK_GROUP_MASK )
2023-09-14 19:06:58 +03:00
return true ;
return false ;
}
2023-09-14 19:07:00 +03:00
static inline int btrfs_num_raid_stripes ( u32 item_size )
{
return ( item_size - offsetof ( struct btrfs_stripe_extent , strides ) ) /
sizeof ( struct btrfs_raid_stride ) ;
}
2023-09-14 19:06:58 +03:00
# endif