* [SPDK] [RFC PATCH 3/4] Add ScanTarget to optimize spdk app start time
@ 2018-05-11 3:25 Ming Lin
0 siblings, 0 replies; only message in thread
From: Ming Lin @ 2018-05-11 3:25 UTC (permalink / raw)
To: spdk
[-- Attachment #1: Type: text/plain, Size: 2732 bytes --]
From: Ming Lin <ming.lin(a)alibaba-inc.com>
For example,
[VirtioUser0]
Path /var/run/vhost.nvme0
Queues 3
Name nvme0
ScanTarget 0
"ScanTarget 0" tells virtio scsi only scans vhost target 0.
If not specified, will do a full scan.
Signed-off-by: Ming Lin <ming.lin(a)alibaba-inc.com>
---
lib/bdev/virtio/bdev_virtio_scsi.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/lib/bdev/virtio/bdev_virtio_scsi.c b/lib/bdev/virtio/bdev_virtio_scsi.c
index 0602597..e677a50 100644
--- a/lib/bdev/virtio/bdev_virtio_scsi.c
+++ b/lib/bdev/virtio/bdev_virtio_scsi.c
@@ -97,6 +97,8 @@ struct virtio_scsi_dev {
/** protect reconnect process */
pthread_mutex_t reconn_mutex;
+
+ int scan_target;
};
struct virtio_scsi_io_ctx {
@@ -351,6 +353,8 @@ virtio_user_scsi_dev_create(const char *name, const char *path,
return NULL;
}
+ svdev->scan_target = -1;
+
vdev = &svdev->vdev;
rc = virtio_user_dev_init(vdev, name, path, queue_size);
if (rc != 0) {
@@ -869,8 +873,13 @@ bdev_virtio_poll(void *arg)
if (scan_ctx->restart) {
scan_ctx->restart = false;
- scan_ctx->full_scan = true;
- _virtio_scsi_dev_scan_tgt(scan_ctx, 0);
+ if (svdev->scan_target == -1) {
+ scan_ctx->full_scan = true;
+ _virtio_scsi_dev_scan_tgt(scan_ctx, 0);
+ } else {
+ scan_ctx->full_scan = false;
+ _virtio_scsi_dev_scan_tgt(scan_ctx, svdev->scan_target);
+ }
continue;
}
@@ -1588,6 +1597,7 @@ bdev_virtio_process_config(void)
char *path, *name;
unsigned vdev_num;
int num_queues;
+ int scan_target;
bool enable_pci;
int rc = 0;
@@ -1629,6 +1639,9 @@ bdev_virtio_process_config(void)
rc = -1;
goto out;
}
+
+ scan_target = spdk_conf_section_get_intval(sp, "ScanTarget");
+ svdev->scan_target = scan_target;
}
sp = spdk_conf_find_section(NULL, "VirtioPci");
@@ -1734,9 +1747,13 @@ virtio_scsi_dev_scan(struct virtio_scsi_dev *svdev, bdev_virtio_create_cb cb_fn,
base = svdev->scan_ctx;
base->cb_fn = cb_fn;
base->cb_arg = cb_arg;
- base->full_scan = true;
-
- _virtio_scsi_dev_scan_tgt(base, 0);
+ if (svdev->scan_target == -1) {
+ base->full_scan = true;
+ _virtio_scsi_dev_scan_tgt(base, 0);
+ } else {
+ base->full_scan = false;
+ _virtio_scsi_dev_scan_tgt(base, svdev->scan_target);
+ }
return 0;
}
@@ -1766,7 +1783,7 @@ virtio_scsi_dev_scan_tgt(struct virtio_scsi_dev *svdev, uint8_t target)
}
base = svdev->scan_ctx;
- base->full_scan = true;
+ base->full_scan = (svdev->scan_target == -1) ? true : false;
_virtio_scsi_dev_scan_tgt(base, target);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-11 3:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-11 3:25 [SPDK] [RFC PATCH 3/4] Add ScanTarget to optimize spdk app start time Ming Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox