1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Only ask libdevmapper for open_count when we need it.

This commit is contained in:
Alasdair Kergon 2005-01-12 22:58:21 +00:00
parent 8e2dd0dfb2
commit e9c761b869
12 changed files with 68 additions and 37 deletions

View File

@ -1,5 +1,6 @@
Version 2.00.34 - Version 2.00.34 -
================================== ==================================
Only ask libdevmapper for open_count when we need it.
Adjust RHEL4 clvmd init script priority. Adjust RHEL4 clvmd init script priority.
Version 2.00.33 - 7th January 2005 Version 2.00.33 - 7th January 2005

View File

@ -78,12 +78,13 @@ int target_present(const char *target_name)
{ {
return 0; 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; return 0;
} }
int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, 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; return 0;
} }
@ -333,7 +334,7 @@ int target_present(const char *target_name)
* Returns 1 if info structure populated, else 0 on failure. * Returns 1 if info structure populated, else 0 on failure.
*/ */
static int _lv_info(const struct logical_volume *lv, int mknodes, static int _lv_info(const struct logical_volume *lv, int mknodes,
struct lvinfo *info) struct lvinfo *info, int with_open_count)
{ {
int r; int r;
struct dev_manager *dm; struct dev_manager *dm;
@ -347,7 +348,7 @@ static int _lv_info(const struct logical_volume *lv, int mknodes,
return 0; return 0;
} }
if (!(r = dev_manager_info(dm, lv, mknodes, &dminfo))) if (!(r = dev_manager_info(dm, lv, mknodes, with_open_count, &dminfo)))
stack; stack;
info->exists = dminfo.exists; info->exists = dminfo.exists;
@ -361,20 +362,21 @@ static int _lv_info(const struct logical_volume *lv, int mknodes,
return r; 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, 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; struct logical_volume *lv;
if (!(lv = lv_from_lvid(cmd, lvid_s))) if (!(lv = lv_from_lvid(cmd, lvid_s)))
return 0; 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()) if (!activation())
return 0; return 0;
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 0)) {
stack; stack;
return 0; return 0;
} }
@ -437,7 +439,7 @@ static int _lv_active(struct logical_volume *lv)
{ {
struct lvinfo info; struct lvinfo info;
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 0)) {
stack; stack;
return -1; return -1;
} }
@ -449,7 +451,7 @@ static int _lv_open_count(struct logical_volume *lv)
{ {
struct lvinfo info; struct lvinfo info;
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 1)) {
stack; stack;
return -1; return -1;
} }
@ -566,7 +568,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
return 1; return 1;
} }
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 0)) {
stack; stack;
return 0; return 0;
} }
@ -612,7 +614,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
return 1; return 1;
} }
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 0)) {
stack; stack;
return 0; return 0;
} }
@ -657,7 +659,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
return 1; return 1;
} }
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 1)) {
stack; stack;
return 0; return 0;
} }
@ -726,7 +728,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, int filter)
return 1; return 1;
} }
if (!lv_info(lv, &info)) { if (!lv_info(lv, &info, 0)) {
stack; stack;
return 0; return 0;
} }
@ -765,7 +767,7 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
return r; return r;
} }
if (!_lv_info(lv, 1, &info)) { if (!_lv_info(lv, 1, &info, 0)) {
stack; stack;
return 0; return 0;
} }

View File

@ -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. * 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, 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. * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.

View File

@ -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, 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; int r = 0;
struct dm_task *dmt; struct dm_task *dmt;
@ -225,6 +226,10 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info,
return 0; 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)) { if (!dm_task_run(dmt)) {
stack; stack;
goto out; 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, 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 && 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; return 1;
if (name) 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; return 0;
} }
@ -279,6 +287,9 @@ static int _status_run(const char *name, const char *uuid,
return 0; return 0;
} }
if (!dm_task_no_open_count(dmt))
log_error("Failed to disable open_count");
if (!dm_task_run(dmt)) { if (!dm_task_run(dmt)) {
stack; stack;
goto out; goto out;
@ -357,6 +368,9 @@ static int _percent_run(struct dev_manager *dm, const char *name,
return 0; return 0;
} }
if (!dm_task_no_open_count(dmt))
log_error("Failed to disable open_count");
if (!dm_task_run(dmt)) { if (!dm_task_run(dmt)) {
stack; stack;
goto out; goto out;
@ -460,6 +474,9 @@ static int _rename(struct dev_manager *dm, struct dev_layer *dl, char *newname)
goto out; goto out;
} }
if (!dm_task_no_open_count(dmt))
log_error("Failed to disable open_count");
if (!(r = dm_task_run(dmt))) { if (!(r = dm_task_run(dmt))) {
log_error("Couldn't rename device '%s'.", dl->name); log_error("Couldn't rename device '%s'.", dl->name);
goto out; goto out;
@ -488,6 +505,9 @@ static int _suspend_or_resume(const char *name, action_t suspend)
return 0; return 0;
} }
if (!dm_task_no_open_count(dmt))
log_error("Failed to disable open_count");
if (!(r = dm_task_run(dmt))) if (!(r = dm_task_run(dmt)))
log_error("Couldn't %s device '%s'", sus ? "suspend" : "resume", log_error("Couldn't %s device '%s'", sus ? "suspend" : "resume",
name); 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); 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))) { if (!(r = dm_task_run(dmt))) {
log_error("Couldn't load device '%s'.", dl->name); log_error("Couldn't load device '%s'.", dl->name);
if ((dl->lv->minor >= 0 || dl->lv->major >= 0) && if ((dl->lv->minor >= 0 || dl->lv->major >= 0) &&
@ -635,6 +658,9 @@ static int _remove(struct dev_layer *dl)
return 0; 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 */ /* Suppress error message if it's still in use - we'll log it later */
log_suppress(1); 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 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; 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. * Try and get some info on this device.
*/ */
log_debug("Getting device info for %s", name); 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; stack;
return 0; return 0;
} }
@ -1065,7 +1092,7 @@ static struct dev_layer *_create_dev(struct dev_manager *dm, char *name,
dl->name = name; dl->name = name;
log_debug("Getting device info for %s", dl->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; stack;
return NULL; return NULL;
} }

View File

@ -36,7 +36,7 @@ void dev_manager_exit(void);
* unsuspended until the snapshot is also created.) * unsuspended until the snapshot is also created.)
*/ */
int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv, 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, int dev_manager_snapshot_percent(struct dev_manager *dm,
struct logical_volume *lv, float *percent); struct logical_volume *lv, float *percent);
int dev_manager_mirror_percent(struct dev_manager *dm, int dev_manager_mirror_percent(struct dev_manager *dm,

View File

@ -317,7 +317,7 @@ void lvdisplay_colons(struct logical_volume *lv)
{ {
int inkernel; int inkernel;
struct lvinfo info; 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", log_print("%s%s/%s:%s:%d:%d:-1:%d:%" PRIu64 ":%d:-1:%d:%d:%d:%d",
lv->vg->cmd->dev_dir, lv->vg->cmd->dev_dir,
@ -348,7 +348,7 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
return 0; return 0;
} }
inkernel = lv_info(lv, &info) && info.exists; inkernel = lv_info(lv, &info, 1) && info.exists;
log_print("--- Logical volume ---"); log_print("--- Logical volume ---");

View File

@ -295,7 +295,7 @@ static int _lvkmaj_disp(struct report_handle *rh, struct field *field,
struct lvinfo info; struct lvinfo info;
uint64_t minusone = UINT64_C(-1); 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); return _int_disp(rh, field, &info.major);
else else
return _int_disp(rh, field, &minusone); return _int_disp(rh, field, &minusone);
@ -310,7 +310,7 @@ static int _lvkmin_disp(struct report_handle *rh, struct field *field,
struct lvinfo info; struct lvinfo info;
uint64_t minusone = UINT64_C(-1); 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); return _int_disp(rh, field, &info.minor);
else else
return _int_disp(rh, field, &minusone); return _int_disp(rh, field, &minusone);
@ -362,7 +362,7 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
else else
repstr[3] = '-'; repstr[3] = '-';
if (lv_info(lv, &info) && info.exists) { if (lv_info(lv, &info, 1) && info.exists) {
if (info.suspended) if (info.suspended)
repstr[4] = 's'; /* Suspended */ repstr[4] = 's'; /* Suspended */
else else
@ -774,7 +774,7 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field,
} }
if (!(snap = find_cow(lv)) || if (!(snap = find_cow(lv)) ||
(lv_info(snap->cow, &info) && !info.exists)) { (lv_info(snap->cow, &info, 0) && !info.exists)) {
field->report_string = ""; field->report_string = "";
*sortval = UINT64_C(0); *sortval = UINT64_C(0);
field->sort_value = sortval; field->sort_value = sortval;

View File

@ -256,7 +256,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
log_error("Major number must be specified with -My"); log_error("Major number must be specified with -My");
return 0; return 0;
} }
if (lv_info(lv, &info) && info.exists && if (lv_info(lv, &info, 0) && info.exists &&
!arg_count(cmd, force_ARG)) { !arg_count(cmd, force_ARG)) {
if (yes_no_prompt("Logical volume %s will be " if (yes_no_prompt("Logical volume %s will be "
"deactivated temporarily. " "deactivated temporarily. "

View File

@ -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 */ /* FIXME Ensure not referred to by another existing LVs */
if (lv_info(lv, &info)) { if (lv_info(lv, &info, 1)) {
if (info.open_count) { if (info.open_count) {
log_error("Can't remove open logical volume \"%s\"", log_error("Can't remove open logical volume \"%s\"",
lv->name); lv->name);

View File

@ -364,7 +364,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
if (lp->resize == LV_REDUCE || lp->resizefs) { if (lp->resize == LV_REDUCE || lp->resizefs) {
memset(&info, 0, sizeof(info)); 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"); log_error("lv_info failed: aborting");
return ECMD_FAILED; return ECMD_FAILED;
} }

View File

@ -25,7 +25,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
const char *active_str, *snapshot_str; const char *active_str, *snapshot_str;
/* FIXME Add -D arg to skip this! */ /* 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 "; active_str = "ACTIVE ";
else else
active_str = "inactive "; active_str = "inactive ";

View File

@ -94,7 +94,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
lv = lvl->lv; lv = lvl->lv;
if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS) if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS)
continue; continue;
if (lv_info(lv, &info) && info.exists) { if (lv_info(lv, &info, 0) && info.exists) {
log_error("Logical volume %s must be " log_error("Logical volume %s must be "
"deactivated before conversion.", "deactivated before conversion.",
lv->name); lv->name);