NVMe: Allow user initiated rescan
This exposes ioctl and sysfs methods a user can invoke to request the driver rescan a controller and its namespaces. This is less harsh than doing a controller reset, which temporarilly halts all IO, just to surface a newly attached namespace. This is mainly useful for controllers that implement the namespace management command, but do not support the namespace notify change asynchronous event notification. Signed-off-by: Keith Busch <keith.busch@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Родитель
d011fb3164
Коммит
9ec3bb2f99
|
@ -1212,6 +1212,9 @@ static long nvme_dev_ioctl(struct file *file, unsigned int cmd,
|
||||||
return ctrl->ops->reset_ctrl(ctrl);
|
return ctrl->ops->reset_ctrl(ctrl);
|
||||||
case NVME_IOCTL_SUBSYS_RESET:
|
case NVME_IOCTL_SUBSYS_RESET:
|
||||||
return nvme_reset_subsystem(ctrl);
|
return nvme_reset_subsystem(ctrl);
|
||||||
|
case NVME_IOCTL_RESCAN:
|
||||||
|
nvme_queue_scan(ctrl);
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
@ -1239,6 +1242,17 @@ static ssize_t nvme_sysfs_reset(struct device *dev,
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);
|
static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);
|
||||||
|
|
||||||
|
static ssize_t nvme_sysfs_rescan(struct device *dev,
|
||||||
|
struct device_attribute *attr, const char *buf,
|
||||||
|
size_t count)
|
||||||
|
{
|
||||||
|
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
nvme_queue_scan(ctrl);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
static DEVICE_ATTR(rescan_controller, S_IWUSR, NULL, nvme_sysfs_rescan);
|
||||||
|
|
||||||
static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
|
static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
|
@ -1342,6 +1356,7 @@ nvme_show_int_function(cntlid);
|
||||||
|
|
||||||
static struct attribute *nvme_dev_attrs[] = {
|
static struct attribute *nvme_dev_attrs[] = {
|
||||||
&dev_attr_reset_controller.attr,
|
&dev_attr_reset_controller.attr,
|
||||||
|
&dev_attr_rescan_controller.attr,
|
||||||
&dev_attr_model.attr,
|
&dev_attr_model.attr,
|
||||||
&dev_attr_serial.attr,
|
&dev_attr_serial.attr,
|
||||||
&dev_attr_firmware_rev.attr,
|
&dev_attr_firmware_rev.attr,
|
||||||
|
|
|
@ -61,5 +61,6 @@ struct nvme_passthru_cmd {
|
||||||
#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
|
#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
|
||||||
#define NVME_IOCTL_RESET _IO('N', 0x44)
|
#define NVME_IOCTL_RESET _IO('N', 0x44)
|
||||||
#define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
|
#define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
|
||||||
|
#define NVME_IOCTL_RESCAN _IO('N', 0x46)
|
||||||
|
|
||||||
#endif /* _UAPI_LINUX_NVME_IOCTL_H */
|
#endif /* _UAPI_LINUX_NVME_IOCTL_H */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче