diff mbox series

[08/11] btrfs-progs: track total_devs in fs devices

Message ID 25c9f3b987016c897132146360c5aeab0cca9a12.1688724045.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: fix bugs and CHANGING_FSID_V2 flag | expand

Commit Message

Anand Jain July 7, 2023, 3:52 p.m. UTC
Similar to the kernel, introduce the btrfs_fs_devices::total_devs
attribute to know the overall count of devices that are expected
to be present per filesystem.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 kernel-shared/volumes.c | 4 +++-
 kernel-shared/volumes.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

David Sterba July 13, 2023, 6:58 p.m. UTC | #1
On Fri, Jul 07, 2023 at 11:52:38PM +0800, Anand Jain wrote:
> Similar to the kernel, introduce the btrfs_fs_devices::total_devs
> attribute to know the overall count of devices that are expected
> to be present per filesystem.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  kernel-shared/volumes.c | 4 +++-
>  kernel-shared/volumes.h | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
> index 1e42e4fe105e..fd5890d033c8 100644
> --- a/kernel-shared/volumes.c
> +++ b/kernel-shared/volumes.c
> @@ -367,7 +367,8 @@ static int device_list_add(const char *path,
>  			       BTRFS_FSID_SIZE);
>  
>  		fs_devices->latest_devid = devid;
> -		fs_devices->latest_trans = found_transid;
> +		/* Below we would set this to found_transid */
> +		fs_devices->latest_trans = 0;
>  		fs_devices->lowest_devid = (u64)-1;
>  		fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR;
>  		device = NULL;
> @@ -438,6 +439,7 @@ static int device_list_add(const char *path,
>  	if (found_transid > fs_devices->latest_trans) {
>  		fs_devices->latest_devid = devid;
>  		fs_devices->latest_trans = found_transid;
> +		fs_devices->total_devices = device->total_devs;
>  	}
>  	if (fs_devices->lowest_devid > devid) {
>  		fs_devices->lowest_devid = devid;
> diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h
> index 93e02a901d31..09964f96ca37 100644
> --- a/kernel-shared/volumes.h
> +++ b/kernel-shared/volumes.h
> @@ -90,6 +90,7 @@ struct btrfs_fs_devices {
>  
>  	u64 total_rw_bytes;
>  
> +	int total_devices;
>  	int num_devices;
>  	int missing;

All the device counters could be added separately, that's for the
kernel/userspace parity.

>  	int latest_bdev;
> -- 
> 2.39.3
Anand Jain July 17, 2023, 7:28 p.m. UTC | #2
On 14/07/2023 02:58, David Sterba wrote:
> On Fri, Jul 07, 2023 at 11:52:38PM +0800, Anand Jain wrote:
>> Similar to the kernel, introduce the btrfs_fs_devices::total_devs
>> attribute to know the overall count of devices that are expected
>> to be present per filesystem.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   kernel-shared/volumes.c | 4 +++-
>>   kernel-shared/volumes.h | 1 +
>>   2 files changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
>> index 1e42e4fe105e..fd5890d033c8 100644
>> --- a/kernel-shared/volumes.c
>> +++ b/kernel-shared/volumes.c
>> @@ -367,7 +367,8 @@ static int device_list_add(const char *path,
>>   			       BTRFS_FSID_SIZE);
>>   
>>   		fs_devices->latest_devid = devid;
>> -		fs_devices->latest_trans = found_transid;
>> +		/* Below we would set this to found_transid */
>> +		fs_devices->latest_trans = 0;
>>   		fs_devices->lowest_devid = (u64)-1;
>>   		fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR;
>>   		device = NULL;
>> @@ -438,6 +439,7 @@ static int device_list_add(const char *path,
>>   	if (found_transid > fs_devices->latest_trans) {
>>   		fs_devices->latest_devid = devid;
>>   		fs_devices->latest_trans = found_transid;
>> +		fs_devices->total_devices = device->total_devs;
>>   	}
>>   	if (fs_devices->lowest_devid > devid) {
>>   		fs_devices->lowest_devid = devid;
>> diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h
>> index 93e02a901d31..09964f96ca37 100644
>> --- a/kernel-shared/volumes.h
>> +++ b/kernel-shared/volumes.h
>> @@ -90,6 +90,7 @@ struct btrfs_fs_devices {
>>   
>>   	u64 total_rw_bytes;
>>   
>> +	int total_devices;
>>   	int num_devices;
>>   	int missing;
> 
> All the device counters could be added separately, that's for the
> kernel/userspace parity.

Hm. I didn't get this. Could you please elaborate on this?

Thanks.

> 
>>   	int latest_bdev;
>> -- 
>> 2.39.3
diff mbox series

Patch

diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
index 1e42e4fe105e..fd5890d033c8 100644
--- a/kernel-shared/volumes.c
+++ b/kernel-shared/volumes.c
@@ -367,7 +367,8 @@  static int device_list_add(const char *path,
 			       BTRFS_FSID_SIZE);
 
 		fs_devices->latest_devid = devid;
-		fs_devices->latest_trans = found_transid;
+		/* Below we would set this to found_transid */
+		fs_devices->latest_trans = 0;
 		fs_devices->lowest_devid = (u64)-1;
 		fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR;
 		device = NULL;
@@ -438,6 +439,7 @@  static int device_list_add(const char *path,
 	if (found_transid > fs_devices->latest_trans) {
 		fs_devices->latest_devid = devid;
 		fs_devices->latest_trans = found_transid;
+		fs_devices->total_devices = device->total_devs;
 	}
 	if (fs_devices->lowest_devid > devid) {
 		fs_devices->lowest_devid = devid;
diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h
index 93e02a901d31..09964f96ca37 100644
--- a/kernel-shared/volumes.h
+++ b/kernel-shared/volumes.h
@@ -90,6 +90,7 @@  struct btrfs_fs_devices {
 
 	u64 total_rw_bytes;
 
+	int total_devices;
 	int num_devices;
 	int missing;
 	int latest_bdev;