[PATCH 1/8] nvmet: add debugfs support
Daniel Wagner
dwagner at suse.de
Tue Mar 26 00:16:40 PDT 2024
On Tue, Mar 26, 2024 at 12:39:16AM +0200, Sagi Grimberg wrote:
>
>
> 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?
nvmet_ctrl_fatal_error() also calls ctrl->ops->delete_ctrl() eventually
but also logs 'fatal error occurred'. This works also just fine for what
I had in mind.
More information about the Linux-nvme
mailing list