diff mbox series

[03/11] btrfs-progs: track missing device counter

Message ID cd1a6eb0c0c04105d5e3ae76a4959ef89c704cd1.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
Maintain the btrfs_fs_devices::missing counter to track the number of
missing devices.

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

Patch

diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
index d20cb3177a34..671396dba689 100644
--- a/kernel-shared/volumes.c
+++ b/kernel-shared/volumes.c
@@ -2156,6 +2156,7 @@  static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
 			       (unsigned long long)devid);
 			list_add(&map->stripes[i].dev->dev_list,
 				 &fs_info->fs_devices->devices);
+			fs_info->fs_devices->missing++;
 		}
 
 	}
@@ -2259,6 +2260,7 @@  static int read_one_dev(struct btrfs_fs_info *fs_info,
 		device->fd = -1;
 		list_add(&device->dev_list,
 			 &fs_info->fs_devices->devices);
+		fs_info->fs_devices->missing++;
 	}
 
 	fill_device_from_item(leaf, dev_item, device);
diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h
index ab5ac40269bb..d2915681e6de 100644
--- a/kernel-shared/volumes.h
+++ b/kernel-shared/volumes.h
@@ -90,6 +90,7 @@  struct btrfs_fs_devices {
 
 	u64 total_rw_bytes;
 
+	int missing;
 	int latest_bdev;
 	int lowest_bdev;
 	struct list_head devices;