summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-10-24 15:13:04 -0500
committerDavid Teigland <teigland@redhat.com>2017-11-02 15:24:35 -0500
commit38f9c89991064f833a73f14bd9c9f402a338f7f6 (patch)
tree300e9c795729989dc4f062ae95dd24d7ab7b299e
parenta41ffd52d6bf0c6357d25aade0d6d8ea0ad2431d (diff)
downloadlvm2-38f9c89991064f833a73f14bd9c9f402a338f7f6.tar.gz
command: add settings to enable async io
There are config settings to enable aio, and to configure the concurrency and read size.
-rw-r--r--daemons/clvmd/lvm-functions.c2
-rw-r--r--lib/commands/toolcontext.c26
-rw-r--r--lib/commands/toolcontext.h2
-rw-r--r--lib/config/config_settings.h17
-rw-r--r--lib/config/defaults.h2
5 files changed, 49 insertions, 0 deletions
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index e872fbe49..84b3b5587 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -661,6 +661,7 @@ int do_refresh_cache(void)
return -1;
}
+ cmd->use_aio = 0;
init_full_scan_done(0);
init_ignore_suspended_devices(1);
lvmcache_force_next_label_scan();
@@ -920,6 +921,7 @@ int init_clvm(struct dm_hash_table *excl_uuid)
/* Check lvm.conf is setup for cluster-LVM */
check_config();
init_ignore_suspended_devices(1);
+ cmd->use_aio = 0;
/* Trap log messages so we can pass them back to the user */
init_log_fn(lvm2_log_fn);
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index e742df5e0..9f86c13e4 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -542,6 +542,7 @@ static int _process_config(struct cmd_context *cmd)
const struct dm_config_value *cv;
int64_t pv_min_kb;
int udev_disabled = 0;
+ int scan_size_kb;
char sysfs_dir[PATH_MAX];
if (!_check_config(cmd))
@@ -625,6 +626,29 @@ static int _process_config(struct cmd_context *cmd)
cmd->default_settings.udev_sync = udev_disabled ? 0 :
find_config_tree_bool(cmd, activation_udev_sync_CFG, NULL);
+#ifdef AIO_SUPPORT
+ cmd->use_aio = find_config_tree_bool(cmd, devices_scan_async_CFG, NULL);
+#else
+ cmd->use_aio = 0;
+ if (find_config_tree_bool(cmd, devices_scan_async_CFG, NULL))
+ log_verbose("Ignoring scan_async, no async I/O support.");
+#endif
+ scan_size_kb = find_config_tree_int(cmd, devices_scan_size_CFG, NULL);
+
+ if (!scan_size_kb || (scan_size_kb < 0) || (scan_size_kb % 4)) {
+ log_warn("WARNING: Ignoring invalid scan_size %d KB, using default %u KB.",
+ scan_size_kb, DEFAULT_SCAN_SIZE_KB);
+ log_warn("scan_size has units of KB and must be a multiple of 4 KB.");
+ scan_size_kb = DEFAULT_SCAN_SIZE_KB;
+ }
+
+ cmd->default_settings.scan_size_kb = scan_size_kb;
+
+ if (cmd->use_aio)
+ log_debug("Using async io with scan_size %u KB.", scan_size_kb);
+ else
+ log_debug("Using sync io with scan_size %u KB.", scan_size_kb);
+
/*
* Set udev_fallback lazily on first use since it requires
* checking DM driver version which is an extra ioctl!
@@ -2226,6 +2250,8 @@ void destroy_toolcontext(struct cmd_context *cmd)
!cmd->filter->dump(cmd->filter, 1))
stack;
+ label_scan_destroy(cmd);
+
archive_exit(cmd);
backup_exit(cmd);
lvmcache_destroy(cmd, 0, 0);
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index bf2b25124..10987ee72 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -40,6 +40,7 @@ struct config_info {
int udev_sync;
int udev_fallback;
int cache_vgmetadata;
+ int scan_size_kb;
const char *msg_prefix;
const char *fmt_name;
uint64_t unit_factor;
@@ -164,6 +165,7 @@ struct cmd_context {
unsigned vg_notify:1;
unsigned lv_notify:1;
unsigned pv_notify:1;
+ unsigned use_aio:1;
/*
* Filtering.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 7d800b3d8..33ebee9d9 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -457,6 +457,23 @@ cfg(devices_allow_changes_with_duplicate_pvs_CFG, "allow_changes_with_duplicate_
"Enabling this setting allows the VG to be used as usual even with\n"
"uncertain devices.\n")
+cfg(devices_scan_async_CFG, "scan_async", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_SCAN_ASYNC, vsn(2, 2, 173), NULL, 0, NULL,
+ "Use async I/O to read headers and metadata from disks in parallel.\n")
+
+cfg(devices_scan_size_CFG, "scan_size", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_SCAN_SIZE_KB, vsn(2, 2, 173), NULL, 0, NULL,
+ "Number of KiB to read from each disk when scanning disks.\n"
+ "The initial scan size is intended to cover all the headers\n"
+ "and metadata that LVM places at the start of each disk so\n"
+ "that a single read operation can retrieve them all.\n"
+ "Any headers or metadata that lie beyond this size require\n"
+ "an additional disk read. Must be a multiple of 4KiB.\n")
+
+cfg(devices_async_events_CFG, "async_events", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_ASYNC_EVENTS, vsn(2, 2, 173), NULL, 0, NULL,
+ "Max number of concurrent async reads when scanning disks.\n"
+ "Up to this many disks can be read concurrently when scanning\n"
+ "disks with async I/O. This setting may be limited by the system\n"
+ "aio configuration.\n")
+
cfg_array(allocation_cling_tag_list_CFG, "cling_tag_list", allocation_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 77), NULL, 0, NULL,
"Advise LVM which PVs to use when searching for new space.\n"
"When searching for free space to extend an LV, the 'cling' allocation\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 8da8670d1..533aad11a 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -268,5 +268,7 @@
#define DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT 20
#define DEFAULT_ASYNC_EVENTS 100
+#define DEFAULT_SCAN_ASYNC 1
+#define DEFAULT_SCAN_SIZE_KB 128
#endif /* _LVM_DEFAULTS_H */