[PATCH 1/8] nvmet: add debugfs support
Hannes Reinecke
hare at suse.de
Tue Mar 26 00:14:28 PDT 2024
On 3/25/24 19:18, Daniel Wagner wrote:
> On Fri, Mar 22, 2024 at 08:03:26AM +0100, Hannes Reinecke wrote:
>> +static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,
>> + size_t count, loff_t *ppos)
>> +{
>> + struct seq_file *m = file->private_data;
>> + struct nvmet_ctrl *ctrl = m->private;
>> + char reset[16];
>> +
>> + if (count >= sizeof(reset))
>> + return -EINVAL;
>> + if (copy_from_user(reset, buf, count))
>> + return -EFAULT;
>> + if (!memcmp(reset, "fatal", 5))
>> + nvmet_ctrl_fatal_error(ctrl);
>
> I'd like to use this also to trigger a reset. This allows to test the
> auth code a bit better, e.g. after changing the ctrl key on the target
> nothing will happen until a reconnect happens. Currently, I have to
> set the max queue count which triggers a reset. Also it would make the
> 'support real hardware' series for blktests why more generic.
>
> This here should does the trick in my local testing:
>
> --- a/drivers/nvme/target/debugfs.c
> +++ b/drivers/nvme/target/debugfs.c
> @@ -157,6 +157,8 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,
> return -EFAULT;
> if (!memcmp(reset, "fatal", 5))
> nvmet_ctrl_fatal_error(ctrl);
> + else if (!memcmp(reset, "reset", 5))
> + ctrl->ops->delete_ctrl(ctrl);
> else
> return -EINVAL;
> return count;
>
Weelll ... guess what the 'fatal' status does ...
I can rename it to 'reset' if you'd like, but 'fatal' corresponds to one
of the controller states, whereas 'reset' doesn't.
But I can make it an alias if you really want to write 'reset' :-)
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list