Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
if (err)
return err;

if (is_blkdev(dev)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. We should be able to get the smart log page data from a NVMe block device itself, right?

Copy link
Copy Markdown
Collaborator

@igaw igaw May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far I understand the specs, it says SMART is only for the controller not a namespace.

5.1.12.1.3 SMART / Health Information (Log Page Identifier 02h)

This log page is used to provide SMART and general health information. The information provided is over
the life of the controller and is retained across power cycles unless otherwise specified. To request the
controller log page, the namespace identifier specified is FFFFFFFFh or 0h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. But I think it would be harsh if we restrict this command to char devices alone and not block devices as well, not to speak of the confusion this would generate in the field. And I believe there are multiple other areas in the code as well where the same issue exists. So we may have to be careful before enforcing such a check here.

Copy link
Copy Markdown
Collaborator

@igaw igaw May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is a result of a regression observed in blktests.

https://lore.kernel.org/linux-nvme/a25kumc6oyvzmr42jgowkf4yztmmiypxrvnygetwv6qvc2ol6b@tzhqqggcme3q/

If I read the spec right, then the block device is just wrong and it just worked because the devices are not checking the namespace identifier. If my understanding is correct I have no problem in breaking existing users. Or at least introduce a warning for nvme-cli 2.x and kill it for nvme-cli 3.x

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I stopped reading too early. The spec says:

The controller may also
support requesting the log page on a per namespace basis, as indicated by the SMART Support bit of the
LPA field in the Identify Controller data structure in Figure 312.

nvme_show_error("Only character device is allowed");
return -EINVAL;
}

err = validate_output_format(nvme_cfg.output_format, &flags);
if (err < 0) {
nvme_show_error("Invalid output format");
Expand Down