[PATCH 1/8] nvmet: add debugfs support

Daniel Wagner dwagner at suse.de
Mon Mar 25 11:18:52 PDT 2024


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;



More information about the Linux-nvme mailing list