diff mbox series

[1/4] btrfs-progs: zoned: export sb_zone_number() and related constants

Message ID 20220406014313.993961-2-naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: zoned: fix mkfs failure on various zone size | expand

Commit Message

Naohiro Aota April 6, 2022, 1:43 a.m. UTC
Move sb_zone_number() and related constants from zoned.c to the
corresponding header for later use.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 kernel-shared/zoned.c | 33 ---------------------------------
 kernel-shared/zoned.h | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 33 deletions(-)

Comments

David Sterba April 8, 2022, 7:45 p.m. UTC | #1
On Wed, Apr 06, 2022 at 10:43:10AM +0900, Naohiro Aota wrote:
> Move sb_zone_number() and related constants from zoned.c to the
> corresponding header for later use.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
>  kernel-shared/zoned.c | 33 ---------------------------------
>  kernel-shared/zoned.h | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+), 33 deletions(-)
> 
> diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
> index 2a11a1d723aa..396b74f0d906 100644
> --- a/kernel-shared/zoned.c
> +++ b/kernel-shared/zoned.c
> @@ -33,20 +33,6 @@
>  /* Pseudo write pointer value for conventional zone */
>  #define WP_CONVENTIONAL			((u64)-2)
>  
> -/*
> - * Location of the first zone of superblock logging zone pairs.
> - *
> - * - primary superblock:    0B (zone 0)
> - * - first copy:          512G (zone starting at that offset)
> - * - second copy:           4T (zone starting at that offset)
> - */
> -#define BTRFS_SB_LOG_PRIMARY_OFFSET	(0ULL)
> -#define BTRFS_SB_LOG_FIRST_OFFSET	(512ULL * SZ_1G)
> -#define BTRFS_SB_LOG_SECOND_OFFSET	(4096ULL * SZ_1G)
> -
> -#define BTRFS_SB_LOG_FIRST_SHIFT	const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET)
> -#define BTRFS_SB_LOG_SECOND_SHIFT	const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET)
> -
>  #define EMULATED_ZONE_SIZE		SZ_256M
>  
>  static int btrfs_get_dev_zone_info(struct btrfs_device *device);
> @@ -220,25 +206,6 @@ static int sb_write_pointer(int fd, struct blk_zone *zones, u64 *wp_ret)
>  	return 0;
>  }
>  
> -/*
> - * Get the first zone number of the superblock mirror
> - */
> -static inline u32 sb_zone_number(int shift, int mirror)
> -{
> -	u64 zone = 0;
> -
> -	ASSERT(0 <= mirror && mirror < BTRFS_SUPER_MIRROR_MAX);
> -	switch (mirror) {
> -	case 0: zone = 0; break;
> -	case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break;
> -	case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
> -	}
> -
> -	ASSERT(zone <= U32_MAX);
> -
> -	return (u32)zone;
> -}
> -
>  int btrfs_reset_dev_zone(int fd, struct blk_zone *zone)
>  {
>  	struct blk_zone_range range;
> diff --git a/kernel-shared/zoned.h b/kernel-shared/zoned.h
> index 75327610e537..cc0d6b6f166d 100644
> --- a/kernel-shared/zoned.h
> +++ b/kernel-shared/zoned.h
> @@ -36,6 +36,20 @@ struct blk_zone {
>  /* Number of superblock log zones */
>  #define BTRFS_NR_SB_LOG_ZONES		2
>  
> +/*
> + * Location of the first zone of superblock logging zone pairs.
> + *
> + * - primary superblock:    0B (zone 0)
> + * - first copy:          512G (zone starting at that offset)
> + * - second copy:           4T (zone starting at that offset)
> + */
> +#define BTRFS_SB_LOG_PRIMARY_OFFSET	(0ULL)
> +#define BTRFS_SB_LOG_FIRST_OFFSET	(512ULL * SZ_1G)
> +#define BTRFS_SB_LOG_SECOND_OFFSET	(4096ULL * SZ_1G)
> +
> +#define BTRFS_SB_LOG_FIRST_SHIFT	const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET)
> +#define BTRFS_SB_LOG_SECOND_SHIFT	const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET)
> +
>  /*
>   * Zoned block device models
>   */
> @@ -206,6 +220,25 @@ static inline bool zoned_profile_supported(u64 map_type)
>  
>  #endif /* BTRFS_ZONED */
>  
> +/*
> + * Get the first zone number of the superblock mirror
> + */
> +static inline u32 sb_zone_number(int shift, int mirror)
> +{

This does not need to be static inline but not a big deal.

> +	u64 zone = 0;
> +
> +	ASSERT(0 <= mirror && mirror < BTRFS_SUPER_MIRROR_MAX);
> +	switch (mirror) {
> +	case 0: zone = 0; break;
> +	case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break;
> +	case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
> +	}
> +
> +	ASSERT(zone <= U32_MAX);
> +
> +	return (u32)zone;
> +}
> +
>  static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
>  {
>  	return zone_is_sequential(device->zone_info, pos);
> -- 
> 2.35.1
diff mbox series

Patch

diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
index 2a11a1d723aa..396b74f0d906 100644
--- a/kernel-shared/zoned.c
+++ b/kernel-shared/zoned.c
@@ -33,20 +33,6 @@ 
 /* Pseudo write pointer value for conventional zone */
 #define WP_CONVENTIONAL			((u64)-2)
 
-/*
- * Location of the first zone of superblock logging zone pairs.
- *
- * - primary superblock:    0B (zone 0)
- * - first copy:          512G (zone starting at that offset)
- * - second copy:           4T (zone starting at that offset)
- */
-#define BTRFS_SB_LOG_PRIMARY_OFFSET	(0ULL)
-#define BTRFS_SB_LOG_FIRST_OFFSET	(512ULL * SZ_1G)
-#define BTRFS_SB_LOG_SECOND_OFFSET	(4096ULL * SZ_1G)
-
-#define BTRFS_SB_LOG_FIRST_SHIFT	const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET)
-#define BTRFS_SB_LOG_SECOND_SHIFT	const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET)
-
 #define EMULATED_ZONE_SIZE		SZ_256M
 
 static int btrfs_get_dev_zone_info(struct btrfs_device *device);
@@ -220,25 +206,6 @@  static int sb_write_pointer(int fd, struct blk_zone *zones, u64 *wp_ret)
 	return 0;
 }
 
-/*
- * Get the first zone number of the superblock mirror
- */
-static inline u32 sb_zone_number(int shift, int mirror)
-{
-	u64 zone = 0;
-
-	ASSERT(0 <= mirror && mirror < BTRFS_SUPER_MIRROR_MAX);
-	switch (mirror) {
-	case 0: zone = 0; break;
-	case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break;
-	case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
-	}
-
-	ASSERT(zone <= U32_MAX);
-
-	return (u32)zone;
-}
-
 int btrfs_reset_dev_zone(int fd, struct blk_zone *zone)
 {
 	struct blk_zone_range range;
diff --git a/kernel-shared/zoned.h b/kernel-shared/zoned.h
index 75327610e537..cc0d6b6f166d 100644
--- a/kernel-shared/zoned.h
+++ b/kernel-shared/zoned.h
@@ -36,6 +36,20 @@  struct blk_zone {
 /* Number of superblock log zones */
 #define BTRFS_NR_SB_LOG_ZONES		2
 
+/*
+ * Location of the first zone of superblock logging zone pairs.
+ *
+ * - primary superblock:    0B (zone 0)
+ * - first copy:          512G (zone starting at that offset)
+ * - second copy:           4T (zone starting at that offset)
+ */
+#define BTRFS_SB_LOG_PRIMARY_OFFSET	(0ULL)
+#define BTRFS_SB_LOG_FIRST_OFFSET	(512ULL * SZ_1G)
+#define BTRFS_SB_LOG_SECOND_OFFSET	(4096ULL * SZ_1G)
+
+#define BTRFS_SB_LOG_FIRST_SHIFT	const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET)
+#define BTRFS_SB_LOG_SECOND_SHIFT	const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET)
+
 /*
  * Zoned block device models
  */
@@ -206,6 +220,25 @@  static inline bool zoned_profile_supported(u64 map_type)
 
 #endif /* BTRFS_ZONED */
 
+/*
+ * Get the first zone number of the superblock mirror
+ */
+static inline u32 sb_zone_number(int shift, int mirror)
+{
+	u64 zone = 0;
+
+	ASSERT(0 <= mirror && mirror < BTRFS_SUPER_MIRROR_MAX);
+	switch (mirror) {
+	case 0: zone = 0; break;
+	case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break;
+	case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
+	}
+
+	ASSERT(zone <= U32_MAX);
+
+	return (u32)zone;
+}
+
 static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
 {
 	return zone_is_sequential(device->zone_info, pos);