[PATCHv2] nvme: add 'fail_if_no_path' sysfs attribute

Minwoo Im minwoo.im.dev at gmail.com
Mon Feb 22 05:15:19 EST 2021


On 21-02-22 07:41:55, Hannes Reinecke wrote:
> In some setups like RAID we need to return an I/O error
> once all paths are unavailable to allow the upper layers
> to start their own error recovery (like redirecting I/O
> to other mirrors).
> This patch adds a sysfs attribute 'fail_if_no_path' to
> allow the admin to enable that behaviour instead of the
> current 'queue until a path becomes available' policy.
> 
> Signed-off-by: Hannes Reinecke <hare at suse.de>
> ---
>  drivers/nvme/host/core.c      |  5 +++++
>  drivers/nvme/host/multipath.c | 38 +++++++++++++++++++++++++++++++++--
>  drivers/nvme/host/nvme.h      |  2 ++
>  3 files changed, 43 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 5c1ec3bfb9d3..ef20029a46b2 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3466,6 +3466,7 @@ static struct attribute *nvme_ns_id_attrs[] = {
>  #ifdef CONFIG_NVME_MULTIPATH
>  	&dev_attr_ana_grpid.attr,
>  	&dev_attr_ana_state.attr,
> +	&dev_attr_fail_if_no_path.attr,
>  #endif
>  	NULL,
>  };
> @@ -3496,6 +3497,10 @@ static umode_t nvme_ns_id_attrs_are_visible(struct kobject *kobj,
>  		if (!nvme_ctrl_use_ana(nvme_get_ns_from_dev(dev)->ctrl))
>  			return 0;
>  	}
> +	if (a == &dev_attr_fail_if_no_path.attr) {
> +		if (dev_to_disk(dev)->fops == &nvme_bdev_ops)
> +			return 0;
> +	}
>  #endif
>  	return a->mode;
>  }
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 0696319adaf6..35ed2f6d431b 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -283,10 +283,13 @@ static bool nvme_available_path(struct nvme_ns_head *head)
>  			continue;
>  		switch (ns->ctrl->state) {
>  		case NVME_CTRL_LIVE:
> +			return true;

Hello Hannes,

May I ask there's any reason why LIVE state is not covered by the sysfs
attribute that this patch introduced ?  Wouldn't it be possible to have
no available paths (inaccessible) in LIVE state ?

Thanks! :)



More information about the Linux-nvme mailing list