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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user