[PATCH 4/9] libnvme: add support for retrieving per-path gendisk I/O statistics
Daniel Wagner
dwagner at suse.de
Tue Mar 24 02:05:01 PDT 2026
On Sat, Mar 21, 2026 at 08:58:03PM +0530, Nilay Shroff wrote:
> +static int nvme_update_stat(const char *sysfs_stat_path, nvme_stat_t stat)
> +{
> + int n;
> + struct timespec ts;
> + unsigned long rd_ios, rd_merges, wr_ios, wr_merges;
> + unsigned long dc_ios, dc_merges, fl_ios;
> + unsigned long long rd_sectors, wr_sectors, dc_sectors;
> + unsigned int rd_ticks, wr_ticks, dc_ticks, fl_ticks;
> + unsigned int io_ticks, tot_ticks, inflights;
> +
> + memset(stat, 0, sizeof(struct nvme_stat));
> +
> + n = sscanf(sysfs_stat_path,
> + "%lu %lu %llu %u %lu %lu %llu %u %u %u %u %lu %lu %llu %u %lu %u",
> + &rd_ios, &rd_merges, &rd_sectors, &rd_ticks,
> + &wr_ios, &wr_merges, &wr_sectors, &wr_ticks,
> + &inflights, &io_ticks, &tot_ticks,
> + &dc_ios, &dc_merges, &dc_sectors, &dc_ticks,
> + &fl_ios, &fl_ticks);
> +
> + if (n < 17)
> + return -1;
return a proper error code, e.g. -EINVAL or whatever matches better.
> +__public int nvme_path_update_stat(nvme_path_t p, int curr)
Do we need to expose 'curr' to the user? I'd prefer not to expose this
implementation detail to the user if possible.
> +{
> + _cleanup_free_ char *sysfs_stat_path = NULL;
> + nvme_stat_t stat;
> +
> + stat = nvme_path_get_stat(p, curr);
> + if (!stat)
> + return -1;
return an error code instead -1. same comment for the rest of the patch.
> +__public unsigned int nvme_path_get_io_ticks(nvme_path_t p, int this)
> +{
> + nvme_stat_t curr, prev;
> +
> + curr = nvme_path_get_stat(p, this);
> + prev = nvme_path_get_stat(p, !this);
Do we really need to expose 'this'?
More information about the Linux-nvme
mailing list