|
|
c63e28 |
lib/commands/toolcontext.c | 2 ++
|
|
|
c63e28 |
lib/config/config_settings.h | 8 ++++++++
|
|
|
c63e28 |
lib/config/defaults.h | 2 ++
|
|
|
c63e28 |
lib/label/label.c | 40 ++++++++++++++++++++--------------------
|
|
|
c63e28 |
lib/misc/lvm-globals.c | 10 ++++++++++
|
|
|
c63e28 |
lib/misc/lvm-globals.h | 3 +++
|
|
|
c63e28 |
6 files changed, 45 insertions(+), 20 deletions(-)
|
|
|
c63e28 |
|
|
|
c63e28 |
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
|
|
|
c63e28 |
index 4d3f744..95b2317 100644
|
|
|
c63e28 |
--- a/lib/commands/toolcontext.c
|
|
|
c63e28 |
+++ b/lib/commands/toolcontext.c
|
|
|
c63e28 |
@@ -693,6 +693,8 @@ static int _process_config(struct cmd_context *cmd)
|
|
|
c63e28 |
if (!_init_system_id(cmd))
|
|
|
c63e28 |
return_0;
|
|
|
c63e28 |
|
|
|
c63e28 |
+ init_io_memory_size(find_config_tree_int(cmd, global_io_memory_size_CFG, NULL));
|
|
|
c63e28 |
+
|
|
|
c63e28 |
return 1;
|
|
|
c63e28 |
}
|
|
|
c63e28 |
|
|
|
c63e28 |
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
|
|
|
c63e28 |
index 2de3fd4..c3e9600 100644
|
|
|
c63e28 |
--- a/lib/config/config_settings.h
|
|
|
c63e28 |
+++ b/lib/config/config_settings.h
|
|
|
c63e28 |
@@ -1138,6 +1138,14 @@ cfg(global_notify_dbus_CFG, "notify_dbus", global_CFG_SECTION, 0, CFG_TYPE_BOOL,
|
|
|
c63e28 |
"When enabled, an LVM command that changes PVs, changes VG metadata,\n"
|
|
|
c63e28 |
"or changes the activation state of an LV will send a notification.\n")
|
|
|
c63e28 |
|
|
|
c63e28 |
+cfg(global_io_memory_size_CFG, "io_memory_size", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_IO_MEMORY_SIZE_KB, vsn(2, 2, 184), NULL, 0, NULL,
|
|
|
c63e28 |
+ "The amount of memory in KiB that LVM allocates to perform disk io.\n"
|
|
|
c63e28 |
+ "LVM performance may benefit from more io memory when there are many\n"
|
|
|
c63e28 |
+ "disks or VG metadata is large. Increasing this size may be necessary\n"
|
|
|
c63e28 |
+ "when a single copy of VG metadata is larger than the current setting.\n"
|
|
|
c63e28 |
+ "This value should usually not be decreased from the default; setting\n"
|
|
|
c63e28 |
+ "it too low can result in lvm failing to read VGs.\n")
|
|
|
c63e28 |
+
|
|
|
c63e28 |
cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL, 0, NULL,
|
|
|
c63e28 |
"Use udev notifications to synchronize udev and LVM.\n"
|
|
|
c63e28 |
"The --nodevsync option overrides this setting.\n"
|
|
|
c63e28 |
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
|
|
|
c63e28 |
index b3e6c34..690bf56 100644
|
|
|
c63e28 |
--- a/lib/config/defaults.h
|
|
|
c63e28 |
+++ b/lib/config/defaults.h
|
|
|
c63e28 |
@@ -267,4 +267,6 @@
|
|
|
c63e28 |
#define DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD 100
|
|
|
c63e28 |
#define DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT 20
|
|
|
c63e28 |
|
|
|
c63e28 |
+#define DEFAULT_IO_MEMORY_SIZE_KB 4096
|
|
|
c63e28 |
+
|
|
|
c63e28 |
#endif /* _LVM_DEFAULTS_H */
|
|
|
c63e28 |
diff --git a/lib/label/label.c b/lib/label/label.c
|
|
|
c63e28 |
index 03726d0..4ec7d9b 100644
|
|
|
c63e28 |
--- a/lib/label/label.c
|
|
|
c63e28 |
+++ b/lib/label/label.c
|
|
|
c63e28 |
@@ -772,33 +772,33 @@ out:
|
|
|
c63e28 |
}
|
|
|
c63e28 |
|
|
|
c63e28 |
/*
|
|
|
c63e28 |
- * How many blocks to set up in bcache? Is 1024 a good max?
|
|
|
c63e28 |
+ * num_devs is the number of devices the caller is going to scan.
|
|
|
c63e28 |
+ * When 0 the caller doesn't know, and we use the default cache size.
|
|
|
c63e28 |
+ * When non-zero, allocate at least num_devs bcache blocks.
|
|
|
c63e28 |
+ * num_devs doesn't really tell us how many bcache blocks we'll use
|
|
|
c63e28 |
+ * because it includes lvm devs and non-lvm devs, and each lvm dev
|
|
|
c63e28 |
+ * will often use a number of bcache blocks.
|
|
|
c63e28 |
*
|
|
|
c63e28 |
- * Currently, we tell bcache to set up N blocks where N
|
|
|
c63e28 |
- * is the number of devices that are going to be scanned.
|
|
|
c63e28 |
- * Reasons why this number may not be be a good choice:
|
|
|
c63e28 |
- *
|
|
|
c63e28 |
- * - there may be a lot of non-lvm devices, which
|
|
|
c63e28 |
- * would make this number larger than necessary
|
|
|
c63e28 |
- *
|
|
|
c63e28 |
- * - each lvm device may use more than one cache
|
|
|
c63e28 |
- * block if the metadata is large enough or it
|
|
|
c63e28 |
- * uses more than one metadata area, which
|
|
|
c63e28 |
- * would make this number smaller than it
|
|
|
c63e28 |
- * should be for the best performance.
|
|
|
c63e28 |
- *
|
|
|
c63e28 |
- * This is even more tricky to estimate when lvmetad
|
|
|
c63e28 |
- * is used, because it's hard to predict how many
|
|
|
c63e28 |
- * devs might need to be scanned when using lvmetad.
|
|
|
c63e28 |
- * This currently just sets up bcache with MIN blocks.
|
|
|
c63e28 |
+ * We don't know ahead of time if we will find some VG metadata
|
|
|
c63e28 |
+ * that is larger than the total size of the bcache, which would
|
|
|
c63e28 |
+ * prevent us from reading/writing the VG since we do not dynamically
|
|
|
c63e28 |
+ * increase the bcache size when we find it's too small. In these
|
|
|
c63e28 |
+ * cases the user would need to set io_memory_size to be larger
|
|
|
c63e28 |
+ * than the max VG metadata size (lvm does not impose any limit on
|
|
|
c63e28 |
+ * the metadata size.)
|
|
|
c63e28 |
*/
|
|
|
c63e28 |
|
|
|
c63e28 |
-#define MIN_BCACHE_BLOCKS 32
|
|
|
c63e28 |
+#define MIN_BCACHE_BLOCKS 32 /* 4MB, currently matches DEFAULT_IO_MEMORY_SIZE_KB */
|
|
|
c63e28 |
#define MAX_BCACHE_BLOCKS 1024
|
|
|
c63e28 |
|
|
|
c63e28 |
-static int _setup_bcache(int cache_blocks)
|
|
|
c63e28 |
+static int _setup_bcache(int num_devs)
|
|
|
c63e28 |
{
|
|
|
c63e28 |
struct io_engine *ioe = NULL;
|
|
|
c63e28 |
+ int iomem_kb = io_memory_size();
|
|
|
c63e28 |
+ int block_size_kb = (BCACHE_BLOCK_SIZE_IN_SECTORS * 512) / 1024;
|
|
|
c63e28 |
+ int cache_blocks;
|
|
|
c63e28 |
+
|
|
|
c63e28 |
+ cache_blocks = iomem_kb / block_size_kb;
|
|
|
c63e28 |
|
|
|
c63e28 |
if (cache_blocks < MIN_BCACHE_BLOCKS)
|
|
|
c63e28 |
cache_blocks = MIN_BCACHE_BLOCKS;
|
|
|
c63e28 |
diff --git a/lib/misc/lvm-globals.c b/lib/misc/lvm-globals.c
|
|
|
c63e28 |
index 82c5706..3bd5cac 100644
|
|
|
c63e28 |
--- a/lib/misc/lvm-globals.c
|
|
|
c63e28 |
+++ b/lib/misc/lvm-globals.c
|
|
|
c63e28 |
@@ -54,6 +54,7 @@ static char _sysfs_dir_path[PATH_MAX] = "";
|
|
|
c63e28 |
static int _dev_disable_after_error_count = DEFAULT_DISABLE_AFTER_ERROR_COUNT;
|
|
|
c63e28 |
static uint64_t _pv_min_size = (DEFAULT_PV_MIN_SIZE_KB * 1024L >> SECTOR_SHIFT);
|
|
|
c63e28 |
static const char *_unknown_device_name = DEFAULT_UNKNOWN_DEVICE_NAME;
|
|
|
c63e28 |
+static int _io_memory_size_kb = DEFAULT_IO_MEMORY_SIZE_KB;
|
|
|
c63e28 |
|
|
|
c63e28 |
void init_verbose(int level)
|
|
|
c63e28 |
{
|
|
|
c63e28 |
@@ -387,3 +388,12 @@ void init_unknown_device_name(const char *name)
|
|
|
c63e28 |
_unknown_device_name = name;
|
|
|
c63e28 |
}
|
|
|
c63e28 |
|
|
|
c63e28 |
+int io_memory_size(void)
|
|
|
c63e28 |
+{
|
|
|
c63e28 |
+ return _io_memory_size_kb;
|
|
|
c63e28 |
+}
|
|
|
c63e28 |
+
|
|
|
c63e28 |
+void init_io_memory_size(int val)
|
|
|
c63e28 |
+{
|
|
|
c63e28 |
+ _io_memory_size_kb = val;
|
|
|
c63e28 |
+}
|
|
|
c63e28 |
diff --git a/lib/misc/lvm-globals.h b/lib/misc/lvm-globals.h
|
|
|
c63e28 |
index f985cfa..3007cc5 100644
|
|
|
c63e28 |
--- a/lib/misc/lvm-globals.h
|
|
|
c63e28 |
+++ b/lib/misc/lvm-globals.h
|
|
|
c63e28 |
@@ -53,6 +53,7 @@ void init_pv_min_size(uint64_t sectors);
|
|
|
c63e28 |
void init_activation_checks(int checks);
|
|
|
c63e28 |
void init_retry_deactivation(int retry);
|
|
|
c63e28 |
void init_unknown_device_name(const char *name);
|
|
|
c63e28 |
+void init_io_memory_size(int val);
|
|
|
c63e28 |
|
|
|
c63e28 |
void set_cmd_name(const char *cmd_name);
|
|
|
c63e28 |
const char *get_cmd_name(void);
|
|
|
c63e28 |
@@ -86,6 +87,7 @@ uint64_t pv_min_size(void);
|
|
|
c63e28 |
int activation_checks(void);
|
|
|
c63e28 |
int retry_deactivation(void);
|
|
|
c63e28 |
const char *unknown_device_name(void);
|
|
|
c63e28 |
+int io_memory_size(void);
|
|
|
c63e28 |
|
|
|
c63e28 |
#define DMEVENTD_MONITOR_IGNORE -1
|
|
|
c63e28 |
int dmeventd_monitor_mode(void);
|
|
|
c63e28 |
@@ -93,4 +95,5 @@ int dmeventd_monitor_mode(void);
|
|
|
c63e28 |
#define NO_DEV_ERROR_COUNT_LIMIT 0
|
|
|
c63e28 |
int dev_disable_after_error_count(void);
|
|
|
c63e28 |
|
|
|
c63e28 |
+
|
|
|
c63e28 |
#endif
|