From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: "kbusch@kernel.org" <kbusch@kernel.org>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
Christoph Hellwig <hch@lst.de>,
Alan Adamson <alan.adamson@oracle.com>
Subject: Re: [PATCH V8 1/1] nvme: allow passthru cmd error logging
Date: Wed, 24 Jan 2024 03:37:57 +0000 [thread overview]
Message-ID: <d23d6b6e-a2ff-4938-9f06-7da9eb07f64c@nvidia.com> (raw)
In-Reply-To: <e79e6423-3fb0-4c81-b68e-7a5ea0807027@grimberg.me>
On 1/23/24 03:33, Sagi Grimberg wrote:
>
>
> On 1/18/24 05:31, Chaitanya Kulkarni wrote:
>> Sagi,
>>
>>>> nvme_mpath_add_disk(ns, info->anagrpid);
>>>> nvme_fault_inject_init(&ns->fault_inject,
>>>> ns->disk->disk_name);
>>>> +
>>>> + /*
>>>> + * Set ns->disk->device->driver_data to ns so we can access
>>>> + * ns->logging_enabled in
>>>> nvme_passthru_err_log_enabled_store() and
>>>> + * nvme_passthru_err_log_enabled_show().
>>>> + */
>>>> + dev_set_drvdata(disk_to_dev(ns->disk), ns);
>>>
>>> Is this needed?
>>
>> Yes see explanation below ..
>>
>> [...]
>>
>>>
>>>>
>>>> static ssize_t nvme_passthru_err_log_enabled_store(struct device
>>>> *dev,
>>>> struct device_attribute *attr, const char *buf,
>>>> size_t
>>>> count)
>>>> {
>>>> - int err;
>>>> bool passthru_err_log_enabled;
>>>> + int err;
>>>>
>>>> err = kstrtobool(buf, &passthru_err_log_enabled);
>>>> if (err)
>>>> return -EINVAL;
>>>>
>>>> - dev->logging_enabled = passthru_err_log_enabled;
>>>> + if (is_nvme_class(dev->class)) {
>>>> + struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
>>>> +
>>>> + ctrl->logging_enabled = passthru_err_log_enabled;
>>>> + } else {
>>>> + struct nvme_ns *ns = dev_get_drvdata(dev);
>>>> +
>>>> + ns->logging_enabled = passthru_err_log_enabled;
>>>> + }
>>>
>>> Why mix ctrl with ns sysfs handlers?
>>
>> sorry I didn't understand your question clearly ...
>>
>> In the original implementation we get two different struct device
>> objects
>> for following commands in sysfs, that sets struct device:logging_enabled
>> flag,
>> which is also used to determine the logging in nvme_init_request() :-
>>
>> echo 1 > /sys/class/nvme/nvme0/passthru_err_log_enabled
>> echo 1 > /sys/class/nvme/nvme0/nvme0n1/passthru_err_log_enabled
>>
>> nvme_init_ctrl() already sets dev_set_drvdata(ctrl->device, ctrl). In
>> this
>> proposal above change in nvme_alloc_ns() sets the
>> dev_set_drvdata(disk_to_dev(ns->disk), ns).
>>
>> This allows us to get the ctrl or ns object associated with the struct
>> device
>> we get in the sysfs, then based on the device class we update
>> logging_enabled
>> flags for either ctrl or ns respectively. In nvme_init_request() I use
>> ctrl->logging_enabled and ns->logging_enabled based on admin or io cmd.
>
> I was asking why should we have a show/store that operate on both ns and
> ctrl?
>
> Why not have a show/store in nvme_dev_attrs and a separate one in
> nvme_ns_id_attrs ? Then you don't need the awkward is_nvme_class() ?
> the ns attrs can access the ns in a normal way like the rest? Or am
> I missing something?
no you are not, I was just trying to minimize the changes in the posted
patch guess that is a right way to go forward ...
-ck
next prev parent reply other threads:[~2024-01-24 3:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 0:08 [PATCH V8 0/1] nvme: allow passthru cmd error logging Alan Adamson
2024-01-11 0:08 ` [PATCH V8 1/1] " Alan Adamson
2024-01-11 7:04 ` Christoph Hellwig
2024-01-17 3:46 ` Chaitanya Kulkarni
2024-01-17 14:14 ` Sagi Grimberg
2024-01-18 3:31 ` Chaitanya Kulkarni
2024-01-23 11:33 ` Sagi Grimberg
2024-01-23 17:11 ` alan.adamson
2024-01-24 3:41 ` Chaitanya Kulkarni
2024-01-24 17:10 ` alan.adamson
2024-01-24 9:06 ` Christoph Hellwig
2024-01-24 3:37 ` Chaitanya Kulkarni [this message]
2024-01-25 0:52 ` alan.adamson
2024-01-29 10:24 ` Sagi Grimberg
2024-01-16 6:33 ` Chaitanya Kulkarni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d23d6b6e-a2ff-4938-9f06-7da9eb07f64c@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=alan.adamson@oracle.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox