shared/blockdev-list: add flag to gather diskseq stats

Only one caller ever looks at this field. Let's optimize a bit.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-21 20:14:43 +02:00
parent b298d68dd0
commit ad997d0630
3 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -161,8 +161,9 @@ int vl_method_list_candidate_devices(
BLOCKDEV_LIST_SHOW_SYMLINKS|
BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING|
BLOCKDEV_LIST_IGNORE_ZRAM|
BLOCKDEV_LIST_METADATA|
BLOCKDEV_LIST_IGNORE_READ_ONLY|
BLOCKDEV_LIST_METADATA|
BLOCKDEV_LIST_DISKSEQ|
(p.ignore_empty ? BLOCKDEV_LIST_IGNORE_EMPTY : 0)|
(p.ignore_root ? BLOCKDEV_LIST_IGNORE_ROOT : 0);
+5 -3
View File
@@ -279,9 +279,11 @@ int blockdev_list_one(
}
uint64_t diskseq = UINT64_MAX;
r = sd_device_get_diskseq(dev, &diskseq);
if (r < 0)
log_device_debug_errno(dev, r, "Failed to acquire diskseq of device '%s', ignoring: %m", node);
if (FLAGS_SET(flags, BLOCKDEV_LIST_DISKSEQ)) {
r = sd_device_get_diskseq(dev, &diskseq);
if (r < 0)
log_device_debug_errno(dev, r, "Failed to acquire diskseq of device '%s', ignoring: %m", node);
}
_cleanup_free_ char *m = strdup(node);
if (!m)
+1
View File
@@ -14,6 +14,7 @@ typedef enum BlockDevListFlags {
BLOCKDEV_LIST_IGNORE_READ_ONLY = 1 << 7, /* Ignore read-only block devices */
BLOCKDEV_LIST_REQUIRE_LUKS = 1 << 8, /* Only consider block devices with LUKS superblocks */
BLOCKDEV_LIST_METADATA = 1 << 9, /* Fill in model, vendor, subsystem, read_only */
BLOCKDEV_LIST_DISKSEQ = 1 << 10, /* Fill in the diskseq field */
} BlockDevListFlags;
/* The "dynamic" filters – ones the kernel can flip at runtime via sysattrs on a live device.