diff options
author | David Teigland <teigland@redhat.com> | 2017-08-29 10:52:04 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2017-10-18 10:05:16 -0500 |
commit | fd14c3ebb597d3d250e3b25ddb9c2862e267b1f8 (patch) | |
tree | faa8032a8a9fe72484cb5812a94ab4d6f49f71e4 | |
parent | d801cda29dfbd1162875ff7322d220fb7c5c9f22 (diff) | |
download | lvm2-fd14c3ebb597d3d250e3b25ddb9c2862e267b1f8.tar.gz |
scanning: get async events from config setting
-rw-r--r-- | lib/device/dev-io.c | 7 | ||||
-rw-r--r-- | lib/device/device.h | 9 | ||||
-rw-r--r-- | lib/label/label.c | 25 |
3 files changed, 22 insertions, 19 deletions
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c index c8743f348..9bdc5e82c 100644 --- a/lib/device/dev-io.c +++ b/lib/device/dev-io.c @@ -835,20 +835,21 @@ int dev_set(struct device *dev, uint64_t offset, size_t len, int value) struct dev_async_context *dev_async_context_setup(unsigned async_event_count) { struct dev_async_context *ac; - int max_submit_events = MAX_ASYNC_EVENTS; + unsigned nr_events = DEFAULT_ASYNC_EVENTS; int error; if (async_event_count) - max_submit_events = async_event_count; + nr_events = async_event_count; if (!(ac = malloc(sizeof(struct dev_async_context)))) return_0; memset(ac, 0, sizeof(struct dev_async_context)); - error = io_setup(max_submit_events, &ac->aio_ctx); + error = io_setup(nr_events, &ac->aio_ctx); if (error < 0) { + log_warn("WARNING: async io setup error %d with %u events.", error, nr_events); free(ac); return_0; } diff --git a/lib/device/device.h b/lib/device/device.h index 87d19bd66..eb88fc83d 100644 --- a/lib/device/device.h +++ b/lib/device/device.h @@ -98,15 +98,6 @@ struct device_area { */ #define MAX_GET_EVENTS 16 -/* - * The number of events to use in io_setup(), - * which is the limit on the number of concurrent - * async i/o's we can submit. After all these are - * used, io_submit() returns -EAGAIN, and we revert - * to doing synchronous io. - */ -#define MAX_ASYNC_EVENTS 1024 - struct dev_async_context { io_context_t aio_ctx; struct io_event events[MAX_GET_EVENTS]; diff --git a/lib/label/label.c b/lib/label/label.c index 99d2521a2..7d2ebfbff 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -732,23 +732,21 @@ static int _label_scan_async(struct cmd_context *cmd, int skip_cached) int need_wait_count; int need_process_count; int dev_count = 0; + int async_event_count; _free_label_read_list(0); buf_len = _get_scan_size(cmd); + async_event_count = find_config_tree_int(cmd, devices_async_events_CFG, NULL); + /* * if aio setup fails, caller will revert to sync scan * The number of events set up here is the max number of * concurrent async reads that can be submitted. After * all of those are used, we revert to synchronous reads. - * - * FIXME: add a config setting to control the number passed - * into setup used for max async events in io_setup(). - * (0 uses default) */ - - if (!(ac = dev_async_context_setup(0))) { + if (!(ac = dev_async_context_setup(async_event_count))) { log_debug_devs("async io setup error, reverting to sync io."); return_0; } @@ -932,12 +930,25 @@ static int _label_scan_devs_async(struct cmd_context *cmd, struct dm_list *devs) int need_wait_count; int need_process_count; int dev_count = 0; + int async_event_count; + int num_devs; buf_len = _get_scan_size(cmd); dm_list_init(&tmp_label_read_list); - if (!(ac = dev_async_context_setup(0))) { + async_event_count = find_config_tree_int(cmd, devices_async_events_CFG, NULL); + num_devs = dm_list_size(devs); + + if (num_devs < async_event_count) + async_event_count = num_devs; + + /* + * Should we set up one global aio context when the command starts, + * and then use/reuse that one context from multiple calls to + * label_scan/label_scan_devs? + */ + if (!(ac = dev_async_context_setup(async_event_count))) { log_debug_devs("async io setup error, reverting to sync io."); return_0; } |