[PATCH 1/8] nvmet: add debugfs support
Sagi Grimberg
sagi at grimberg.me
Mon Mar 25 15:39:16 PDT 2024
On 25/03/2024 20: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;
What is the difference between fatal and reset?
More information about the Linux-nvme
mailing list