From 26f25402ff5a2473fc7b4fe3912427ccf576a15a Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Thu, 3 Aug 2023 07:29:44 +0800 Subject: [PATCH] btrfs-progs: kernel-shared: track total_devs in fs devices 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 Signed-off-by: David Sterba --- 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 6b38e74c..67b5ef1c 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; @@ -437,6 +438,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 786add2c..2fa4bf79 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -91,6 +91,7 @@ struct btrfs_fs_devices { u64 missing_devices; u64 total_rw_bytes; + u64 total_devices; int latest_bdev; int lowest_bdev; struct list_head devices;