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