summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-10-24 15:13:04 -0500
committerDavid Teigland <teigland@redhat.com>2017-10-25 13:40:24 -0500
commitf386c040e3774584bff83981efa3b8347934b234 (patch)
treeef2c1c491c5118321643005354f7299cb1804bfa
parentb3253b98ccf5b3d67a69f87a1bae515eb3d6450e (diff)
downloadlvm2-f386c040e3774584bff83981efa3b8347934b234.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--lib/commands/toolcontext.c27
-rw-r--r--lib/commands/toolcontext.h3
-rw-r--r--lib/config/config_settings.h20
-rw-r--r--lib/config/defaults.h3
4 files changed, 53 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index e742df5e0..255e427d6 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;
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 = find_config_tree_int(cmd, devices_scan_size_CFG, NULL);
+
+ if (!scan_size || (scan_size < 0)) {
+ log_warn("WARNING: Ignoring invalid metadata/scan_size %d, using default %u.",
+ scan_size, DEFAULT_SCAN_SIZE_KB);
+ scan_size = DEFAULT_SCAN_SIZE_KB;
+ }
+
+ if (cmd->use_aio && (scan_size % 4)) {
+ log_warn("WARNING: Ignoring invalid metadata/scan_size %d with scan_async, using default %u.",
+ scan_size, DEFAULT_SCAN_SIZE_KB);
+ scan_size = DEFAULT_SCAN_SIZE_KB;
+ }
+
+ cmd->default_settings.scan_size_kb = scan_size;
+
/*
* Set udev_fallback lazily on first use since it requires
* checking DM driver version which is an extra ioctl!
@@ -2226,6 +2250,9 @@ void destroy_toolcontext(struct cmd_context *cmd)
!cmd->filter->dump(cmd->filter, 1))
stack;
+ if (cmd->ac)
+ dev_async_context_destroy(cmd->ac);
+
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..32b4cd9c0 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.
@@ -223,6 +225,7 @@ struct cmd_context {
const char *time_format;
unsigned rand_seed;
struct dm_list unused_duplicate_devs; /* save preferences between lvmcache instances */
+ struct dev_async_context *ac; /* for async i/o */
};
/*
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 7d800b3d8..3118d414d 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -457,6 +457,26 @@ 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.\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. If there are more disks than this,\n"
+ "they will be scanned serially with synchronous reads.\n"
+ "Increasing this number to match a larger number of disks may\n"
+ "improve performance, but will increase memory requirements.\n"
+ "This setting is limitted by the system 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..ac19b815b 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -268,5 +268,8 @@
#define DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT 20
#define DEFAULT_ASYNC_EVENTS 100
+#define DEFAULT_SCAN_ASYNC 1
+#define DEFAULT_SCAN_SIZE_KB 128
+#define DEFAULT_ASYNC_EVENTS 100
#endif /* _LVM_DEFAULTS_H */