mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Fixed bug where lvresize option -t was not properly passed to fsadm.
Using argv[] list in exec_cmd() to allow more params for external commands. Fsadm does not allow checking mounted filesystem. Fsadm no longer accepts 'any other key' as 'no' answer to y/n. Fsadm improved handling of command line options.
This commit is contained in:
parent
049cbb75b8
commit
c8669f6b13
@ -1,5 +1,10 @@
|
|||||||
Version 2.02.45 -
|
Version 2.02.45 -
|
||||||
===================================
|
===================================
|
||||||
|
Fixed bug where lvresize option -t was not properly passed to fsadm.
|
||||||
|
Using argv[] list in exec_cmd() to allow more params for external commands.
|
||||||
|
Fsadm does not allow checking mounted filesystem.
|
||||||
|
Fsadm no longer accepts 'any other key' as 'no' answer to y/n.
|
||||||
|
Fsadm improved handling of command line options.
|
||||||
Add lib/lvm.h and lib/lvm_base.c for the new library interface.
|
Add lib/lvm.h and lib/lvm_base.c for the new library interface.
|
||||||
Move tools/version.h to lib/misc/lvm-version.h.
|
Move tools/version.h to lib/misc/lvm-version.h.
|
||||||
Split LVM_VERSION into MAJOR, MINOR, PATCHLEVEL, RELEASE and RELEASE_DATE.
|
Split LVM_VERSION into MAJOR, MINOR, PATCHLEVEL, RELEASE and RELEASE_DATE.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of LVM2.
|
* This file is part of LVM2.
|
||||||
*
|
*
|
||||||
@ -396,6 +396,7 @@ int module_present(const char *target_name)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef MODPROBE_CMD
|
#ifdef MODPROBE_CMD
|
||||||
char module[128];
|
char module[128];
|
||||||
|
const char *argv[3];
|
||||||
|
|
||||||
if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
|
if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
|
||||||
log_error("module_present module name too long: %s",
|
log_error("module_present module name too long: %s",
|
||||||
@ -403,7 +404,11 @@ int module_present(const char *target_name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = exec_cmd(MODPROBE_CMD, module, "", "");
|
argv[0] = MODPROBE_CMD;
|
||||||
|
argv[1] = module;
|
||||||
|
argv[2] = NULL;
|
||||||
|
|
||||||
|
ret = exec_cmd(argv);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of LVM2.
|
* This file is part of LVM2.
|
||||||
*
|
*
|
||||||
@ -19,16 +19,45 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create verbose string with list of parameters
|
||||||
|
*/
|
||||||
|
static char *verbose_args(const char *const argv[])
|
||||||
|
{
|
||||||
|
char *buf = 0;
|
||||||
|
int pos = 0;
|
||||||
|
size_t sz = 0;
|
||||||
|
size_t len;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; argv[i] != NULL; i++) {
|
||||||
|
len = strlen(argv[i]);
|
||||||
|
if (pos + len >= sz) {
|
||||||
|
sz = 64 + (sz + len) * 2;
|
||||||
|
if (!(buf = realloc(buf, sz)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pos)
|
||||||
|
buf[pos++] = ' ';
|
||||||
|
memcpy(buf + pos, argv[i], len + 1); /* copy with '\0' */
|
||||||
|
pos += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Execute and wait for external command
|
* Execute and wait for external command
|
||||||
*/
|
*/
|
||||||
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
|
int exec_cmd(const char *const argv[])
|
||||||
const char *size)
|
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
char *buf = 0;
|
||||||
|
|
||||||
log_verbose("Executing: %s %s %s %s", command, fscmd, lv_path, size);
|
log_verbose("Executing: %s", buf = verbose_args(argv));
|
||||||
|
free(buf);
|
||||||
|
|
||||||
if ((pid = fork()) == -1) {
|
if ((pid = fork()) == -1) {
|
||||||
log_error("fork failed: %s", strerror(errno));
|
log_error("fork failed: %s", strerror(errno));
|
||||||
@ -38,8 +67,8 @@ int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
|
|||||||
if (!pid) {
|
if (!pid) {
|
||||||
/* Child */
|
/* Child */
|
||||||
/* FIXME Use execve directly */
|
/* FIXME Use execve directly */
|
||||||
execlp(command, command, fscmd, lv_path, size, NULL);
|
execvp(argv[0], (char **const) argv); /* cast to match execvp prototype */
|
||||||
log_sys_error("execlp", command);
|
log_sys_error("execvp", argv[0]);
|
||||||
exit(errno);
|
exit(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +85,7 @@ int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WEXITSTATUS(status)) {
|
if (WEXITSTATUS(status)) {
|
||||||
log_error("%s failed: %u", command, WEXITSTATUS(status));
|
log_error("%s failed: %u", argv[0], WEXITSTATUS(status));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
|
|
||||||
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
|
int exec_cmd(const char *const argv[]);
|
||||||
const char *size);
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
# Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of LVM2.
|
# This file is part of LVM2.
|
||||||
#
|
#
|
||||||
@ -206,21 +206,22 @@ temp_umount() {
|
|||||||
|
|
||||||
yes_no() {
|
yes_no() {
|
||||||
echo -n "$@? [Y|n] "
|
echo -n "$@? [Y|n] "
|
||||||
|
|
||||||
if [ -n "$YES" ]; then
|
if [ -n "$YES" ]; then
|
||||||
ANS="y"; echo -n $ANS
|
echo y ; return 0
|
||||||
else
|
|
||||||
read -n 1 ANS
|
|
||||||
fi
|
fi
|
||||||
test -n "$ANS" && echo
|
|
||||||
|
while read -r -s -n 1 ANS ; do
|
||||||
case "$ANS" in
|
case "$ANS" in
|
||||||
"y" | "Y" | "" ) return 0 ;;
|
"y" | "Y" | "") echo y ; return 0 ;;
|
||||||
|
"n" | "N") echo n ; return 1 ;;
|
||||||
esac
|
esac
|
||||||
return 1
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
try_umount() {
|
try_umount() {
|
||||||
yes_no "Do you want to unmount \"$MOUNTED\"" && dry $UMOUNT "$MOUNTED" && return 0
|
yes_no "Do you want to unmount \"$MOUNTED\"" && dry $UMOUNT "$MOUNTED" && return 0
|
||||||
error "Cannot proceed test with mounted filesystem \"$MOUNTED\""
|
error "Can not proceed with mounted filesystem \"$MOUNTED\""
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_parsing() {
|
validate_parsing() {
|
||||||
@ -250,7 +251,7 @@ resize_ext() {
|
|||||||
FSFORCE="-f"
|
FSFORCE="-f"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
verbose "Resizing \"$VOLUME\" $BLOCKCOUNT -> $NEWBLOCKCOUNT blocks ($NEWSIZE bytes, bs:$BLOCKSIZE)"
|
verbose "Resizing filesystem on device \"$VOLUME\" to $NEWSIZE bytes ($BLOCKCOUNT -> $NEWBLOCKCOUNT blocks of $BLOCKSIZE bytes)"
|
||||||
dry $RESIZE_EXT $FSFORCE "$VOLUME" $NEWBLOCKCOUNT
|
dry $RESIZE_EXT $FSFORCE "$VOLUME" $NEWBLOCKCOUNT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,12 +261,8 @@ resize_ext() {
|
|||||||
# - unmounted for downsize
|
# - unmounted for downsize
|
||||||
#############################
|
#############################
|
||||||
resize_reiser() {
|
resize_reiser() {
|
||||||
detect_mounted
|
detect_mounted && verbose "ReiserFS resizes only unmounted filesystem" && try_umount
|
||||||
if [ -n "$MOUNTED" ]; then
|
|
||||||
verbose "ReiserFS resizes only unmounted filesystem"
|
|
||||||
try_umount
|
|
||||||
REMOUNT=$MOUNTED
|
REMOUNT=$MOUNTED
|
||||||
fi
|
|
||||||
verbose "Parsing $TUNE_REISER \"$VOLUME\""
|
verbose "Parsing $TUNE_REISER \"$VOLUME\""
|
||||||
for i in $($TUNE_REISER "$VOLUME"); do
|
for i in $($TUNE_REISER "$VOLUME"); do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
@ -322,7 +319,7 @@ resize() {
|
|||||||
NEWSIZE=$2
|
NEWSIZE=$2
|
||||||
detect_fs "$1"
|
detect_fs "$1"
|
||||||
detect_device_size
|
detect_device_size
|
||||||
verbose "Device \"$VOLUME\" has $DEVSIZE bytes"
|
verbose "Device \"$VOLUME\" size is $DEVSIZE bytes"
|
||||||
# if the size parameter is missing use device size
|
# if the size parameter is missing use device size
|
||||||
#if [ -n "$NEWSIZE" -a $NEWSIZE <
|
#if [ -n "$NEWSIZE" -a $NEWSIZE <
|
||||||
test -z "$NEWSIZE" && NEWSIZE=${DEVSIZE}b
|
test -z "$NEWSIZE" && NEWSIZE=${DEVSIZE}b
|
||||||
@ -343,6 +340,7 @@ resize() {
|
|||||||
###################
|
###################
|
||||||
check() {
|
check() {
|
||||||
detect_fs "$1"
|
detect_fs "$1"
|
||||||
|
detect_mounted && error "Can not fsck device \"$VOLUME\", filesystem mounted on $MOUNTED"
|
||||||
case "$FSTYPE" in
|
case "$FSTYPE" in
|
||||||
"xfs") dry $XFS_CHECK "$VOLUME" ;;
|
"xfs") dry $XFS_CHECK "$VOLUME" ;;
|
||||||
*) dry $FSCK $YES "$VOLUME" ;;
|
*) dry $FSCK $YES "$VOLUME" ;;
|
||||||
@ -370,13 +368,14 @@ test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arith
|
|||||||
$(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly"
|
$(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly"
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" = "" ] ; then
|
if [ "$#" -eq 0 ] ; then
|
||||||
tool_usage
|
tool_usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [ "$1" != "" ]
|
while [ "$#" -ne 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
"") ;;
|
||||||
"-h"|"--help") tool_usage ;;
|
"-h"|"--help") tool_usage ;;
|
||||||
"-v"|"--verbose") VERB="-v" ;;
|
"-v"|"--verbose") VERB="-v" ;;
|
||||||
"-n"|"--dry-run") DRY=1 ;;
|
"-n"|"--dry-run") DRY=1 ;;
|
||||||
@ -384,8 +383,8 @@ do
|
|||||||
"-e"|"--ext-offline") EXTOFF=1 ;;
|
"-e"|"--ext-offline") EXTOFF=1 ;;
|
||||||
"-y"|"--yes") YES="-y" ;;
|
"-y"|"--yes") YES="-y" ;;
|
||||||
"-l"|"--lvresize") DO_LVRESIZE=1 ;;
|
"-l"|"--lvresize") DO_LVRESIZE=1 ;;
|
||||||
"check") shift; CHECK=$1 ;;
|
"check") CHECK="$2" ; shift ;;
|
||||||
"resize") shift; RESIZE=$1; shift; NEWSIZE=$1 ;;
|
"resize") RESIZE="$2"; NEWSIZE="$3" ; shift 2 ;;
|
||||||
*) error "Wrong argument \"$1\". (see: $TOOL --help)"
|
*) error "Wrong argument \"$1\". (see: $TOOL --help)"
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of LVM2.
|
* This file is part of LVM2.
|
||||||
*
|
*
|
||||||
@ -130,12 +130,30 @@ static int confirm_resizefs_reduce(struct cmd_context *cmd,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_resizefs_reduce(const struct cmd_context *cmd,
|
enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
char lv_path[PATH_MAX];
|
char lv_path[PATH_MAX];
|
||||||
char size_buf[SIZE_BUF];
|
char size_buf[SIZE_BUF];
|
||||||
|
const char *argv[10];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
argv[i++] = "fsadm"; /* FIXME: se configurable FSADM_CMD */
|
||||||
|
|
||||||
|
if (test_mode())
|
||||||
|
argv[i++] = "--dry-run";
|
||||||
|
|
||||||
|
if (verbose_level() > _LOG_WARN)
|
||||||
|
argv[i++] = "--verbose";
|
||||||
|
|
||||||
|
if (arg_count(cmd, force_ARG))
|
||||||
|
argv[i++] = "--force";
|
||||||
|
|
||||||
|
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->lv_name) < 0) {
|
lp->vg_name, lp->lv_name) < 0) {
|
||||||
@ -144,21 +162,21 @@ static int do_resizefs_reduce(const struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argv[i++] = lv_path;
|
||||||
|
|
||||||
|
if (fcmd == FSADM_CMD_RESIZE) {
|
||||||
if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64 "K",
|
if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64 "K",
|
||||||
(uint64_t) lp->extents * vg->extent_size / 2) < 0) {
|
(uint64_t) lp->extents * vg->extent_size / 2) < 0) {
|
||||||
log_error("Couldn't generate new LV size string");
|
log_error("Couldn't generate new LV size string");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lp->nofsck)
|
argv[i++] = size_buf;
|
||||||
if (!exec_cmd("fsadm", "check", lv_path, NULL))
|
}
|
||||||
return_0;
|
|
||||||
|
|
||||||
if (lp->resize == LV_REDUCE)
|
argv[i] = NULL;
|
||||||
if (!exec_cmd("fsadm", "resize", lv_path, size_buf))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
return 1;
|
return exec_cmd(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
|
static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
|
||||||
@ -268,8 +286,6 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
uint32_t seg_extents;
|
uint32_t seg_extents;
|
||||||
uint32_t sz, str;
|
uint32_t sz, str;
|
||||||
struct dm_list *pvh = NULL;
|
struct dm_list *pvh = NULL;
|
||||||
char size_buf[SIZE_BUF];
|
|
||||||
char lv_path[PATH_MAX];
|
|
||||||
|
|
||||||
/* does LV exist? */
|
/* does LV exist? */
|
||||||
if (!(lvl = find_lv_in_vg(vg, lp->lv_name))) {
|
if (!(lvl = find_lv_in_vg(vg, lp->lv_name))) {
|
||||||
@ -373,10 +389,13 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lp->extents == lv->le_count) {
|
if (lp->extents == lv->le_count) {
|
||||||
|
if (!lp->resizefs) {
|
||||||
log_error("New size (%d extents) matches existing size "
|
log_error("New size (%d extents) matches existing size "
|
||||||
"(%d extents)", lp->extents, lv->le_count);
|
"(%d extents)", lp->extents, lv->le_count);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
lp->resize = LV_EXTEND; /* lets pretend zero size extension */
|
||||||
|
}
|
||||||
|
|
||||||
seg_size = lp->extents - lv->le_count;
|
seg_size = lp->extents - lv->le_count;
|
||||||
|
|
||||||
@ -509,29 +528,21 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp->extents == lv->le_count) {
|
|
||||||
log_error("New size (%d extents) matches existing size "
|
|
||||||
"(%d extents)", lp->extents, lv->le_count);
|
|
||||||
return EINVALID_CMD_LINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lp->extents < lv->le_count) {
|
if (lp->extents < lv->le_count) {
|
||||||
if (lp->resize == LV_EXTEND) {
|
if (lp->resize == LV_EXTEND) {
|
||||||
log_error("New size given (%d extents) not larger "
|
log_error("New size given (%d extents) not larger "
|
||||||
"than existing size (%d extents)",
|
"than existing size (%d extents)",
|
||||||
lp->extents, lv->le_count);
|
lp->extents, lv->le_count);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
} else
|
|
||||||
lp->resize = LV_REDUCE;
|
|
||||||
}
|
}
|
||||||
|
lp->resize = LV_REDUCE;
|
||||||
if (lp->extents > lv->le_count) {
|
} else if (lp->extents > lv->le_count) {
|
||||||
if (lp->resize == LV_REDUCE) {
|
if (lp->resize == LV_REDUCE) {
|
||||||
log_error("New size given (%d extents) not less than "
|
log_error("New size given (%d extents) not less than "
|
||||||
"existing size (%d extents)", lp->extents,
|
"existing size (%d extents)", lp->extents,
|
||||||
lv->le_count);
|
lv->le_count);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
} else
|
}
|
||||||
lp->resize = LV_EXTEND;
|
lp->resize = LV_EXTEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,15 +573,23 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
log_warn("Ignoring PVs on command line when reducing");
|
log_warn("Ignoring PVs on command line when reducing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp->resize == LV_REDUCE || lp->resizefs) {
|
if ((lp->resizefs || (lp->resize == LV_REDUCE))
|
||||||
if (!confirm_resizefs_reduce(cmd, vg, lv, lp))
|
&& !confirm_resizefs_reduce(cmd, vg, lv, lp)) /* ensure active LV */
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
|
if (lp->resizefs) {
|
||||||
|
if (!lp->nofsck
|
||||||
|
&& !fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK)) {
|
||||||
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp->resizefs) {
|
if ((lp->resize == LV_REDUCE)
|
||||||
if (!do_resizefs_reduce(cmd, vg, lp))
|
&& !fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
|
||||||
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!archive(vg)) {
|
if (!archive(vg)) {
|
||||||
stack;
|
stack;
|
||||||
@ -587,7 +606,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
} else if (!lv_extend(lv, lp->segtype, lp->stripes,
|
} else if ((lp->extents > lv->le_count) /* check we really do extend */
|
||||||
|
&& !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)) {
|
||||||
@ -628,23 +648,11 @@ 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)
|
||||||
if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir,
|
&& !fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
|
||||||
lp->vg_name, lp->lv_name) < 0) {
|
|
||||||
log_error("Couldn't create LV path for %s",
|
|
||||||
lp->lv_name);
|
|
||||||
return ECMD_FAILED;
|
|
||||||
}
|
|
||||||
if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64 "K",
|
|
||||||
(uint64_t) lp->extents * vg->extent_size / 2) < 0) {
|
|
||||||
log_error("Couldn't generate new LV size string");
|
|
||||||
return ECMD_FAILED;
|
|
||||||
}
|
|
||||||
if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) {
|
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ECMD_PROCESSED;
|
return ECMD_PROCESSED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user