mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-15 16:24:21 +08:00
btrfs-progs: Introduce macro to calculate backup superblock offset
Introduce a new macro, BTRFS_SB_OFFSET() to calculate backup superblock offset, this is handy if one wants to initialize static array at declaration time. Suggested-by: David Sterba <dsterba@suse.cz> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a2203246ae
commit
c928522052
10
disk-io.h
10
disk-io.h
@ -98,11 +98,17 @@ enum btrfs_read_sb_flags {
|
||||
SBREAD_PARTIAL = (1 << 1),
|
||||
};
|
||||
|
||||
/*
|
||||
* Use macro to define mirror super block position,
|
||||
* so we can use it in static array initialization
|
||||
*/
|
||||
#define BTRFS_SB_MIRROR_OFFSET(mirror) ((u64)(SZ_16K) << \
|
||||
(BTRFS_SUPER_MIRROR_SHIFT * (mirror)))
|
||||
|
||||
static inline u64 btrfs_sb_offset(int mirror)
|
||||
{
|
||||
u64 start = SZ_16K;
|
||||
if (mirror)
|
||||
return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror);
|
||||
return BTRFS_SB_MIRROR_OFFSET(mirror);
|
||||
return BTRFS_SUPER_INFO_OFFSET;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user