Skip to contentSkip to conversation

master - lvmcache: Use asynchronous I/O when scanning devices.

PATCH Alasdair Kergon 1 participant 1 message Feb 9, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=db41fe6c5dab7ff66db9c0568f0e1e1b31657be3
Commit:        db41fe6c5dab7ff66db9c0568f0e1e1b31657be3
Parent:        8c7bbcfb0f6771a10acd238057fdb7931c3fbb12
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Mon Jan 22 18:17:58 2018 +0000
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Thu Feb 8 20:15:29 2018 +0000

lvmcache: Use asynchronous I/O when scanning devices.

---
 WHATS_NEW            |    1 +
 lib/cache/lvmcache.c |   11 +++
 lib/device/dev-io.c  |  165 ++++++++++++++++++++++++++++++++++++++++++++-----
 lib/device/device.h  |    4 +
 4 files changed, 164 insertions(+), 17 deletions(-)
WHATS_NEW +1 -0
index 5aa4ed8..8ae79cf 100644
@@ -1,5 +1,6 @@
 Version 2.02.178 - 
 =====================================
+  Support asynchronous I/O when scanning devices.
   Detect asynchronous I/O capability in configure or accept --disable-aio.
   Add AIO_SUPPORTED_CODE_PATH to indicate whether AIO may be used.
   Configure ensures /usr/bin dir is checked for dmpd tools.
lib/cache/lvmcache.c +11 -0
index 2eaf479..7678290 100644
@@ -1103,6 +1103,11 @@ static void _process_label_data(int failed, unsigned ioflags, void *context, con
 {
 	int *nr_labels_outstanding = context;
 
+	if (!*nr_labels_outstanding) {
+		log_error(INTERNAL_ERROR "_process_label_data called too many times");
+		return;
+	}
+
 	(*nr_labels_outstanding)--;
 }
 
@@ -1163,6 +1168,12 @@ int lvmcache_label_scan(struct cmd_context *cmd)
 
 	dev_iter_destroy(iter);
 
+	while (nr_labels_outstanding) {
+		log_very_verbose("Scanned %d device labels (%d outstanding)", dev_count, nr_labels_outstanding);
+		if (!dev_async_getevents())
+			return_0;
+	}
+
 	log_very_verbose("Scanned %d device labels (%d outstanding)", dev_count, nr_labels_outstanding);
 
 	/*
lib/device/dev-io.c +148 -17

273 lines not on this page · raw message

lib/device/device.h +4 -0
index 37d2fd2..b52522d 100644
@@ -97,6 +97,9 @@ struct device_buffer {
 	struct device_area where;	/* Location of buf */
 	dev_io_reason_t reason;
 	unsigned write:1;	/* 1 if write; 0 if read */
+
+	lvm_callback_fn_t dev_read_callback_fn;
+	void *dev_read_callback_context;
 };
 
 /*
@@ -203,6 +206,7 @@ void devbufs_release(struct device *dev);
 const char *dev_name_confirmed(struct device *dev, int quiet);
 
 struct cmd_context;
+int dev_async_getevents(void);
 int dev_async_setup(struct cmd_context *cmd);
 void dev_async_exit(void);
 int dev_async_reset(struct cmd_context *cmd);