lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 6 Dec 2023 09:59:45 +0100
From:   Christoph Hellwig <hch@....de>
To:     Daniel Wagner <dwagner@...e.de>
Cc:     linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Keith Busch <kbusch@...nel.org>,
        Christoph Hellwig <hch@....de>,
        Sagi Grimberg <sagi@...mberg.me>,
        Hannes Reinecke <hare@...e.de>
Subject: Re: [PATCH v3 4/4] nvme: add csi, ms and nuse to sysfs

On Wed, Dec 06, 2023 at 09:12:44AM +0100, Daniel Wagner wrote:
> libnvme is using the sysfs for enumarating the nvme resources. Though
> there are few missing attritbutes in the sysfs. For these libnvme issues
> commands during discovering.
> 
> As the kernel already knows all these attributes and we would like to
> avoid libnvme to issue commands all the time, expose these missing
> attributes.
> 
> The nuse value is updated on request because the nuse is a volatile
> value. Since any user can read the sysfs attribute, a very simple rate
> limit is added (update max every 5 seconds). A more sophisticated update
> strategy can be added later if there is actually a need for it.
> 
> Signed-off-by: Daniel Wagner <dwagner@...e.de>
> ---
>  drivers/nvme/host/core.c  | 28 ++++++++++++++++++++++++++++
>  drivers/nvme/host/nvme.h  |  2 ++
>  drivers/nvme/host/sysfs.c | 31 +++++++++++++++++++++++++++++++
>  3 files changed, 61 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index caa52c2f57c8..e7dd64ee1653 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1663,6 +1663,33 @@ static void nvme_ns_release(struct nvme_ns *ns)
>  	nvme_put_ns(ns);
>  }
>  
> +int nvme_ns_update_nuse(struct nvme_ns_head *head)
> +{
> +	static DEFINE_RATELIMIT_STATE(_rs, 5 * HZ, 1);
> +	struct nvme_id_ns *id;
> +	struct nvme_ns *ns;
> +	int srcu_idx, ret = -EWOULDBLOCK;
> +
> +	if (__ratelimit(&_rs))
> +		return 0;

Can you add a comment on the ratelimiting here?

> +
> +	srcu_idx = srcu_read_lock(&head->srcu);
> +	ns = nvme_find_path(head);
> +	if (!ns)
> +		goto out_unlock;
> +
> +	ret = nvme_identify_ns(ns->ctrl, head->ns_id, &id);
> +	if (ret)
> +		goto out_unlock;
> +
> +	head->nuse = le64_to_cpu(id->nuse);

This looks like the wrong thing to do for the non-multipath nodes,
which should be able to go straight to the ns.

I'd move this to sysfs.c, and then do a similar trick to say
nvme_send_pr_command to directly use the ns for the non-multipath
nodes, and do what you're doing here for the multipath nodes.

>  static struct attribute *nvme_ns_id_attrs[] = {

And I duess the _id is not correct now, I'd just drop it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ