mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-28 02:50:41 +03:00
Snapshots are now attached to their origin device for locking purposes
so lock the origin instead of the snapshot itself when creating one.
This commit is contained in:
parent
4bb3eccf2b
commit
8573c6bcac
@ -36,8 +36,7 @@ struct lvcreate_params {
|
||||
};
|
||||
|
||||
static int _read_name_params(struct lvcreate_params *lp,
|
||||
struct cmd_context *cmd, int *pargc,
|
||||
char ***pargv)
|
||||
struct cmd_context *cmd, int *pargc, char ***pargv)
|
||||
{
|
||||
int argc = *pargc;
|
||||
char **argv = *pargv, *ptr;
|
||||
@ -86,7 +85,7 @@ static int _read_name_params(struct lvcreate_params *lp,
|
||||
if (lp->lv_name && strchr(lp->lv_name, '/')) {
|
||||
if (!(lp->vg_name =
|
||||
extract_vgname(cmd->fid, lp->lv_name)))
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
if (strcmp(lp->vg_name, argv[0])) {
|
||||
log_error("Inconsistent volume group "
|
||||
@ -109,8 +108,7 @@ static int _read_name_params(struct lvcreate_params *lp,
|
||||
}
|
||||
|
||||
static int _read_size_params(struct lvcreate_params *lp,
|
||||
struct cmd_context *cmd, int *pargc,
|
||||
char ***pargv)
|
||||
struct cmd_context *cmd, int *pargc, char ***pargv)
|
||||
{
|
||||
/*
|
||||
* There are two mutually exclusive ways of specifying
|
||||
@ -383,7 +381,8 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
|
||||
if (!(lv = lv_create(cmd->fid, lp->lv_name, status,
|
||||
lp->stripes, lp->stripe_size, lp->extents,
|
||||
vg, pvh))) return 0;
|
||||
vg, pvh)))
|
||||
return 0;
|
||||
|
||||
if (lp->read_ahead) {
|
||||
log_verbose("Setting read ahead sectors");
|
||||
@ -413,7 +412,12 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
|
||||
if (lp->snapshot) {
|
||||
if (!lock_vol(cmd, lv->lvid.s, LCK_LV_DEACTIVATE)) {
|
||||
log_err("Couldn't lock snapshot.");
|
||||
log_err("Couldn't unlock snapshot.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, org->lvid.s, LCK_LV_SUSPEND | LCK_HOLD)) {
|
||||
log_error("Failed to lock origin %s", org->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -426,8 +430,10 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
if (!cmd->fid->ops->vg_write(cmd->fid, vg))
|
||||
return 0;
|
||||
|
||||
if (!lock_vol(cmd, lv->lvid.s, LCK_LV_ACTIVATE))
|
||||
if (!unlock_lv(cmd, org->lvid.s)) {
|
||||
log_error("Problem reactivating origin %s", org->name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
backup(vg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user