public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: kill btrfs_raid_type_names[]
@ 2018-04-25  7:26 Anand Jain
  2018-04-25  7:35 ` Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anand Jain @ 2018-04-25  7:26 UTC (permalink / raw)
  To: linux-btrfs

Add a new member struct btrfs_raid_attr::raid_name so that
btrfs_raid_array[] can maintain the name of the raid type,
and so we can kill btrfs_raid_type_names[].

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/extent-tree.c | 18 ------------------
 fs/btrfs/volumes.c     | 15 +++++++++++++++
 fs/btrfs/volumes.h     |  3 +++
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 90d28a3727c6..4742734a73d7 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7338,24 +7338,6 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
 	return ret;
 }
 
-static const char *btrfs_raid_type_names[BTRFS_NR_RAID_TYPES] = {
-	[BTRFS_RAID_RAID10]	= "raid10",
-	[BTRFS_RAID_RAID1]	= "raid1",
-	[BTRFS_RAID_DUP]	= "dup",
-	[BTRFS_RAID_RAID0]	= "raid0",
-	[BTRFS_RAID_SINGLE]	= "single",
-	[BTRFS_RAID_RAID5]	= "raid5",
-	[BTRFS_RAID_RAID6]	= "raid6",
-};
-
-static const char *get_raid_name(enum btrfs_raid_types type)
-{
-	if (type >= BTRFS_NR_RAID_TYPES)
-		return NULL;
-
-	return btrfs_raid_type_names[type];
-}
-
 enum btrfs_loop_type {
 	LOOP_CACHING_NOWAIT = 0,
 	LOOP_CACHING_WAIT = 1,
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9c29fdca9075..04b8d602dc08 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -52,6 +52,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 1,
 		.devs_increment	= 2,
 		.ncopies	= 2,
+		.raid_name	="raid10",
 	},
 	[BTRFS_RAID_RAID1] = {
 		.sub_stripes	= 1,
@@ -61,6 +62,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 1,
 		.devs_increment	= 2,
 		.ncopies	= 2,
+		.raid_name	="raid1",
 	},
 	[BTRFS_RAID_DUP] = {
 		.sub_stripes	= 1,
@@ -70,6 +72,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 0,
 		.devs_increment	= 1,
 		.ncopies	= 2,
+		.raid_name	="dup",
 	},
 	[BTRFS_RAID_RAID0] = {
 		.sub_stripes	= 1,
@@ -79,6 +82,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 0,
 		.devs_increment	= 1,
 		.ncopies	= 1,
+		.raid_name	="raid0",
 	},
 	[BTRFS_RAID_SINGLE] = {
 		.sub_stripes	= 1,
@@ -88,6 +92,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 0,
 		.devs_increment	= 1,
 		.ncopies	= 1,
+		.raid_name	="single",
 	},
 	[BTRFS_RAID_RAID5] = {
 		.sub_stripes	= 1,
@@ -97,6 +102,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 1,
 		.devs_increment	= 1,
 		.ncopies	= 2,
+		.raid_name	="raid5",
 	},
 	[BTRFS_RAID_RAID6] = {
 		.sub_stripes	= 1,
@@ -106,9 +112,18 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
 		.tolerated_failures = 2,
 		.devs_increment	= 1,
 		.ncopies	= 3,
+		.raid_name	="raid6",
 	},
 };
 
+const char *get_raid_name(enum btrfs_raid_types type)
+{
+	if (type >= BTRFS_NR_RAID_TYPES)
+		return NULL;
+
+	return btrfs_raid_array[type].raid_name;
+}
+
 const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
 	[BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
 	[BTRFS_RAID_RAID1]  = BTRFS_BLOCK_GROUP_RAID1,
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index ef220d541d4b..2acd32ce1573 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -342,6 +342,7 @@ struct btrfs_raid_attr {
 	int tolerated_failures; /* max tolerated fail devs */
 	int devs_increment;	/* ndevs has to be a multiple of this */
 	int ncopies;		/* how many copies to data has */
+	char *raid_name;	/* name of the raid */
 };
 
 extern const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES];
@@ -563,6 +564,8 @@ static inline enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags)
 	return BTRFS_RAID_SINGLE; /* BTRFS_BLOCK_GROUP_SINGLE */
 }
 
+const char *get_raid_name(enum btrfs_raid_types type);
+
 void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info);
 void btrfs_update_commit_device_bytes_used(struct btrfs_transaction *trans);
 
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: kill btrfs_raid_type_names[]
  2018-04-25  7:26 [PATCH] btrfs: kill btrfs_raid_type_names[] Anand Jain
@ 2018-04-25  7:35 ` Qu Wenruo
  2018-04-25  7:35 ` Nikolay Borisov
  2018-04-25  9:23 ` David Sterba
  2 siblings, 0 replies; 5+ messages in thread
From: Qu Wenruo @ 2018-04-25  7:35 UTC (permalink / raw)
  To: Anand Jain, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 4643 bytes --]



On 2018年04月25日 15:26, Anand Jain wrote:
> Add a new member struct btrfs_raid_attr::raid_name so that
> btrfs_raid_array[] can maintain the name of the raid type,
> and so we can kill btrfs_raid_type_names[].
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Looks much better than the old way.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/extent-tree.c | 18 ------------------
>  fs/btrfs/volumes.c     | 15 +++++++++++++++
>  fs/btrfs/volumes.h     |  3 +++
>  3 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 90d28a3727c6..4742734a73d7 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -7338,24 +7338,6 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
>  	return ret;
>  }
>  
> -static const char *btrfs_raid_type_names[BTRFS_NR_RAID_TYPES] = {
> -	[BTRFS_RAID_RAID10]	= "raid10",
> -	[BTRFS_RAID_RAID1]	= "raid1",
> -	[BTRFS_RAID_DUP]	= "dup",
> -	[BTRFS_RAID_RAID0]	= "raid0",
> -	[BTRFS_RAID_SINGLE]	= "single",
> -	[BTRFS_RAID_RAID5]	= "raid5",
> -	[BTRFS_RAID_RAID6]	= "raid6",
> -};
> -
> -static const char *get_raid_name(enum btrfs_raid_types type)
> -{
> -	if (type >= BTRFS_NR_RAID_TYPES)
> -		return NULL;
> -
> -	return btrfs_raid_type_names[type];
> -}
> -
>  enum btrfs_loop_type {
>  	LOOP_CACHING_NOWAIT = 0,
>  	LOOP_CACHING_WAIT = 1,
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 9c29fdca9075..04b8d602dc08 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -52,6 +52,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 2,
>  		.ncopies	= 2,
> +		.raid_name	="raid10",
>  	},
>  	[BTRFS_RAID_RAID1] = {
>  		.sub_stripes	= 1,
> @@ -61,6 +62,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 2,
>  		.ncopies	= 2,
> +		.raid_name	="raid1",
>  	},
>  	[BTRFS_RAID_DUP] = {
>  		.sub_stripes	= 1,
> @@ -70,6 +72,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 2,
> +		.raid_name	="dup",
>  	},
>  	[BTRFS_RAID_RAID0] = {
>  		.sub_stripes	= 1,
> @@ -79,6 +82,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 1,
> +		.raid_name	="raid0",
>  	},
>  	[BTRFS_RAID_SINGLE] = {
>  		.sub_stripes	= 1,
> @@ -88,6 +92,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 1,
> +		.raid_name	="single",
>  	},
>  	[BTRFS_RAID_RAID5] = {
>  		.sub_stripes	= 1,
> @@ -97,6 +102,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 1,
>  		.ncopies	= 2,
> +		.raid_name	="raid5",
>  	},
>  	[BTRFS_RAID_RAID6] = {
>  		.sub_stripes	= 1,
> @@ -106,9 +112,18 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 2,
>  		.devs_increment	= 1,
>  		.ncopies	= 3,
> +		.raid_name	="raid6",
>  	},
>  };
>  
> +const char *get_raid_name(enum btrfs_raid_types type)
> +{
> +	if (type >= BTRFS_NR_RAID_TYPES)
> +		return NULL;
> +
> +	return btrfs_raid_array[type].raid_name;
> +}
> +
>  const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
>  	[BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
>  	[BTRFS_RAID_RAID1]  = BTRFS_BLOCK_GROUP_RAID1,
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index ef220d541d4b..2acd32ce1573 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -342,6 +342,7 @@ struct btrfs_raid_attr {
>  	int tolerated_failures; /* max tolerated fail devs */
>  	int devs_increment;	/* ndevs has to be a multiple of this */
>  	int ncopies;		/* how many copies to data has */
> +	char *raid_name;	/* name of the raid */
>  };
>  
>  extern const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES];
> @@ -563,6 +564,8 @@ static inline enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags)
>  	return BTRFS_RAID_SINGLE; /* BTRFS_BLOCK_GROUP_SINGLE */
>  }
>  
> +const char *get_raid_name(enum btrfs_raid_types type);
> +
>  void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info);
>  void btrfs_update_commit_device_bytes_used(struct btrfs_transaction *trans);
>  
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: kill btrfs_raid_type_names[]
  2018-04-25  7:26 [PATCH] btrfs: kill btrfs_raid_type_names[] Anand Jain
  2018-04-25  7:35 ` Qu Wenruo
@ 2018-04-25  7:35 ` Nikolay Borisov
  2018-04-25  9:29   ` Anand Jain
  2018-04-25  9:23 ` David Sterba
  2 siblings, 1 reply; 5+ messages in thread
From: Nikolay Borisov @ 2018-04-25  7:35 UTC (permalink / raw)
  To: Anand Jain, linux-btrfs



On 25.04.2018 10:26, Anand Jain wrote:
> Add a new member struct btrfs_raid_attr::raid_name so that
> btrfs_raid_array[] can maintain the name of the raid type,
> and so we can kill btrfs_raid_type_names[].
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Makes sense:

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

> ---
>  fs/btrfs/extent-tree.c | 18 ------------------
>  fs/btrfs/volumes.c     | 15 +++++++++++++++
>  fs/btrfs/volumes.h     |  3 +++
>  3 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 90d28a3727c6..4742734a73d7 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -7338,24 +7338,6 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
>  	return ret;
>  }
>  
> -static const char *btrfs_raid_type_names[BTRFS_NR_RAID_TYPES] = {
> -	[BTRFS_RAID_RAID10]	= "raid10",
> -	[BTRFS_RAID_RAID1]	= "raid1",
> -	[BTRFS_RAID_DUP]	= "dup",
> -	[BTRFS_RAID_RAID0]	= "raid0",
> -	[BTRFS_RAID_SINGLE]	= "single",
> -	[BTRFS_RAID_RAID5]	= "raid5",
> -	[BTRFS_RAID_RAID6]	= "raid6",
> -};
> -
> -static const char *get_raid_name(enum btrfs_raid_types type)
> -{
> -	if (type >= BTRFS_NR_RAID_TYPES)
> -		return NULL;
> -
> -	return btrfs_raid_type_names[type];
> -}
> -
>  enum btrfs_loop_type {
>  	LOOP_CACHING_NOWAIT = 0,
>  	LOOP_CACHING_WAIT = 1,
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 9c29fdca9075..04b8d602dc08 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -52,6 +52,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 2,
>  		.ncopies	= 2,
> +		.raid_name	="raid10",
>  	},
>  	[BTRFS_RAID_RAID1] = {
>  		.sub_stripes	= 1,
> @@ -61,6 +62,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 2,
>  		.ncopies	= 2,
> +		.raid_name	="raid1",
>  	},
>  	[BTRFS_RAID_DUP] = {
>  		.sub_stripes	= 1,
> @@ -70,6 +72,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 2,
> +		.raid_name	="dup",
>  	},
>  	[BTRFS_RAID_RAID0] = {
>  		.sub_stripes	= 1,
> @@ -79,6 +82,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 1,
> +		.raid_name	="raid0",
>  	},
>  	[BTRFS_RAID_SINGLE] = {
>  		.sub_stripes	= 1,
> @@ -88,6 +92,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 1,
> +		.raid_name	="single",
>  	},
>  	[BTRFS_RAID_RAID5] = {
>  		.sub_stripes	= 1,
> @@ -97,6 +102,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 1,
>  		.ncopies	= 2,
> +		.raid_name	="raid5",
>  	},
>  	[BTRFS_RAID_RAID6] = {
>  		.sub_stripes	= 1,
> @@ -106,9 +112,18 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 2,
>  		.devs_increment	= 1,
>  		.ncopies	= 3,
> +		.raid_name	="raid6",
>  	},
>  };
>  
> +const char *get_raid_name(enum btrfs_raid_types type)
> +{
> +	if (type >= BTRFS_NR_RAID_TYPES)
> +		return NULL;
> +
> +	return btrfs_raid_array[type].raid_name;
> +}
> +
>  const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
>  	[BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
>  	[BTRFS_RAID_RAID1]  = BTRFS_BLOCK_GROUP_RAID1,
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index ef220d541d4b..2acd32ce1573 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -342,6 +342,7 @@ struct btrfs_raid_attr {
>  	int tolerated_failures; /* max tolerated fail devs */
>  	int devs_increment;	/* ndevs has to be a multiple of this */
>  	int ncopies;		/* how many copies to data has */
> +	char *raid_name;	/* name of the raid */
nit: const char * ?
>  };
>  
>  extern const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES];
> @@ -563,6 +564,8 @@ static inline enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags)
>  	return BTRFS_RAID_SINGLE; /* BTRFS_BLOCK_GROUP_SINGLE */
>  }
>  
> +const char *get_raid_name(enum btrfs_raid_types type);
> +
>  void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info);
>  void btrfs_update_commit_device_bytes_used(struct btrfs_transaction *trans);
>  
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: kill btrfs_raid_type_names[]
  2018-04-25  7:26 [PATCH] btrfs: kill btrfs_raid_type_names[] Anand Jain
  2018-04-25  7:35 ` Qu Wenruo
  2018-04-25  7:35 ` Nikolay Borisov
@ 2018-04-25  9:23 ` David Sterba
  2 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-04-25  9:23 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Wed, Apr 25, 2018 at 03:26:08PM +0800, Anand Jain wrote:
> Add a new member struct btrfs_raid_attr::raid_name so that
> btrfs_raid_array[] can maintain the name of the raid type,
> and so we can kill btrfs_raid_type_names[].
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Ok, nice.

> +		.raid_name	="raid10",

		.raid_name	= "raid10",

spaces around binary operators

>  	},
>  	[BTRFS_RAID_RAID1] = {
>  		.sub_stripes	= 1,
> @@ -61,6 +62,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 2,
>  		.ncopies	= 2,
> +		.raid_name	="raid1",
>  	},
>  	[BTRFS_RAID_DUP] = {
>  		.sub_stripes	= 1,
> @@ -70,6 +72,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 2,
> +		.raid_name	="dup",
>  	},
>  	[BTRFS_RAID_RAID0] = {
>  		.sub_stripes	= 1,
> @@ -79,6 +82,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 1,
> +		.raid_name	="raid0",
>  	},
>  	[BTRFS_RAID_SINGLE] = {
>  		.sub_stripes	= 1,
> @@ -88,6 +92,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 0,
>  		.devs_increment	= 1,
>  		.ncopies	= 1,
> +		.raid_name	="single",
>  	},
>  	[BTRFS_RAID_RAID5] = {
>  		.sub_stripes	= 1,
> @@ -97,6 +102,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 1,
>  		.devs_increment	= 1,
>  		.ncopies	= 2,
> +		.raid_name	="raid5",
>  	},
>  	[BTRFS_RAID_RAID6] = {
>  		.sub_stripes	= 1,
> @@ -106,9 +112,18 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
>  		.tolerated_failures = 2,
>  		.devs_increment	= 1,
>  		.ncopies	= 3,
> +		.raid_name	="raid6",
>  	},
>  };
>  
> +const char *get_raid_name(enum btrfs_raid_types type)
> +{
> +	if (type >= BTRFS_NR_RAID_TYPES)
> +		return NULL;
> +
> +	return btrfs_raid_array[type].raid_name;
> +}
> +
>  const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
>  	[BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
>  	[BTRFS_RAID_RAID1]  = BTRFS_BLOCK_GROUP_RAID1,
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index ef220d541d4b..2acd32ce1573 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -342,6 +342,7 @@ struct btrfs_raid_attr {
>  	int tolerated_failures; /* max tolerated fail devs */
>  	int devs_increment;	/* ndevs has to be a multiple of this */
>  	int ncopies;		/* how many copies to data has */
> +	char *raid_name;	/* name of the raid */

	const char raid_name[8];

This stores the name in the array that is const, so there's no
indirection and extra pointers.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: kill btrfs_raid_type_names[]
  2018-04-25  7:35 ` Nikolay Borisov
@ 2018-04-25  9:29   ` Anand Jain
  0 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2018-04-25  9:29 UTC (permalink / raw)
  To: Nikolay Borisov, linux-btrfs





>> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
>> index ef220d541d4b..2acd32ce1573 100644
>> --- a/fs/btrfs/volumes.h
>> +++ b/fs/btrfs/volumes.h
>> @@ -342,6 +342,7 @@ struct btrfs_raid_attr {
>>   	int tolerated_failures; /* max tolerated fail devs */
>>   	int devs_increment;	/* ndevs has to be a multiple of this */
>>   	int ncopies;		/* how many copies to data has */
>> +	char *raid_name;	/* name of the raid */
> nit: const char * ?

Its declared as const when allocated.

  const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {

Thanks, Anand

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-25  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-25  7:26 [PATCH] btrfs: kill btrfs_raid_type_names[] Anand Jain
2018-04-25  7:35 ` Qu Wenruo
2018-04-25  7:35 ` Nikolay Borisov
2018-04-25  9:29   ` Anand Jain
2018-04-25  9:23 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox