summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-08-23 15:59:34 -0500
committerDavid Teigland <teigland@redhat.com>2017-10-18 14:09:12 -0500
commitf233a6c8ae1163ca88d22e0811466153a1c6d424 (patch)
treeeade9ca2bcca33c1a1cbe609b9d584f8352b2b72
parentafeca4edad0aa9821dca2a1d956e9105e05f2626 (diff)
downloadlvm2-f233a6c8ae1163ca88d22e0811466153a1c6d424.tar.gz
label_scan: get scan_size from config setting
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--lib/format_text/import.c4
-rw-r--r--lib/label/label.c5
-rw-r--r--lib/label/label.h8
-rw-r--r--tools/lvmcmdline.c18
5 files changed, 22 insertions, 14 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 6180f9fd7..702cc1680 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -39,6 +39,7 @@ struct config_info {
int udev_rules;
int udev_sync;
int udev_fallback;
+ int scan_size_kb;
const char *msg_prefix;
const char *fmt_name;
uint64_t unit_factor;
diff --git a/lib/format_text/import.c b/lib/format_text/import.c
index 088207448..1a62ea3dd 100644
--- a/lib/format_text/import.c
+++ b/lib/format_text/import.c
@@ -56,7 +56,7 @@ int text_read_metadata_summary(const struct format_type *fmt,
/*
* Needs data beyond the end of the async read buffer.
* Will do a new synchronous read to get the data.
- * (ASYNC_SCAN_SIZE could also be made larger.)
+ * (scan_size could also be made larger.)
*/
log_debug_metadata("async read buffer for %s too small %u for metadata offset %llu size %u",
dev_name(dev), ld->buf_len, (unsigned long long)offset, size);
@@ -177,7 +177,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
/*
* Needs data beyond the end of the async read buffer.
* Will do a new synchronous read to get the data.
- * (ASYNC_SCAN_SIZE could also be made larger.)
+ * (scan_size could also be made larger.)
*/
log_debug_metadata("async read buffer for %s too small %u for metadata offset %llu size %u",
dev_name(dev), ld->buf_len, (unsigned long long)offset, size);
diff --git a/lib/label/label.c b/lib/label/label.c
index ec0a313ba..99d2521a2 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -628,8 +628,7 @@ struct label_read_data *get_label_read_data(struct cmd_context *cmd, struct devi
*/
static int _get_scan_size(struct cmd_context *cmd)
{
- /* FIXME: make this a config setting, default to a multiple of optimal_io_size? */
- return ASYNC_SCAN_SIZE;
+ return cmd->current_settings.scan_size_kb * 1024;
}
/*
@@ -1023,7 +1022,7 @@ static int _label_scan_devs_async(struct cmd_context *cmd, struct dm_list *devs)
/*
* Process devices that have finished reading label sectors.
* Processing can include sync i/o to read metadata areas
- * beyond the ASYNC_SCAN_SIZE.
+ * beyond the scan_size.
*
* FIXME: we shouldn't need to fully reprocess everything when rescanning.
* lvmcache is already populated from the previous scan, and if nothing
diff --git a/lib/label/label.h b/lib/label/label.h
index 265477cf8..0f88511dd 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -29,14 +29,6 @@ struct labeller;
void allow_reads_with_lvmetad(void);
-/*
- * This is the amount of data read from each device
- * at the start of label scan. It's meant to be big
- * enough to cover all the headers and metadata that
- * need to be read during label scan for common cases.
- */
-#define ASYNC_SCAN_SIZE (128 * 1024)
-
struct label_read_data {
struct dev_async_io *aio;
char *buf; /* points to aio->buf */
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index a2e329dac..479453543 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2266,6 +2266,7 @@ static void _apply_current_output_settings(struct cmd_context *cmd)
static int _get_current_settings(struct cmd_context *cmd)
{
const char *activation_mode;
+ int scan_size;
_get_current_output_settings_from_args(cmd);
@@ -2391,8 +2392,23 @@ static int _get_current_settings(struct cmd_context *cmd)
#else
cmd->use_aio = 0;
if (find_config_tree_bool(cmd, metadata_scan_async_CFG, NULL))
- log_verbose("No async I/O support, ignoring metadata/scan_async.");
+ log_verbose("Ignoring scan_async, no async I/O support.");
#endif
+ scan_size = find_config_tree_int(cmd, metadata_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->current_settings.scan_size_kb = scan_size;
/* Zero indicates success */
return 0;