diff --git a/WHATS_NEW b/WHATS_NEW index b3402a5df..25a702cb2 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.00.34 - ================================== + Only ask libdevmapper for open_count when we need it. Adjust RHEL4 clvmd init script priority. Version 2.00.33 - 7th January 2005 diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 573ce097b..8ff3b8a3a 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -78,12 +78,13 @@ int target_present(const char *target_name) { return 0; } -int lv_info(const struct logical_volume *lv, struct lvinfo *info) +int lv_info(const struct logical_volume *lv, struct lvinfo *info, + int with_open_count) { return 0; } int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, - struct lvinfo *info) + struct lvinfo *info, int with_open_count) { return 0; } @@ -333,7 +334,7 @@ int target_present(const char *target_name) * Returns 1 if info structure populated, else 0 on failure. */ static int _lv_info(const struct logical_volume *lv, int mknodes, - struct lvinfo *info) + struct lvinfo *info, int with_open_count) { int r; struct dev_manager *dm; @@ -347,7 +348,7 @@ static int _lv_info(const struct logical_volume *lv, int mknodes, return 0; } - if (!(r = dev_manager_info(dm, lv, mknodes, &dminfo))) + if (!(r = dev_manager_info(dm, lv, mknodes, with_open_count, &dminfo))) stack; info->exists = dminfo.exists; @@ -361,20 +362,21 @@ static int _lv_info(const struct logical_volume *lv, int mknodes, return r; } -int lv_info(const struct logical_volume *lv, struct lvinfo *info) +int lv_info(const struct logical_volume *lv, struct lvinfo *info, + int with_open_count) { - return _lv_info(lv, 0, info); + return _lv_info(lv, 0, info, with_open_count); } int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, - struct lvinfo *info) + struct lvinfo *info, int with_open_count) { struct logical_volume *lv; if (!(lv = lv_from_lvid(cmd, lvid_s))) return 0; - return _lv_info(lv, 0, info); + return _lv_info(lv, 0, info, with_open_count); } /* @@ -412,7 +414,7 @@ int lv_mirror_percent(struct logical_volume *lv, int wait, float *percent, if (!activation()) return 0; - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 0)) { stack; return 0; } @@ -437,7 +439,7 @@ static int _lv_active(struct logical_volume *lv) { struct lvinfo info; - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 0)) { stack; return -1; } @@ -449,7 +451,7 @@ static int _lv_open_count(struct logical_volume *lv) { struct lvinfo info; - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 1)) { stack; return -1; } @@ -566,7 +568,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, return 1; } - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 0)) { stack; return 0; } @@ -612,7 +614,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s, return 1; } - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 0)) { stack; return 0; } @@ -657,7 +659,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) return 1; } - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 1)) { stack; return 0; } @@ -726,7 +728,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, int filter) return 1; } - if (!lv_info(lv, &info)) { + if (!lv_info(lv, &info, 0)) { stack; return 0; } @@ -765,7 +767,7 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv) return r; } - if (!_lv_info(lv, 1, &info)) { + if (!_lv_info(lv, 1, &info, 0)) { stack; return 0; } diff --git a/lib/activate/activate.h b/lib/activate/activate.h index 0f9cd530b..6704fcc3f 100644 --- a/lib/activate/activate.h +++ b/lib/activate/activate.h @@ -55,9 +55,10 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv); /* * Returns 1 if info structure has been populated, else 0. */ -int lv_info(const struct logical_volume *lv, struct lvinfo *info); +int lv_info(const struct logical_volume *lv, struct lvinfo *info, + int with_open_count); int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, - struct lvinfo *info); + struct lvinfo *info, int with_open_count); /* * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't. diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index e02a4f819..9aa22938d 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -211,7 +211,8 @@ static struct dm_task *_setup_task(const char *name, const char *uuid, } static int _info_run(const char *name, const char *uuid, struct dm_info *info, - int mknodes, struct pool *mem, char **uuid_out) + int mknodes, int with_open_count, struct pool *mem, + char **uuid_out) { int r = 0; struct dm_task *dmt; @@ -225,6 +226,10 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info, return 0; } + if (!with_open_count) + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + if (!dm_task_run(dmt)) { stack; goto out; @@ -250,14 +255,17 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info, } static int _info(const char *name, const char *uuid, int mknodes, - struct dm_info *info, struct pool *mem, char **uuid_out) + int with_open_count, struct dm_info *info, + struct pool *mem, char **uuid_out) { if (!mknodes && uuid && *uuid && - _info_run(NULL, uuid, info, 0, mem, uuid_out) && info->exists) + _info_run(NULL, uuid, info, 0, with_open_count, mem, uuid_out) && + info->exists) return 1; if (name) - return _info_run(name, NULL, info, mknodes, mem, uuid_out); + return _info_run(name, NULL, info, mknodes, with_open_count, + mem, uuid_out); return 0; } @@ -279,6 +287,9 @@ static int _status_run(const char *name, const char *uuid, return 0; } + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + if (!dm_task_run(dmt)) { stack; goto out; @@ -357,6 +368,9 @@ static int _percent_run(struct dev_manager *dm, const char *name, return 0; } + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + if (!dm_task_run(dmt)) { stack; goto out; @@ -460,6 +474,9 @@ static int _rename(struct dev_manager *dm, struct dev_layer *dl, char *newname) goto out; } + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + if (!(r = dm_task_run(dmt))) { log_error("Couldn't rename device '%s'.", dl->name); goto out; @@ -488,6 +505,9 @@ static int _suspend_or_resume(const char *name, action_t suspend) return 0; } + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + if (!(r = dm_task_run(dmt))) log_error("Couldn't %s device '%s'", sus ? "suspend" : "resume", name); @@ -579,6 +599,9 @@ static int _load(struct dev_manager *dm, struct dev_layer *dl, int task) log_very_verbose("Activating %s read-only", dl->name); } + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + if (!(r = dm_task_run(dmt))) { log_error("Couldn't load device '%s'.", dl->name); if ((dl->lv->minor >= 0 || dl->lv->major >= 0) && @@ -635,6 +658,9 @@ static int _remove(struct dev_layer *dl) return 0; } + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + /* Suppress error message if it's still in use - we'll log it later */ log_suppress(1); @@ -970,7 +996,7 @@ void dev_manager_destroy(struct dev_manager *dm) } int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv, - int mknodes, struct dm_info *info) + int mknodes, int with_open_count, struct dm_info *info) { char *name; @@ -986,7 +1012,8 @@ int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv, * Try and get some info on this device. */ log_debug("Getting device info for %s", name); - if (!_info(name, lv->lvid.s, mknodes, info, NULL, NULL)) { + if (!_info(name, lv->lvid.s, mknodes, with_open_count, info, NULL, + NULL)) { stack; return 0; } @@ -1065,7 +1092,7 @@ static struct dev_layer *_create_dev(struct dev_manager *dm, char *name, dl->name = name; log_debug("Getting device info for %s", dl->name); - if (!_info(dl->name, dlid, 0, &dl->info, dm->mem, &uuid)) { + if (!_info(dl->name, dlid, 0, 0, &dl->info, dm->mem, &uuid)) { stack; return NULL; } diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h index 2290679cd..1c32d56fe 100644 --- a/lib/activate/dev_manager.h +++ b/lib/activate/dev_manager.h @@ -36,7 +36,7 @@ void dev_manager_exit(void); * unsuspended until the snapshot is also created.) */ int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv, - int mknodes, struct dm_info *info); + int mknodes, int with_open_count, struct dm_info *info); int dev_manager_snapshot_percent(struct dev_manager *dm, struct logical_volume *lv, float *percent); int dev_manager_mirror_percent(struct dev_manager *dm, diff --git a/lib/display/display.c b/lib/display/display.c index 08e2dc95d..14605ed27 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -317,7 +317,7 @@ void lvdisplay_colons(struct logical_volume *lv) { int inkernel; struct lvinfo info; - inkernel = lv_info(lv, &info) && info.exists; + inkernel = lv_info(lv, &info, 1) && info.exists; log_print("%s%s/%s:%s:%d:%d:-1:%d:%" PRIu64 ":%d:-1:%d:%d:%d:%d", lv->vg->cmd->dev_dir, @@ -348,7 +348,7 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv, return 0; } - inkernel = lv_info(lv, &info) && info.exists; + inkernel = lv_info(lv, &info, 1) && info.exists; log_print("--- Logical volume ---"); diff --git a/lib/report/report.c b/lib/report/report.c index 33cd25887..46b288eb8 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -295,7 +295,7 @@ static int _lvkmaj_disp(struct report_handle *rh, struct field *field, struct lvinfo info; uint64_t minusone = UINT64_C(-1); - if (lv_info(lv, &info) && info.exists) + if (lv_info(lv, &info, 0) && info.exists) return _int_disp(rh, field, &info.major); else return _int_disp(rh, field, &minusone); @@ -310,7 +310,7 @@ static int _lvkmin_disp(struct report_handle *rh, struct field *field, struct lvinfo info; uint64_t minusone = UINT64_C(-1); - if (lv_info(lv, &info) && info.exists) + if (lv_info(lv, &info, 0) && info.exists) return _int_disp(rh, field, &info.minor); else return _int_disp(rh, field, &minusone); @@ -362,7 +362,7 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field, else repstr[3] = '-'; - if (lv_info(lv, &info) && info.exists) { + if (lv_info(lv, &info, 1) && info.exists) { if (info.suspended) repstr[4] = 's'; /* Suspended */ else @@ -774,7 +774,7 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field, } if (!(snap = find_cow(lv)) || - (lv_info(snap->cow, &info) && !info.exists)) { + (lv_info(snap->cow, &info, 0) && !info.exists)) { field->report_string = ""; *sortval = UINT64_C(0); field->sort_value = sortval; diff --git a/tools/lvchange.c b/tools/lvchange.c index e9ec8d2a7..d5ac0acdf 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -256,7 +256,7 @@ static int lvchange_persistent(struct cmd_context *cmd, log_error("Major number must be specified with -My"); return 0; } - if (lv_info(lv, &info) && info.exists && + if (lv_info(lv, &info, 0) && info.exists && !arg_count(cmd, force_ARG)) { if (yes_no_prompt("Logical volume %s will be " "deactivated temporarily. " diff --git a/tools/lvremove.c b/tools/lvremove.c index fa882fa5d..bb442932d 100644 --- a/tools/lvremove.c +++ b/tools/lvremove.c @@ -41,7 +41,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv, /* FIXME Ensure not referred to by another existing LVs */ - if (lv_info(lv, &info)) { + if (lv_info(lv, &info, 1)) { if (info.open_count) { log_error("Can't remove open logical volume \"%s\"", lv->name); diff --git a/tools/lvresize.c b/tools/lvresize.c index f8ca36c83..734fd7056 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -364,7 +364,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp) if (lp->resize == LV_REDUCE || lp->resizefs) { memset(&info, 0, sizeof(info)); - if (!lv_info(lv, &info) && driver_version(NULL, 0)) { + if (!lv_info(lv, &info, 1) && driver_version(NULL, 0)) { log_error("lv_info failed: aborting"); return ECMD_FAILED; } diff --git a/tools/lvscan.c b/tools/lvscan.c index 1ed48c23a..fa76f19a5 100644 --- a/tools/lvscan.c +++ b/tools/lvscan.c @@ -25,7 +25,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv, const char *active_str, *snapshot_str; /* FIXME Add -D arg to skip this! */ - if (lv_info(lv, &info) && info.exists) + if (lv_info(lv, &info, 0) && info.exists) active_str = "ACTIVE "; else active_str = "inactive "; diff --git a/tools/vgconvert.c b/tools/vgconvert.c index 1110c3b2d..d55bb406f 100644 --- a/tools/vgconvert.c +++ b/tools/vgconvert.c @@ -94,7 +94,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, lv = lvl->lv; if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS) continue; - if (lv_info(lv, &info) && info.exists) { + if (lv_info(lv, &info, 0) && info.exists) { log_error("Logical volume %s must be " "deactivated before conversion.", lv->name);