mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
fsadm cleanups & release prep
This commit is contained in:
parent
e2997b7328
commit
bc175d2870
@ -1,5 +1,5 @@
|
|||||||
Version 2.02.45 -
|
Version 2.02.45 - 26th February 2009
|
||||||
===================================
|
====================================
|
||||||
Do not scan devices if reporting only attributes from PV label.
|
Do not scan devices if reporting only attributes from PV label.
|
||||||
Use pkgconfig to obtain corosync library details during configuration.
|
Use pkgconfig to obtain corosync library details during configuration.
|
||||||
Fix error returns in clvmd-corosync interface to DLM.
|
Fix error returns in clvmd-corosync interface to DLM.
|
||||||
|
@ -23,24 +23,18 @@
|
|||||||
/*
|
/*
|
||||||
* Create verbose string with list of parameters
|
* Create verbose string with list of parameters
|
||||||
*/
|
*/
|
||||||
static char *verbose_args(const char *const argv[])
|
static char *_verbose_args(const char *const argv[], char *buf, size_t sz)
|
||||||
{
|
{
|
||||||
char *buf = 0;
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
size_t sz = 0;
|
int len;
|
||||||
size_t len;
|
unsigned i;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; argv[i] != NULL; i++) {
|
buf[0] = '\0';
|
||||||
len = strlen(argv[i]);
|
for (i = 0; argv[i]; i++) {
|
||||||
if (pos + len >= sz) {
|
if ((len = dm_snprintf(buf + pos, sz - pos,
|
||||||
sz = 64 + (sz + len) * 2;
|
"%s ", argv[i])) < 0)
|
||||||
if (!(buf = realloc(buf, sz)))
|
/* Truncated */
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (pos)
|
|
||||||
buf[pos++] = ' ';
|
|
||||||
memcpy(buf + pos, argv[i], len + 1); /* copy with '\0' */
|
|
||||||
pos += len;
|
pos += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +48,9 @@ int exec_cmd(const char *const argv[])
|
|||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
char *buf = 0;
|
char buf[PATH_MAX * 2];
|
||||||
|
|
||||||
log_verbose("Executing: %s", buf = verbose_args(argv));
|
log_verbose("Executing: %s", _verbose_args(argv, buf, sizeof(buf)));
|
||||||
free(buf);
|
|
||||||
|
|
||||||
if ((pid = fork()) == -1) {
|
if ((pid = fork()) == -1) {
|
||||||
log_error("fork failed: %s", strerror(errno));
|
log_error("fork failed: %s", strerror(errno));
|
||||||
@ -67,7 +60,7 @@ int exec_cmd(const char *const argv[])
|
|||||||
if (!pid) {
|
if (!pid) {
|
||||||
/* Child */
|
/* Child */
|
||||||
/* FIXME Use execve directly */
|
/* FIXME Use execve directly */
|
||||||
execvp(argv[0], (char **const) argv); /* cast to match execvp prototype */
|
execvp(argv[0], (char **const) argv);
|
||||||
log_sys_error("execvp", argv[0]);
|
log_sys_error("execvp", argv[0]);
|
||||||
exit(errno);
|
exit(errno);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ struct lvresize_params {
|
|||||||
char **argv;
|
char **argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int validate_stripesize(struct cmd_context *cmd,
|
static int _validate_stripesize(struct cmd_context *cmd,
|
||||||
const struct volume_group *vg,
|
const struct volume_group *vg,
|
||||||
struct lvresize_params *lp)
|
struct lvresize_params *lp)
|
||||||
{
|
{
|
||||||
@ -85,7 +85,7 @@ static int validate_stripesize(struct cmd_context *cmd,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int confirm_resizefs_reduce(struct cmd_context *cmd,
|
static int _request_confirmation(struct cmd_context *cmd,
|
||||||
const struct volume_group *vg,
|
const struct volume_group *vg,
|
||||||
const struct logical_volume *lv,
|
const struct logical_volume *lv,
|
||||||
const struct lvresize_params *lp)
|
const struct lvresize_params *lp)
|
||||||
@ -99,55 +99,61 @@ static int confirm_resizefs_reduce(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp->resizefs && !info.exists) {
|
if (lp->resizefs) {
|
||||||
|
if (!info.exists) {
|
||||||
log_error("Logical volume %s must be activated "
|
log_error("Logical volume %s must be activated "
|
||||||
"before resizing filesystem", lp->lv_name);
|
"before resizing filesystem", lp->lv_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (info.exists && !lp->resizefs && (lp->resize == LV_REDUCE)) {
|
if (!info.exists)
|
||||||
log_warn("WARNING: Reducing active%s logical volume "
|
return 1;
|
||||||
"to %s", info.open_count ? " and open" : "",
|
|
||||||
display_size(cmd, (uint64_t) lp->extents *
|
|
||||||
vg->extent_size));
|
|
||||||
|
|
||||||
log_warn("THIS MAY DESTROY YOUR DATA "
|
log_warn("WARNING: Reducing active%s logical volume to %s",
|
||||||
"(filesystem etc.)");
|
info.open_count ? " and open" : "",
|
||||||
|
display_size(cmd, (uint64_t) lp->extents * vg->extent_size));
|
||||||
|
|
||||||
|
log_warn("THIS MAY DESTROY YOUR DATA (filesystem etc.)");
|
||||||
|
|
||||||
if (!arg_count(cmd, force_ARG)) {
|
if (!arg_count(cmd, force_ARG)) {
|
||||||
if (yes_no_prompt("Do you really want to "
|
if (yes_no_prompt("Do you really want to reduce %s? [y/n]: ",
|
||||||
"reduce %s? [y/n]: ",
|
|
||||||
lp->lv_name) == 'n') {
|
lp->lv_name) == 'n') {
|
||||||
log_print("Logical volume %s NOT "
|
log_print("Logical volume %s NOT reduced", lp->lv_name);
|
||||||
"reduced", lp->lv_name);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (sigint_caught())
|
if (sigint_caught())
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
|
enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
|
||||||
|
#define FSADM_CMD "fsadm"
|
||||||
|
#define FSADM_CMD_MAX_ARGS 6
|
||||||
|
|
||||||
static int fsadm_cmd(const struct cmd_context *cmd,
|
/*
|
||||||
|
* FSADM_CMD --dry-run --verbose --force check lv_path
|
||||||
|
* FSADM_CMD --dry-run --verbose --force resize lv_path size
|
||||||
|
*/
|
||||||
|
static int _fsadm_cmd(const struct cmd_context *cmd,
|
||||||
const struct volume_group *vg,
|
const struct volume_group *vg,
|
||||||
const struct lvresize_params *lp,
|
const struct lvresize_params *lp,
|
||||||
enum fsadm_cmd_e fcmd)
|
enum fsadm_cmd_e fcmd)
|
||||||
{
|
{
|
||||||
char lv_path[PATH_MAX];
|
char lv_path[PATH_MAX];
|
||||||
char size_buf[SIZE_BUF];
|
char size_buf[SIZE_BUF];
|
||||||
const char *argv[10];
|
const char *argv[FSADM_CMD_MAX_ARGS + 2];
|
||||||
int i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
argv[i++] = "fsadm"; /* FIXME: se configurable FSADM_CMD */
|
argv[i++] = FSADM_CMD;
|
||||||
|
|
||||||
if (test_mode())
|
if (test_mode())
|
||||||
argv[i++] = "--dry-run";
|
argv[i++] = "--dry-run";
|
||||||
|
|
||||||
if (verbose_level() > _LOG_WARN)
|
if (verbose_level() >= _LOG_NOTICE)
|
||||||
argv[i++] = "--verbose";
|
argv[i++] = "--verbose";
|
||||||
|
|
||||||
if (arg_count(cmd, force_ARG))
|
if (arg_count(cmd, force_ARG))
|
||||||
@ -155,10 +161,9 @@ static int fsadm_cmd(const struct cmd_context *cmd,
|
|||||||
|
|
||||||
argv[i++] = (fcmd == FSADM_CMD_RESIZE) ? "resize" : "check";
|
argv[i++] = (fcmd == FSADM_CMD_RESIZE) ? "resize" : "check";
|
||||||
|
|
||||||
if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir,
|
if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir, lp->vg_name,
|
||||||
lp->vg_name, lp->lv_name) < 0) {
|
lp->lv_name) < 0) {
|
||||||
log_error("Couldn't create LV path for %s",
|
log_error("Couldn't create LV path for %s", lp->lv_name);
|
||||||
lp->lv_name);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,10 +317,9 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd, stripesize_ARG)) {
|
if (arg_count(cmd, stripesize_ARG) &&
|
||||||
if (!validate_stripesize(cmd, vg, lp))
|
!_validate_stripesize(cmd, vg, lp))
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
|
||||||
|
|
||||||
lv = lvl->lv;
|
lv = lvl->lv;
|
||||||
|
|
||||||
@ -420,8 +424,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
sz = seg->stripe_size;
|
sz = seg->stripe_size;
|
||||||
str = seg->area_count;
|
str = seg->area_count;
|
||||||
|
|
||||||
if ((seg_stripesize && seg_stripesize != sz
|
if ((seg_stripesize && seg_stripesize != sz &&
|
||||||
&& !lp->stripe_size) ||
|
!lp->stripe_size) ||
|
||||||
(seg_stripes && seg_stripes != str && !lp->stripes)) {
|
(seg_stripes && seg_stripes != str && !lp->stripes)) {
|
||||||
log_error("Please specify number of "
|
log_error("Please specify number of "
|
||||||
"stripes (-i) and stripesize (-I)");
|
"stripes (-i) and stripesize (-I)");
|
||||||
@ -568,24 +572,25 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp->resize == LV_REDUCE) {
|
if ((lp->resize == LV_REDUCE) && lp->argc)
|
||||||
if (lp->argc)
|
|
||||||
log_warn("Ignoring PVs on command line when reducing");
|
log_warn("Ignoring PVs on command line when reducing");
|
||||||
|
|
||||||
|
/* Request confirmation before operations that are often mistakes. */
|
||||||
|
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
|
||||||
|
!_request_confirmation(cmd, vg, lv, lp)) {
|
||||||
|
stack;
|
||||||
|
// return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lp->resizefs || (lp->resize == LV_REDUCE))
|
|
||||||
&& !confirm_resizefs_reduce(cmd, vg, lv, lp)) /* ensure active LV */
|
|
||||||
return ECMD_FAILED;
|
|
||||||
|
|
||||||
if (lp->resizefs) {
|
if (lp->resizefs) {
|
||||||
if (!lp->nofsck
|
if (!lp->nofsck &&
|
||||||
&& !fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK)) {
|
!_fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK)) {
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lp->resize == LV_REDUCE)
|
if ((lp->resize == LV_REDUCE) &&
|
||||||
&& !fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
|
!_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
@ -606,8 +611,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
} else if ((lp->extents > lv->le_count) /* check we really do extend */
|
} else if ((lp->extents > lv->le_count) && /* Ensure we extend */
|
||||||
&& !lv_extend(lv, lp->segtype, lp->stripes,
|
!lv_extend(lv, lp->segtype, lp->stripes,
|
||||||
lp->stripe_size, lp->mirrors,
|
lp->stripe_size, lp->mirrors,
|
||||||
lp->extents - lv->le_count,
|
lp->extents - lv->le_count,
|
||||||
NULL, 0u, 0u, pvh, alloc)) {
|
NULL, 0u, 0u, pvh, alloc)) {
|
||||||
@ -648,8 +653,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
|
|
||||||
log_print("Logical volume %s successfully resized", lp->lv_name);
|
log_print("Logical volume %s successfully resized", lp->lv_name);
|
||||||
|
|
||||||
if (lp->resizefs && (lp->resize == LV_EXTEND)
|
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
|
||||||
&& !fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
|
!_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user