1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-11 09:18:25 +03:00

Improve thin_check option passing

Update a way we handle option passing - so we now support path and options
with space inside.
Fix dm name usage for thin pools with '-' in name.
Use new lvm.conf option thin_check_options to pass in options as string array.
This commit is contained in:
Zdenek Kabelac 2012-03-14 17:12:05 +00:00
parent 303b44c8fa
commit bac0394dc6
4 changed files with 38 additions and 17 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.96 - Version 2.02.96 -
================================ ================================
Improve thin_check option passing and use configured path.
Add --with-thin-check configure option for path to thin_check. Add --with-thin-check configure option for path to thin_check.
Detect lvm binary path in lvmetad udev rules. Detect lvm binary path in lvmetad udev rules.
Fix error message when pvmove LV activation fails with name already in use. Fix error message when pvmove LV activation fails with name already in use.

View File

@ -658,7 +658,11 @@ activation {
# The thin tools are available as part of the device-mapper-persistent-data # The thin tools are available as part of the device-mapper-persistent-data
# package from https://github.com/jthornber/thin-provisioning-tools. # package from https://github.com/jthornber/thin-provisioning-tools.
# #
thin_check_executable = "/sbin/thin_check -q" thin_check_executable = "@THIN_CHECK_CMD@"
# String with options passed with thin_check command. By default,
# option '-q' is for quite output.
thin_check_options = [ "-q", 121e321 ]
# While activating devices, I/O to devices being (re)configured is # While activating devices, I/O to devices being (re)configured is
# suspended, and as a precaution against deadlocks, LVM2 needs to pin # suspended, and as a precaution against deadlocks, LVM2 needs to pin

View File

@ -1205,39 +1205,55 @@ static int _thin_pool_callback(struct dm_tree_node *node,
int ret, status; int ret, status;
const struct thin_cb_data *data = cb_data; const struct thin_cb_data *data = cb_data;
const char *dmdir = dm_dir(); const char *dmdir = dm_dir();
const struct dm_config_node *cn;
const struct dm_config_value *cv;
const char *thin_check = const char *thin_check =
find_config_tree_str_allow_empty(data->pool_lv->vg->cmd, find_config_tree_str_allow_empty(data->pool_lv->vg->cmd,
"global/thin_check_executable", "global/thin_check_executable",
DEFAULT_THIN_CHECK_EXECUTABLE); THIN_CHECK_CMD);
const struct logical_volume *mlv = first_seg(data->pool_lv)->metadata_lv; const struct logical_volume *mlv = first_seg(data->pool_lv)->metadata_lv;
size_t len = strlen(dmdir) + strlen(mlv->vg->name) + strlen(mlv->name) + 3; size_t len = strlen(dmdir) + 2 * (strlen(mlv->vg->name) + strlen(mlv->name)) + 3;
char meta_path[len]; char meta_path[len];
int args; int args = 0;
char *argv[19]; /* Max supported 15 args */ const char *argv[19]; /* Max supported 15 args */
char *split; char *split, *dm_name;
if (!thin_check[0]) if (!thin_check[0])
return 1; /* Checking disabled */ return 1; /* Checking disabled */
if (dm_snprintf(meta_path, len, "%s/%s-%s", dmdir, if (!(dm_name = dm_build_dm_name(data->dm->mem, mlv->vg->name,
mlv->vg->name, mlv->name) < 0) { mlv->name, NULL)) ||
(dm_snprintf(meta_path, len, "%s/%s", dmdir, dm_name) < 0)) {
log_error("Failed to build thin metadata path."); log_error("Failed to build thin metadata path.");
return 0; return 0;
} }
if (!(split = dm_pool_strdup(data->dm->mem, thin_check))) { if ((cn = find_config_tree_node(mlv->vg->cmd, "global/thin_check_options"))) {
for (cv = cn->v; cv && args < 16; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Invalid string in config file: "
"global/thin_check_options");
return 0;
}
argv[++args] = cv->v.str;
}
} else {
/* Use default options (no support for options with spaces) */
if (!(split = dm_pool_strdup(data->dm->mem, DEFAULT_THIN_CHECK_OPTIONS))) {
log_error("Failed to duplicate thin check string."); log_error("Failed to duplicate thin check string.");
return 0; return 0;
} }
args = dm_split_words(split, 16, 0, (char**) argv + 1);
args = dm_split_words(split, 16, 0, argv); }
if (args == 16) { if (args == 16) {
log_error("Too many options for thin check command."); log_error("Too many options for thin check command.");
return 0; return 0;
} }
argv[args++] = meta_path;
argv[args] = NULL; argv[0] = thin_check;
argv[++args] = meta_path;
argv[++args] = NULL;
if (!(ret = exec_cmd(data->pool_lv->vg->cmd, (const char * const *)argv, if (!(ret = exec_cmd(data->pool_lv->vg->cmd, (const char * const *)argv,
&status, 0))) { &status, 0))) {
@ -1262,7 +1278,7 @@ static int _thin_pool_callback(struct dm_tree_node *node,
*/ */
} }
dm_pool_free(data->dm->mem, split); dm_pool_free(data->dm->mem, dm_name);
return ret; return ret;
} }

View File

@ -64,7 +64,7 @@
#define DEFAULT_DMEVENTD_MONITOR 1 #define DEFAULT_DMEVENTD_MONITOR 1
#define DEFAULT_BACKGROUND_POLLING 1 #define DEFAULT_BACKGROUND_POLLING 1
#define DEFAULT_THIN_CHECK_EXECUTABLE "/sbin/thin_check -q" #define DEFAULT_THIN_CHECK_OPTIONS "-q"
#define DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS 0 #define DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS 0
#define DEFAULT_THIN_POOL_MAX_METADATA_SIZE (16 * 1024 * 1024) /* KB */ #define DEFAULT_THIN_POOL_MAX_METADATA_SIZE (16 * 1024 * 1024) /* KB */
#define DEFAULT_THIN_POOL_MIN_METADATA_SIZE 2048 /* KB */ #define DEFAULT_THIN_POOL_MIN_METADATA_SIZE 2048 /* KB */