File btrfs-progs-introduce-macro-to-calculate-backup-superblock-offset.patch of Package btrfsprogs.5036

From: Qu Wenruo <quwenruo@cn.fujitsu.com>
Subject: btrfs-progs: Introduce macro to calculate backup superblock offset
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
Git-commit: c92852205265cf8ed48671b2405b071fe5870a97
Patch-mainline: v4.10

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>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
 disk-io.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/disk-io.h b/disk-io.h
index c4afea3f..08ee5cee 100644
--- a/disk-io.h
+++ b/disk-io.h
@@ -98,11 +98,17 @@ enum btrfs_read_sb_flags {
 	OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR = (1 << 11)
 };
 
+/*
+ * 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;
 }
 

openSUSE Build Service is sponsored by