Skip to content

Commit

Permalink
Merge #1608
Browse files Browse the repository at this point in the history
1608: feat(callhome): add bustype and rotational properties to block device r=datacore-vvarakantham a=datacore-vvarakantham

Added bus type("connection_type") and rotational ("is_rotational") properties to block device to be able to generate storage media metrics.

connection_type: the type of bus through which the device is connected to the system
is_rotational: indicates whether the device is rotational or non-rotational

Co-authored-by: Vandana Varakantham <[email protected]>
  • Loading branch information
mayastor-bors and datacore-vvarakantham committed Apr 15, 2024
2 parents cc76cfd + b82d6c2 commit 3a9face
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions io-engine/src/grpc/v1/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ impl From<blk_device::BlockDevice> for host_rpc::BlockDevice {
partition: b.partition.map(host_rpc::Partition::from),
filesystem: b.filesystem.map(host_rpc::Filesystem::from),
available: b.available,
connection_type: b.connection_type,
is_rotational: b.is_rotational,
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions io-engine/src/host/blk_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub struct BlockDevice {
pub partition: Option<Partition>,
pub filesystem: Option<FileSystem>,
pub available: bool,
pub connection_type: String,
pub is_rotational: Option<bool>,
}

impl From<Property<'_>> for String {
Expand Down Expand Up @@ -249,13 +251,18 @@ fn new_device(
&& (partition.is_none() || usable_partition(&partition))
&& filesystem.is_none();

let rotational_attribute: Option<String> =
Property(device.attribute_value("queue/rotational")).into();

return Some(BlockDevice {
devname: String::from(devname.to_str().unwrap_or("")),
devtype: Property(device.property_value("DEVTYPE")).into(),
devmaj: devmajor,
devmin: Property(device.property_value("MINOR")).into(),
model: Property(device.property_value("ID_MODEL")).into(),
devpath: Property(device.property_value("DEVPATH")).into(),
connection_type: Property(device.property_value("ID_BUS")).into(),
is_rotational: rotational_attribute.map(|s| s == "1"),
devlinks: device
.property_value("DEVLINKS")
.and_then(|s| s.to_str())
Expand Down

0 comments on commit 3a9face

Please sign in to comment.