diff mbox series

[07/10] btrfs-progs: track num_devices per fs_devices

Message ID bef7d89c5e6564fcd621787a647fedfe72f94c0b.1690985783.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series fixes and preparatory related to metadata_uuid | expand

Commit Message

Anand Jain Aug. 2, 2023, 11:29 p.m. UTC
Similar to the kernel we need to track the number of devices scanned
per fs_devices. A preparation patch to fix incomplete fsid changing.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Maintains parity with the kernel.

 kernel-shared/volumes.c | 1 +
 kernel-shared/volumes.h | 1 +
 2 files changed, 2 insertions(+)

Comments

David Sterba Aug. 11, 2023, 5:41 p.m. UTC | #1
On Thu, Aug 03, 2023 at 07:29:43AM +0800, Anand Jain wrote:
> Similar to the kernel we need to track the number of devices scanned
> per fs_devices. A preparation patch to fix incomplete fsid changing.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Patch looks ok and makes sense but it crashes on segfault with test 001
in misc-tests. I haven't analyzed what exactly it is but given that
there's only one pointer dereference it must be it. Reverting the patch
makes it work (with the whole series applied), so I'll drop it for now
so you can have a look.
Anand Jain Aug. 14, 2023, 11:16 a.m. UTC | #2
On 12/8/23 01:41, David Sterba wrote:
> On Thu, Aug 03, 2023 at 07:29:43AM +0800, Anand Jain wrote:
>> Similar to the kernel we need to track the number of devices scanned
>> per fs_devices. A preparation patch to fix incomplete fsid changing.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> 
> Patch looks ok and makes sense but it crashes on segfault with test 001
> in misc-tests. I haven't analyzed what exactly it is but given that
> there's only one pointer dereference it must be it. Reverting the patch
> makes it work (with the whole series applied), so I'll drop it for now
> so you can have a look.


Run the command: $ make clean-all to fix it.

It appears that the struct btrfs_fs_devices is used somewhere
statically?, and it gets updated only with a clean compile.

Since this has not been integrated yet, would it be better for
me to include it in the upcoming btrfs-progs patchset?

Thanks, Anand
Anand Jain Aug. 14, 2023, 3:30 p.m. UTC | #3
On 14/08/2023 19:16, Anand Jain wrote:
> 
> 
> On 12/8/23 01:41, David Sterba wrote:
>> On Thu, Aug 03, 2023 at 07:29:43AM +0800, Anand Jain wrote:
>>> Similar to the kernel we need to track the number of devices scanned
>>> per fs_devices. A preparation patch to fix incomplete fsid changing.
>>>
>>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>>
>> Patch looks ok and makes sense but it crashes on segfault with test 001
>> in misc-tests. I haven't analyzed what exactly it is but given that
>> there's only one pointer dereference it must be it. Reverting the patch
>> makes it work (with the whole series applied), so I'll drop it for now
>> so you can have a look.
> 
> 
> Run the command: $ make clean-all to fix it.
> 
> It appears that the struct btrfs_fs_devices is used somewhere
> statically?, and it gets updated only with a clean compile.
> 
> Since this has not been integrated yet, would it be better for
> me to include it in the upcoming btrfs-progs patchset?
> 

This patch is now part of the new patchset in the ML.

  [PATCH 00/16] btrfs-progs: recover from failed metadata_uuid
port kernel



> Thanks, Anand
diff mbox series

Patch

diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
index 375ceaa93de4..88d6c51e3e7e 100644
--- a/kernel-shared/volumes.c
+++ b/kernel-shared/volumes.c
@@ -405,6 +405,7 @@  static int device_list_add(const char *path,
 			btrfs_stack_device_bytes_used(&disk_super->dev_item);
 		list_add(&device->dev_list, &fs_devices->devices);
 		device->fs_devices = fs_devices;
+		fs_devices->num_devices++;
 	} else if (!device->name || strcmp(device->name, path)) {
 		char *name;
 
diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h
index 786add2c879d..fe8802a9fb38 100644
--- a/kernel-shared/volumes.h
+++ b/kernel-shared/volumes.h
@@ -88,6 +88,7 @@  struct btrfs_fs_devices {
 	u64 latest_trans;
 	u64 lowest_devid;
 
+	u64 num_devices;
 	u64 missing_devices;
 	u64 total_rw_bytes;