History

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.

Keith Busch committed 10 years ago

Commit 9ec3bb21 parent d011fb32 files · +16 −0Browse files

Unified · Split

2 files
  1. drivers/nvme/host/core.c +15 −0
  2. include/uapi/linux/nvme_ioctl.h +1 −0
drivers/nvme/host/core.c+15−0
@@ -1212,6 +1212,9 @@ static long nvme_dev_ioctl(struct file *file, unsigned int cmd, · 1211 unmodified lines
12121212 return ctrl->ops->reset_ctrl(ctrl);
12131213 case NVME_IOCTL_SUBSYS_RESET:
12141214 return nvme_reset_subsystem(ctrl);
1215+ case NVME_IOCTL_RESCAN:
1216+ nvme_queue_scan(ctrl);
1217+ return 0;
12151218 default:
12161219 return -ENOTTY;
12171220 }
@@ -1239,6 +1242,17 @@ static ssize_t nvme_sysfs_reset(struct device *dev, · 21 unmodified lines
12391242 }
12401243 static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);
12411244
1245+static ssize_t nvme_sysfs_rescan(struct device *dev,
1246+ struct device_attribute *attr, const char *buf,
1247+ size_t count)
1248+{
1249+ struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
1250+
1251+ nvme_queue_scan(ctrl);
1252+ return count;
1253+}
1254+static DEVICE_ATTR(rescan_controller, S_IWUSR, NULL, nvme_sysfs_rescan);
1255+
12421256 static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
12431257 char *buf)
12441258 {
@@ -1342,6 +1356,7 @@ nvme_show_int_function(cntlid); · 97 unmodified lines
13421356
13431357 static struct attribute *nvme_dev_attrs[] = {
13441358 &dev_attr_reset_controller.attr,
1359+ &dev_attr_rescan_controller.attr,
13451360 &dev_attr_model.attr,
13461361 &dev_attr_serial.attr,
13471362 &dev_attr_firmware_rev.attr,
include/uapi/linux/nvme_ioctl.h+1−0
@@ -61,5 +61,6 @@ struct nvme_passthru_cmd { · 60 unmodified lines
6161 #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
6262 #define NVME_IOCTL_RESET _IO('N', 0x44)
6363 #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
64+#define NVME_IOCTL_RESCAN _IO('N', 0x46)
6465
6566 #endif /* _UAPI_LINUX_NVME_IOCTL_H */