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
1212 return ctrl->ops->reset_ctrl(ctrl);1212 return ctrl->ops->reset_ctrl(ctrl);
1213 case NVME_IOCTL_SUBSYS_RESET:1213 case NVME_IOCTL_SUBSYS_RESET:
1214 return nvme_reset_subsystem(ctrl);1214 return nvme_reset_subsystem(ctrl);
1215 case NVME_IOCTL_RESCAN:
1216 nvme_queue_scan(ctrl);
1217 return 0;
1215 default:1218 default:
1216 return -ENOTTY;1219 return -ENOTTY;
1217 }1220 }
@@ -1239,6 +1242,17 @@ static ssize_t nvme_sysfs_reset(struct device *dev, · 21 unmodified lines
1239}1242}
1240static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);1243static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);
1241 1244
1245static 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}
1254static DEVICE_ATTR(rescan_controller, S_IWUSR, NULL, nvme_sysfs_rescan);
1255
1242static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,1256static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
1243 char *buf)1257 char *buf)
1244{1258{
@@ -1342,6 +1356,7 @@ nvme_show_int_function(cntlid); · 97 unmodified lines
1342 1356
1343static struct attribute *nvme_dev_attrs[] = {1357static struct attribute *nvme_dev_attrs[] = {
1344 &dev_attr_reset_controller.attr,1358 &dev_attr_reset_controller.attr,
1359 &dev_attr_rescan_controller.attr,
1345 &dev_attr_model.attr,1360 &dev_attr_model.attr,
1346 &dev_attr_serial.attr,1361 &dev_attr_serial.attr,
1347 &dev_attr_firmware_rev.attr,1362 &dev_attr_firmware_rev.attr,
include/uapi/linux/nvme_ioctl.h+1−0
@@ -61,5 +61,6 @@ struct nvme_passthru_cmd { · 60 unmodified lines
61#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)61#define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
62#define NVME_IOCTL_RESET _IO('N', 0x44)62#define NVME_IOCTL_RESET _IO('N', 0x44)
63#define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)63#define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
64#define NVME_IOCTL_RESCAN _IO('N', 0x46)
64 65
65#endif /* _UAPI_LINUX_NVME_IOCTL_H */66#endif /* _UAPI_LINUX_NVME_IOCTL_H */