mirror of
git://sourceware.org/git/lvm2.git
synced 2026-01-05 04:32:48 +03:00
Compare commits
31 Commits
dm_v1_02_2
...
old-dm_v1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5571ff35d8 | ||
|
|
2a4819f3c8 | ||
|
|
7121866b13 | ||
|
|
d6e05ad9e2 | ||
|
|
993e30a7de | ||
|
|
49cae61254 | ||
|
|
1ea4b2ea91 | ||
|
|
bc1d6e1f90 | ||
|
|
9ec6e68d0c | ||
|
|
341bdc93e2 | ||
|
|
6fb3e1aa15 | ||
|
|
f1f92eb2e2 | ||
|
|
8c2369d40f | ||
|
|
a6d9fc58eb | ||
|
|
f7cd471548 | ||
|
|
5f951faf32 | ||
|
|
b228dfaf2c | ||
|
|
764858fa12 | ||
|
|
5ee976d276 | ||
|
|
8b28b6f2d3 | ||
|
|
fe16df2e6f | ||
|
|
779047f8c9 | ||
|
|
094e9fb45d | ||
|
|
1458bd0e74 | ||
|
|
d2cb05988d | ||
|
|
6e056767b4 | ||
|
|
a10afb1b98 | ||
|
|
bb6d3b6cfd | ||
|
|
c75d4af4bc | ||
|
|
972dc39d00 | ||
|
|
9daac5c178 |
21
WHATS_NEW
21
WHATS_NEW
@@ -1,3 +1,24 @@
|
||||
Version 2.02.27 -
|
||||
================================
|
||||
Turn _add_pv_to_vg() into external library function add_pv_to_vg().
|
||||
Add pv_by_path() external library function.
|
||||
Tidy clvmd-openais of redundant bits, and improve an error report.
|
||||
Cope with find_seg_by_le() failure in check_lv_segments().
|
||||
Call dev_iter_destroy() if _process_all_devs() is interrupted by sigint.
|
||||
Add vg_mda_count and pv_mda_count columns to reports.
|
||||
Fix dumpconfig to use log_print instead of stdout directly.
|
||||
Remove unused parameter 'fid' from _add_pv_to_vg.
|
||||
Add kernel and device-mapper targets versions to lvmdump.
|
||||
Replace BSD (r)index with C89 str(r)chr.
|
||||
Handle vgsplit of an entire VG as a vgrename.
|
||||
Reinitialise internal lvmdiskscan variables when called repeatedly.
|
||||
Fix missing lvm_shell symbol in lvm2cmd library. (2.02.23)
|
||||
Add vg_status function and clean up vg->status in tools directory.
|
||||
Add --ignoremonitoring to disable all dmeventd interaction.
|
||||
Remove get_ prefix from get_pv_* functions.
|
||||
clvmd-openais now uses cpg_local_get() to get nodeid, rather than Clm.
|
||||
Print warnings to stderr instead of stdout.
|
||||
|
||||
Version 2.02.26 - 15th June 2007
|
||||
================================
|
||||
Update vgcfgrestore man page.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
Version 1.02.21 - 13th July 2007
|
||||
================================
|
||||
Introduce _LOG_STDERR to send log_warn() messages to stderr not stdout.
|
||||
Fix dmsetup -o devno string termination. (1.02.20)
|
||||
|
||||
Version 1.02.20 - 15th June 2007
|
||||
================================
|
||||
Fix default dmsetup report buffering and add --unbuffered.
|
||||
|
||||
@@ -59,7 +59,7 @@ endif
|
||||
|
||||
ifeq ("$(OPENAIS)", "yes")
|
||||
SOURCES += clvmd-openais.c
|
||||
LMLIBS += -lSaLck -lSaClm -lcpg
|
||||
LMLIBS += -lSaLck -lcpg
|
||||
DEFS += -DUSE_OPENAIS
|
||||
endif
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <openais/saAis.h>
|
||||
#include <openais/saLck.h>
|
||||
#include <openais/saClm.h>
|
||||
#include <openais/cpg.h>
|
||||
|
||||
#include "list.h"
|
||||
@@ -98,9 +97,6 @@ SaLckCallbacksT lck_callbacks = {
|
||||
.saLckResourceUnlockCallback = lck_unlock_callback
|
||||
};
|
||||
|
||||
/* We only call Clm to get our node id */
|
||||
SaClmCallbacksT clm_callbacks;
|
||||
|
||||
struct node_info
|
||||
{
|
||||
enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state;
|
||||
@@ -348,9 +344,7 @@ static int _init_cluster(void)
|
||||
{
|
||||
SaAisErrorT err;
|
||||
SaVersionT ver = { 'B', 1, 1 };
|
||||
SaClmHandleT clm_handle;
|
||||
int select_fd;
|
||||
SaClmClusterNodeT cluster_node;
|
||||
|
||||
node_hash = dm_hash_create(100);
|
||||
lock_hash = dm_hash_create(10);
|
||||
@@ -383,31 +377,18 @@ static int _init_cluster(void)
|
||||
cpg_finalize(cpg_handle);
|
||||
saLckFinalize(lck_handle);
|
||||
syslog(LOG_ERR, "Cannot join clvmd process group");
|
||||
DEBUGLOG("Cannot join clvmd process group\n");
|
||||
DEBUGLOG("Cannot join clvmd process group: %d\n", err);
|
||||
return ais_to_errno(err);
|
||||
}
|
||||
|
||||
/* A brief foray into Clm to get our node id */
|
||||
err = saClmInitialize(&clm_handle, &clm_callbacks, &ver);
|
||||
if (err != SA_AIS_OK) {
|
||||
syslog(LOG_ERR, "Could not initialize OpenAIS membership service %d\n", err);
|
||||
DEBUGLOG("Could not initialize OpenAIS Membership service %d\n", err);
|
||||
return ais_to_errno(err);
|
||||
}
|
||||
|
||||
err = saClmClusterNodeGet(clm_handle,
|
||||
SA_CLM_LOCAL_NODE_ID,
|
||||
TIMEOUT,
|
||||
&cluster_node);
|
||||
err = cpg_local_get(cpg_handle,
|
||||
&our_nodeid);
|
||||
if (err != SA_AIS_OK) {
|
||||
cpg_finalize(cpg_handle);
|
||||
saLckFinalize(lck_handle);
|
||||
saClmFinalize(clm_handle);
|
||||
syslog(LOG_ERR, "Cannot get local node id\n");
|
||||
return ais_to_errno(err);
|
||||
}
|
||||
saClmFinalize(clm_handle);
|
||||
our_nodeid = cluster_node.nodeId;
|
||||
DEBUGLOG("Our local node id is %d\n", our_nodeid);
|
||||
|
||||
saLckSelectionObjectGet(lck_handle, (SaSelectionObjectT *)&select_fd);
|
||||
@@ -424,7 +405,7 @@ static void _cluster_closedown(void)
|
||||
unlock_all();
|
||||
|
||||
saLckFinalize(lck_handle);
|
||||
cpg_inalize(cpg_handle);
|
||||
cpg_finalize(cpg_handle);
|
||||
}
|
||||
|
||||
static void _get_our_csid(char *csid)
|
||||
|
||||
@@ -245,7 +245,7 @@ void set_activation(int act)
|
||||
log_verbose("Activation enabled. Device-mapper kernel "
|
||||
"driver will be used.");
|
||||
else
|
||||
log_print("WARNING: Activation disabled. No device-mapper "
|
||||
log_warn("WARNING: Activation disabled. No device-mapper "
|
||||
"interaction will be attempted.");
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (!index(str, '/')) {
|
||||
if (!strchr(str, '/')) {
|
||||
/* vgname supplied */
|
||||
if (!strcmp(str, lv->vg->name))
|
||||
return 1;
|
||||
|
||||
@@ -561,7 +561,7 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
log_debug("Getting device info for %s", dl->name);
|
||||
|
||||
/* Rename? */
|
||||
if ((suffix = rindex(dl->dlid + sizeof(UUID_PREFIX) - 1, '-')))
|
||||
if ((suffix = strrchr(dl->dlid + sizeof(UUID_PREFIX) - 1, '-')))
|
||||
suffix++;
|
||||
newname = build_dm_name(dm->mem, dm->vg_name, dl->lv->name,
|
||||
suffix);
|
||||
|
||||
@@ -184,7 +184,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
}
|
||||
|
||||
if (*cmd->proc_dir && !dir_exists(cmd->proc_dir)) {
|
||||
log_error("Warning: proc dir %s not found - some checks will be bypassed",
|
||||
log_error("WARNING: proc dir %s not found - some checks will be bypassed",
|
||||
cmd->proc_dir);
|
||||
cmd->proc_dir[0] = '\0';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
@@ -66,6 +66,11 @@ struct cs {
|
||||
struct device *dev;
|
||||
};
|
||||
|
||||
struct output_line {
|
||||
FILE *fp;
|
||||
struct dm_pool *mem;
|
||||
};
|
||||
|
||||
static void _get_token(struct parser *p, int tok_prev);
|
||||
static void _eat_space(struct parser *p);
|
||||
static struct config_node *_file(struct parser *p);
|
||||
@@ -345,33 +350,87 @@ int config_file_changed(struct config_tree *cft)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _write_value(FILE *fp, struct config_value *v)
|
||||
static int _line_start(struct output_line *outline)
|
||||
{
|
||||
if (!dm_pool_begin_object(outline->mem, 128)) {
|
||||
log_error("dm_pool_begin_object failed for config line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _line_append(struct output_line *outline, const char *fmt, ...)
|
||||
{
|
||||
char buf[4096];
|
||||
va_list ap;
|
||||
int n;
|
||||
|
||||
va_start(ap, fmt);
|
||||
n = vsnprintf(&buf[0], 4095, fmt, ap);
|
||||
if (n < 0 || n > 4095) {
|
||||
log_error("vsnprintf failed for config line");
|
||||
return 0;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
if (!dm_pool_grow_object(outline->mem, &buf[0], strlen(buf))) {
|
||||
log_error("dm_pool_grew_object failed for config line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define line_append(args...) do {if (!_line_append(outline, args)) {return_0;}} while (0)
|
||||
|
||||
static int _line_end(struct output_line *outline)
|
||||
{
|
||||
const char *line;
|
||||
|
||||
if (!dm_pool_grow_object(outline->mem, "\0", 1)) {
|
||||
log_error("dm_pool_grow_object failed for config line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
line = dm_pool_end_object(outline->mem);
|
||||
if (!outline->fp)
|
||||
log_print("%s", line);
|
||||
else
|
||||
fprintf(outline->fp, "%s\n", line);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _write_value(struct output_line *outline, struct config_value *v)
|
||||
{
|
||||
switch (v->type) {
|
||||
case CFG_STRING:
|
||||
fprintf(fp, "\"%s\"", v->v.str);
|
||||
line_append("\"%s\"", v->v.str);
|
||||
break;
|
||||
|
||||
case CFG_FLOAT:
|
||||
fprintf(fp, "%f", v->v.r);
|
||||
line_append("%f", v->v.r);
|
||||
break;
|
||||
|
||||
case CFG_INT:
|
||||
fprintf(fp, "%" PRId64, v->v.i);
|
||||
line_append("%" PRId64, v->v.i);
|
||||
break;
|
||||
|
||||
case CFG_EMPTY_ARRAY:
|
||||
fprintf(fp, "[]");
|
||||
line_append("[]");
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error("_write_value: Unknown value type: %d", v->type);
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _write_config(struct config_node *n, int only_one, FILE *fp,
|
||||
int level)
|
||||
static int _write_config(struct config_node *n, int only_one,
|
||||
struct output_line *outline, int level)
|
||||
{
|
||||
char space[MAX_INDENT + 1];
|
||||
int l = (level < MAX_INDENT) ? level : MAX_INDENT;
|
||||
@@ -385,29 +444,38 @@ static int _write_config(struct config_node *n, int only_one, FILE *fp,
|
||||
space[i] = '\0';
|
||||
|
||||
do {
|
||||
fprintf(fp, "%s%s", space, n->key);
|
||||
if (!_line_start(outline))
|
||||
return_0;
|
||||
line_append("%s%s", space, n->key);
|
||||
if (!n->v) {
|
||||
/* it's a sub section */
|
||||
fprintf(fp, " {\n");
|
||||
_write_config(n->child, 0, fp, level + 1);
|
||||
fprintf(fp, "%s}", space);
|
||||
line_append(" {");
|
||||
if (!_line_end(outline))
|
||||
return_0;
|
||||
if (!_line_start(outline))
|
||||
return_0;
|
||||
_write_config(n->child, 0, outline, level + 1);
|
||||
line_append("%s}", space);
|
||||
} else {
|
||||
/* it's a value */
|
||||
struct config_value *v = n->v;
|
||||
fprintf(fp, "=");
|
||||
line_append("=");
|
||||
if (v->next) {
|
||||
fprintf(fp, "[");
|
||||
line_append("[");
|
||||
while (v) {
|
||||
_write_value(fp, v);
|
||||
if (!_write_value(outline, v))
|
||||
return_0;
|
||||
v = v->next;
|
||||
if (v)
|
||||
fprintf(fp, ", ");
|
||||
line_append(", ");
|
||||
}
|
||||
fprintf(fp, "]");
|
||||
line_append("]");
|
||||
} else
|
||||
_write_value(fp, v);
|
||||
if (!_write_value(outline, v))
|
||||
return_0;
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
if (!_line_end(outline))
|
||||
return_0;
|
||||
n = n->sib;
|
||||
} while (n && !only_one);
|
||||
/* FIXME: add error checking */
|
||||
@@ -419,25 +487,27 @@ int write_config_file(struct config_tree *cft, const char *file,
|
||||
{
|
||||
struct config_node *cn;
|
||||
int r = 1;
|
||||
FILE *fp;
|
||||
struct output_line outline;
|
||||
outline.fp = NULL;
|
||||
|
||||
if (!file) {
|
||||
fp = stdout;
|
||||
if (!file)
|
||||
file = "stdout";
|
||||
} else if (!(fp = fopen(file, "w"))) {
|
||||
else if (!(outline.fp = fopen(file, "w"))) {
|
||||
log_sys_error("open", file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
outline.mem = dm_pool_create("config_line", 1024);
|
||||
|
||||
log_verbose("Dumping configuration to %s", file);
|
||||
if (!argc) {
|
||||
if (!_write_config(cft->root, 0, fp, 0)) {
|
||||
if (!_write_config(cft->root, 0, &outline, 0)) {
|
||||
log_error("Failure while writing to %s", file);
|
||||
r = 0;
|
||||
}
|
||||
} else while (argc--) {
|
||||
if ((cn = find_config_node(cft->root, *argv))) {
|
||||
if (!_write_config(cn, 1, fp, 0)) {
|
||||
if (!_write_config(cn, 1, &outline, 0)) {
|
||||
log_error("Failure while writing to %s", file);
|
||||
r = 0;
|
||||
}
|
||||
@@ -448,11 +518,12 @@ int write_config_file(struct config_tree *cft, const char *file,
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ((fp != stdout) && fclose(fp)) {
|
||||
if (outline.fp && fclose(outline.fp)) {
|
||||
log_sys_error("fclose", file);
|
||||
r = 0;
|
||||
}
|
||||
|
||||
dm_pool_destroy(outline.mem);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -918,26 +989,26 @@ float find_config_float(const struct config_node *cn, const char *path,
|
||||
}
|
||||
|
||||
struct config_node *find_config_tree_node(struct cmd_context *cmd,
|
||||
const char *path)
|
||||
const char *path)
|
||||
{
|
||||
return _find_first_config_node(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path);
|
||||
}
|
||||
|
||||
const char *find_config_tree_str(struct cmd_context *cmd,
|
||||
const char *path, const char *fail)
|
||||
const char *path, const char *fail)
|
||||
{
|
||||
return _find_config_str(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
||||
}
|
||||
|
||||
int find_config_tree_int(struct cmd_context *cmd, const char *path,
|
||||
int fail)
|
||||
int fail)
|
||||
{
|
||||
/* FIXME Add log_error message on overflow */
|
||||
return (int) _find_config_int64(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, (int64_t) fail);
|
||||
}
|
||||
|
||||
float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
||||
float fail)
|
||||
float fail)
|
||||
{
|
||||
return _find_config_float(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ static int _split_vg(const char *filename, char *vgname, size_t vg_size,
|
||||
if (strcmp(".vg", dot))
|
||||
return 0;
|
||||
|
||||
if (!(underscore = rindex(filename, '_')))
|
||||
if (!(underscore = strrchr(filename, '_')))
|
||||
return 0;
|
||||
|
||||
if (sscanf(underscore + 1, "%u", ix) != 1)
|
||||
|
||||
@@ -214,7 +214,7 @@ static int __backup(struct volume_group *vg)
|
||||
int backup(struct volume_group *vg)
|
||||
{
|
||||
if (!vg->cmd->backup_params->enabled || !vg->cmd->backup_params->dir) {
|
||||
log_print("WARNING: This metadata update is NOT backed up");
|
||||
log_warn("WARNING: This metadata update is NOT backed up");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -850,7 +850,7 @@ static int _vg_write_file(struct format_instance *fid, struct volume_group *vg,
|
||||
char *slash;
|
||||
char temp_file[PATH_MAX], temp_dir[PATH_MAX];
|
||||
|
||||
slash = rindex(tc->path_edit, '/');
|
||||
slash = strrchr(tc->path_edit, '/');
|
||||
|
||||
if (slash == 0)
|
||||
strcpy(temp_dir, ".");
|
||||
@@ -948,7 +948,7 @@ static int _vg_commit_file(struct format_instance *fid, struct volume_group *vg,
|
||||
return 0;
|
||||
|
||||
/* vgrename? */
|
||||
if ((slash = rindex(tc->path_live, '/')))
|
||||
if ((slash = strrchr(tc->path_live, '/')))
|
||||
slash = slash + 1;
|
||||
else
|
||||
slash = tc->path_live;
|
||||
@@ -1204,8 +1204,8 @@ static int _mda_setup(const struct format_type *fmt,
|
||||
|
||||
/* Ensure it's not going to be bigger than the disk! */
|
||||
if (start1 + mda_size1 > disk_size) {
|
||||
log_print("Warning: metadata area fills disk leaving no "
|
||||
"space for data on %s.", dev_name(pv->dev));
|
||||
log_warn("WARNING: metadata area fills disk leaving no "
|
||||
"space for data on %s.", dev_name(pv->dev));
|
||||
/* Leave some free space for rounding */
|
||||
/* Avoid empty data area as could cause tools problems */
|
||||
mda_size1 = disk_size - start1 - alignment * 2;
|
||||
|
||||
@@ -44,46 +44,50 @@ static void _catch_sigint(int unused __attribute__((unused)))
|
||||
_sigint_caught = 1;
|
||||
}
|
||||
|
||||
int sigint_caught() {
|
||||
int sigint_caught(void) {
|
||||
return _sigint_caught;
|
||||
}
|
||||
|
||||
void sigint_clear()
|
||||
void sigint_clear(void)
|
||||
{
|
||||
_sigint_caught = 0;
|
||||
}
|
||||
|
||||
/* Temporarily allow keyboard interrupts to be intercepted and noted;
|
||||
saves interrupt handler state for sigint_restore(). Users should
|
||||
use the sigint_caught() predicate to check whether interrupt was
|
||||
requested and act appropriately. Interrupt flags are never
|
||||
automatically cleared by this code, but lvm_run_command() clears
|
||||
the flag before running any command. All other places where the
|
||||
flag needs to be cleared need to call sigint_clear(). */
|
||||
/*
|
||||
* Temporarily allow keyboard interrupts to be intercepted and noted;
|
||||
* saves interrupt handler state for sigint_restore(). Users should
|
||||
* use the sigint_caught() predicate to check whether interrupt was
|
||||
* requested and act appropriately. Interrupt flags are never
|
||||
* cleared automatically by this code, but the tools clear the flag
|
||||
* before running each command in lvm_run_command(). All other places
|
||||
* where the flag needs to be cleared need to call sigint_clear().
|
||||
*/
|
||||
|
||||
void sigint_allow()
|
||||
void sigint_allow(void)
|
||||
{
|
||||
struct sigaction handler;
|
||||
sigset_t sigs;
|
||||
|
||||
/* do not overwrite the backed up handler data with our
|
||||
override ones; we just increase nesting count */
|
||||
/*
|
||||
* Do not overwrite the backed-up handler data -
|
||||
* just increase nesting count.
|
||||
*/
|
||||
if (_handler_installed) {
|
||||
_handler_installed++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* grab old sigaction for SIGINT; shall not fail */
|
||||
/* Grab old sigaction for SIGINT: shall not fail. */
|
||||
sigaction(SIGINT, NULL, &handler);
|
||||
handler.sa_flags &= ~SA_RESTART; /* clear restart flag */
|
||||
handler.sa_flags &= ~SA_RESTART; /* Clear restart flag */
|
||||
handler.sa_handler = _catch_sigint;
|
||||
|
||||
_handler_installed = 1;
|
||||
|
||||
/* override the signal handler; shall not fail */
|
||||
/* Override the signal handler: shall not fail. */
|
||||
sigaction(SIGINT, &handler, &_oldhandler);
|
||||
|
||||
/* unmask SIGINT, remember to mask it again on restore */
|
||||
/* Unmask SIGINT. Remember to mask it again on restore. */
|
||||
sigprocmask(0, NULL, &sigs);
|
||||
if ((_oldmasked = sigismember(&sigs, SIGINT))) {
|
||||
sigdelset(&sigs, SIGINT);
|
||||
@@ -91,9 +95,8 @@ void sigint_allow()
|
||||
}
|
||||
}
|
||||
|
||||
void sigint_restore()
|
||||
void sigint_restore(void)
|
||||
{
|
||||
/* extra call, ignore */
|
||||
if (!_handler_installed)
|
||||
return;
|
||||
|
||||
@@ -102,7 +105,7 @@ void sigint_restore()
|
||||
return;
|
||||
}
|
||||
|
||||
/* nesting count went down to 0 */
|
||||
/* Nesting count went down to 0. */
|
||||
_handler_installed = 0;
|
||||
|
||||
if (_oldmasked) {
|
||||
@@ -211,7 +214,7 @@ int init_locking(int type, struct cmd_context *cmd)
|
||||
switch (type) {
|
||||
case 0:
|
||||
init_no_locking(&_locking, cmd);
|
||||
log_print("WARNING: Locking disabled. Be careful! "
|
||||
log_warn("WARNING: Locking disabled. Be careful! "
|
||||
"This could corrupt your metadata.");
|
||||
return 1;
|
||||
|
||||
@@ -252,8 +255,8 @@ int init_locking(int type, struct cmd_context *cmd)
|
||||
if ((type == 2 || type == 3) &&
|
||||
find_config_tree_int(cmd, "locking/fallback_to_local_locking",
|
||||
DEFAULT_FALLBACK_TO_LOCAL_LOCKING)) {
|
||||
log_print("WARNING: Falling back to local file-based locking.");
|
||||
log_print("Volume Groups with the clustered attribute will "
|
||||
log_warn("WARNING: Falling back to local file-based locking.");
|
||||
log_warn("Volume Groups with the clustered attribute will "
|
||||
"be inaccessible.");
|
||||
if (init_file_locking(&_locking, cmd))
|
||||
return 1;
|
||||
|
||||
@@ -115,11 +115,10 @@ int suspend_lvs(struct cmd_context *cmd, struct list *lvs);
|
||||
int resume_lvs(struct cmd_context *cmd, struct list *lvs);
|
||||
int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs);
|
||||
|
||||
/* interrupt handling */
|
||||
|
||||
void sigint_clear();
|
||||
void sigint_allow();
|
||||
void sigint_restore();
|
||||
int sigint_caught();
|
||||
/* Interrupt handling */
|
||||
void sigint_clear(void);
|
||||
void sigint_allow(void);
|
||||
void sigint_restore(void);
|
||||
int sigint_caught(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -302,6 +302,9 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
int bufused, n;
|
||||
const char *message;
|
||||
const char *trformat; /* Translated format string */
|
||||
int use_stderr = level & _LOG_STDERR;
|
||||
|
||||
level &= ~_LOG_STDERR;
|
||||
|
||||
if (_log_suppress == 2)
|
||||
return;
|
||||
@@ -373,9 +376,9 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
break;
|
||||
case _LOG_WARN:
|
||||
if (_verbose_level >= _LOG_WARN) {
|
||||
printf("%s%s", _cmd_name, _msg_prefix);
|
||||
vprintf(trformat, ap);
|
||||
putchar('\n');
|
||||
fprintf(use_stderr ? stderr : stdout, "%s%s", _cmd_name, _msg_prefix);
|
||||
vfprintf(use_stderr ? stderr : stdout, trformat, ap);
|
||||
fputc('\n', use_stderr ? stderr : stdout);
|
||||
}
|
||||
break;
|
||||
case _LOG_ERR:
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <string.h> /* strerror() */
|
||||
#include <errno.h>
|
||||
|
||||
#define _LOG_STDERR 128 /* force things to go to stderr, even if loglevel
|
||||
would make them go to stdout */
|
||||
#define _LOG_DEBUG 7
|
||||
#define _LOG_INFO 6
|
||||
#define _LOG_NOTICE 5
|
||||
@@ -116,14 +118,14 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
#define log_debug(x...) plog(_LOG_DEBUG, x)
|
||||
#define log_info(x...) plog(_LOG_INFO, x)
|
||||
#define log_notice(x...) plog(_LOG_NOTICE, x)
|
||||
#define log_warn(x...) plog(_LOG_WARN, x)
|
||||
#define log_warn(x...) plog(_LOG_WARN | _LOG_STDERR, x)
|
||||
#define log_err(x...) plog(_LOG_ERR, x)
|
||||
#define log_fatal(x...) plog(_LOG_FATAL, x)
|
||||
|
||||
#define stack log_debug("<backtrace>") /* Backtrace on error */
|
||||
|
||||
#define log_error(args...) log_err(args)
|
||||
#define log_print(args...) log_warn(args)
|
||||
#define log_print(args...) plog(_LOG_WARN, args)
|
||||
#define log_verbose(args...) log_notice(args)
|
||||
#define log_very_verbose(args...) log_info(args)
|
||||
|
||||
|
||||
@@ -146,9 +146,9 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
|
||||
|
||||
if (complete_vg && seg_lv(seg, s) &&
|
||||
(seg_lv(seg, s)->status & MIRROR_IMAGE) &&
|
||||
(find_seg_by_le(seg_lv(seg, s),
|
||||
seg_le(seg, s))->mirror_seg
|
||||
!= seg)) {
|
||||
(!(seg2 = find_seg_by_le(seg_lv(seg, s),
|
||||
seg_le(seg, s))) ||
|
||||
seg2->mirror_seg != seg)) {
|
||||
log_error("LV %s: segment %u mirror "
|
||||
"image %u missing mirror ptr",
|
||||
lv->name, seg_count, s);
|
||||
|
||||
@@ -66,13 +66,23 @@ unsigned long pe_align(void)
|
||||
return MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
|
||||
}
|
||||
|
||||
static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
const char *pv_name)
|
||||
/**
|
||||
* add_pv_to_vg - Add a physical volume to a volume group
|
||||
* @vg - volume group to add to
|
||||
* @pv_name - name of the pv (to be removed)
|
||||
* @pv - physical volume to add to volume group
|
||||
*
|
||||
* Returns:
|
||||
* 0 - failure
|
||||
* 1 - success
|
||||
* FIXME: remove pv_name - obtain safely from pv
|
||||
*/
|
||||
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
|
||||
struct physical_volume *pv)
|
||||
{
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
struct format_instance *fid = vg->fid;
|
||||
struct dm_pool *mem = fid->fmt->cmd->mem;
|
||||
struct list mdas;
|
||||
|
||||
log_verbose("Adding physical volume '%s' to volume group '%s'",
|
||||
pv_name, vg->name);
|
||||
@@ -82,13 +92,6 @@ static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_init(&mdas);
|
||||
if (!(pv = _pv_read(fid->fmt->cmd, pv_name, &mdas, NULL, 1))) {
|
||||
log_error("%s not identified as an existing physical volume",
|
||||
pv_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*pv->vg_name) {
|
||||
log_error("Physical volume '%s' is already in volume group "
|
||||
"'%s'", pv_name, pv->vg_name);
|
||||
@@ -207,8 +210,8 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
|
||||
}
|
||||
|
||||
if (!consistent)
|
||||
log_error("Warning: Volume group %s is not consistent",
|
||||
vg_name);
|
||||
log_warn("WARNING: Volume group %s is not consistent",
|
||||
vg_name);
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
if (id_equal(&pvl->pv->id, (const struct id *) pvid)) {
|
||||
@@ -245,22 +248,31 @@ int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vg_extend(struct format_instance *fid,
|
||||
struct volume_group *vg, int pv_count, char **pv_names)
|
||||
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
|
||||
{
|
||||
int i;
|
||||
struct physical_volume *pv;
|
||||
|
||||
/* attach each pv */
|
||||
for (i = 0; i < pv_count; i++)
|
||||
if (!_add_pv_to_vg(fid, vg, pv_names[i])) {
|
||||
log_error("Unable to add physical volume '%s' to "
|
||||
"volume group '%s'.", pv_names[i], vg->name);
|
||||
return 0;
|
||||
for (i = 0; i < pv_count; i++) {
|
||||
if (!(pv = pv_by_path(vg->fid->fmt->cmd, pv_names[i]))) {
|
||||
log_error("%s not identified as an existing "
|
||||
"physical volume", pv_names[i]);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!add_pv_to_vg(vg, pv_names[i], pv))
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/* FIXME Decide whether to initialise and add new mdahs to format instance */
|
||||
|
||||
return 1;
|
||||
|
||||
bad:
|
||||
log_error("Unable to add physical volume '%s' to "
|
||||
"volume group '%s'.", pv_names[i], vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *strip_dir(const char *vg_name, const char *dev_dir)
|
||||
@@ -352,7 +364,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
/* attach the pv's */
|
||||
if (!vg_extend(vg->fid, vg, pv_count, pv_names))
|
||||
if (!vg_extend(vg, pv_count, pv_names))
|
||||
goto_bad;
|
||||
|
||||
return vg;
|
||||
@@ -642,7 +654,7 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,
|
||||
|
||||
if (size) {
|
||||
if (size > pv->size)
|
||||
log_print("WARNING: %s: Overriding real size. "
|
||||
log_warn("WARNING: %s: Overriding real size. "
|
||||
"You could lose data.", dev_name(pv->dev));
|
||||
log_verbose("%s: Pretending size is %" PRIu64 " sectors.",
|
||||
dev_name(pv->dev), size);
|
||||
@@ -1325,8 +1337,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
return correct_vg;
|
||||
}
|
||||
|
||||
log_print("Inconsistent metadata found for VG %s - updating "
|
||||
"to use version %u", vgname, correct_vg->seqno);
|
||||
log_warn("WARNING: Inconsistent metadata found for VG %s - updating "
|
||||
"to use version %u", vgname, correct_vg->seqno);
|
||||
|
||||
if (!vg_write(correct_vg)) {
|
||||
log_error("Automatic metadata correction failed");
|
||||
@@ -1621,8 +1633,8 @@ struct list *get_pvs(struct cmd_context *cmd)
|
||||
continue;
|
||||
}
|
||||
if (!consistent)
|
||||
log_print("Warning: Volume Group %s is not consistent",
|
||||
vgname);
|
||||
log_warn("WARNING: Volume Group %s is not consistent",
|
||||
vgname);
|
||||
|
||||
/* Move PVs onto results list */
|
||||
list_iterate_safe(pvh, tmp, &vg->pvs) {
|
||||
@@ -1745,33 +1757,33 @@ int pv_analyze(struct cmd_context *cmd, const char *pv_name,
|
||||
/**
|
||||
* vg_check_status - check volume group status flags and log error
|
||||
* @vg - volume group to check status flags
|
||||
* @status_flags - specific status flags to check (e.g. EXPORTED_VG)
|
||||
* @status - specific status flags to check (e.g. EXPORTED_VG)
|
||||
*
|
||||
* Returns:
|
||||
* 0 - fail
|
||||
* 1 - success
|
||||
*/
|
||||
int vg_check_status(struct volume_group *vg, uint32_t status_flags)
|
||||
int vg_check_status(struct volume_group *vg, uint32_t status)
|
||||
{
|
||||
if ((status_flags & CLUSTERED) &&
|
||||
if ((status & CLUSTERED) &&
|
||||
(vg->status & CLUSTERED) && !locking_is_clustered() &&
|
||||
!lockingfailed()) {
|
||||
log_error("Skipping clustered volume group %s", vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((status_flags & EXPORTED_VG) &&
|
||||
if ((status & EXPORTED_VG) &&
|
||||
(vg->status & EXPORTED_VG)) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((status_flags & LVM_WRITE) &&
|
||||
if ((status & LVM_WRITE) &&
|
||||
!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg->name);
|
||||
return 0;
|
||||
}
|
||||
if ((status_flags & RESIZEABLE_VG) &&
|
||||
if ((status & RESIZEABLE_VG) &&
|
||||
!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group %s is not resizeable.", vg->name);
|
||||
return 0;
|
||||
@@ -1784,57 +1796,82 @@ int vg_check_status(struct volume_group *vg, uint32_t status_flags)
|
||||
/*
|
||||
* Gets/Sets for external LVM library
|
||||
*/
|
||||
struct id get_pv_id(pv_t *pv)
|
||||
struct id pv_id(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, id);
|
||||
}
|
||||
|
||||
const struct format_type *get_pv_format_type(pv_t *pv)
|
||||
const struct format_type *pv_format_type(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, fmt);
|
||||
}
|
||||
|
||||
struct id get_pv_vgid(pv_t *pv)
|
||||
struct id pv_vgid(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, vgid);
|
||||
}
|
||||
|
||||
struct device *get_pv_dev(pv_t *pv)
|
||||
struct device *pv_dev(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, dev);
|
||||
}
|
||||
|
||||
const char *get_pv_vg_name(pv_t *pv)
|
||||
const char *pv_vg_name(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, vg_name);
|
||||
}
|
||||
|
||||
uint64_t get_pv_size(pv_t *pv)
|
||||
uint64_t pv_size(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, size);
|
||||
}
|
||||
|
||||
uint32_t get_pv_status(pv_t *pv)
|
||||
uint32_t pv_status(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, status);
|
||||
}
|
||||
|
||||
uint32_t get_pv_pe_size(pv_t *pv)
|
||||
uint32_t pv_pe_size(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, pe_size);
|
||||
}
|
||||
|
||||
uint64_t get_pv_pe_start(pv_t *pv)
|
||||
uint64_t pv_pe_start(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, pe_start);
|
||||
}
|
||||
|
||||
uint32_t get_pv_pe_count(pv_t *pv)
|
||||
uint32_t pv_pe_count(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, pe_count);
|
||||
}
|
||||
|
||||
uint32_t get_pv_pe_alloc_count(pv_t *pv)
|
||||
uint32_t pv_pe_alloc_count(pv_t *pv)
|
||||
{
|
||||
return pv_field(pv, pe_alloc_count);
|
||||
}
|
||||
|
||||
uint32_t vg_status(vg_t *vg)
|
||||
{
|
||||
return vg->status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pv_by_path - Given a device path return a PV handle if it is a PV
|
||||
* @cmd - handle to the LVM command instance
|
||||
* @pv_name - device path to read for the PV
|
||||
*
|
||||
* Returns:
|
||||
* NULL - device path does not contain a valid PV
|
||||
* non-NULL - PV handle corresponding to device path
|
||||
*
|
||||
* FIXME: merge with find_pv_by_name ?
|
||||
*/
|
||||
pv_t *pv_by_path(struct cmd_context *cmd, const char *pv_name)
|
||||
{
|
||||
struct list mdas;
|
||||
|
||||
list_init(&mdas);
|
||||
return _pv_read(cmd, pv_name, &mdas, NULL, 1);
|
||||
}
|
||||
|
||||
@@ -235,6 +235,8 @@ struct volume_group {
|
||||
struct list tags;
|
||||
};
|
||||
|
||||
typedef struct volume_group vg_t;
|
||||
|
||||
/* There will be one area for each stripe */
|
||||
struct lv_segment_area {
|
||||
area_type_t type;
|
||||
@@ -461,8 +463,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
|
||||
int vg_remove(struct volume_group *vg);
|
||||
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
|
||||
const char *new_name);
|
||||
int vg_extend(struct format_instance *fi, struct volume_group *vg,
|
||||
int pv_count, char **pv_names);
|
||||
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
|
||||
int vg_change_pesize(struct cmd_context *cmd, struct volume_group *vg,
|
||||
uint32_t new_extent_size);
|
||||
int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
|
||||
@@ -579,7 +580,7 @@ int vg_add_snapshot(struct format_instance *fid, const char *name,
|
||||
|
||||
int vg_remove_snapshot(struct logical_volume *cow);
|
||||
|
||||
int vg_check_status(struct volume_group *vg, uint32_t status_flags);
|
||||
int vg_check_status(struct volume_group *vg, uint32_t status);
|
||||
|
||||
/*
|
||||
* Mirroring functions
|
||||
@@ -637,18 +638,24 @@ char *generate_lv_name(struct volume_group *vg, const char *format,
|
||||
char *buffer, size_t len);
|
||||
|
||||
/*
|
||||
* Gets/Sets for external LVM library
|
||||
* Begin skeleton for external LVM library
|
||||
*/
|
||||
struct id get_pv_id(pv_t *pv);
|
||||
const struct format_type *get_pv_format_type(pv_t *pv);
|
||||
struct id get_pv_vgid(pv_t *pv);
|
||||
struct device *get_pv_dev(pv_t *pv);
|
||||
const char *get_pv_vg_name(pv_t *pv);
|
||||
uint64_t get_pv_size(pv_t *pv);
|
||||
uint32_t get_pv_status(pv_t *pv);
|
||||
uint32_t get_pv_pe_size(pv_t *pv);
|
||||
uint64_t get_pv_pe_start(pv_t *pv);
|
||||
uint32_t get_pv_pe_count(pv_t *pv);
|
||||
uint32_t get_pv_pe_alloc_count(pv_t *pv);
|
||||
struct id pv_id(pv_t *pv);
|
||||
const struct format_type *pv_format_type(pv_t *pv);
|
||||
struct id pv_vgid(pv_t *pv);
|
||||
struct device *pv_dev(pv_t *pv);
|
||||
const char *pv_vg_name(pv_t *pv);
|
||||
uint64_t pv_size(pv_t *pv);
|
||||
uint32_t pv_status(pv_t *pv);
|
||||
uint32_t pv_pe_size(pv_t *pv);
|
||||
uint64_t pv_pe_start(pv_t *pv);
|
||||
uint32_t pv_pe_count(pv_t *pv);
|
||||
uint32_t pv_pe_alloc_count(pv_t *pv);
|
||||
|
||||
uint32_t vg_status(vg_t *vg);
|
||||
|
||||
pv_t *pv_by_path(struct cmd_context *cmd, const char *pv_name);
|
||||
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
|
||||
struct physical_volume *pv);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -377,7 +377,7 @@ int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirr
|
||||
/* Unable to remove bad devices */
|
||||
return 0;
|
||||
|
||||
log_print("WARNING: Bad device removed from mirror volume, %s/%s",
|
||||
log_warn("WARNING: Bad device removed from mirror volume, %s/%s",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
|
||||
log_policy = get_mirror_log_fault_policy(mirrored_seg->lv->vg->cmd);
|
||||
@@ -394,15 +394,15 @@ int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirr
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
else if (r > 0)
|
||||
/* Success in replacing device(s) */
|
||||
log_print("WARNING: Mirror volume, %s/%s restored - substitute for failed device found.",
|
||||
log_warn("WARNING: Mirror volume, %s/%s restored - substitute for failed device found.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
else
|
||||
/* Bad device removed, but not replaced because of policy */
|
||||
if (mirrored_seg->area_count == 1) {
|
||||
log_print("WARNING: Mirror volume, %s/%s converted to linear due to device failure.",
|
||||
log_warn("WARNING: Mirror volume, %s/%s converted to linear due to device failure.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
} else if (had_log && !mirrored_seg->log_lv) {
|
||||
log_print("WARNING: Mirror volume, %s/%s disk log removed due to device failure.",
|
||||
log_warn("WARNING: Mirror volume, %s/%s disk log removed due to device failure.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -47,6 +47,7 @@ FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr", "Various attributes
|
||||
FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count", "Total number of Physical Extents.")
|
||||
FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.")
|
||||
FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.")
|
||||
FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, "pv_mda_count", "Number of metadata areas on this device.")
|
||||
|
||||
FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.")
|
||||
FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.")
|
||||
@@ -65,6 +66,7 @@ FIELD(VGS, vg, NUM, "#LV", lv_count, 3, uint32, "lv_count", "Number of LVs.")
|
||||
FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.")
|
||||
FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.")
|
||||
FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.")
|
||||
FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas in use by this VG.")
|
||||
|
||||
FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype", "Type of LV segment")
|
||||
FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes", "Number of stripes or mirror legs.")
|
||||
|
||||
@@ -718,6 +718,32 @@ static int _int32_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
return dm_report_field_int32(rh, field, data);
|
||||
}
|
||||
|
||||
static int _pvmdas_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private)
|
||||
{
|
||||
struct lvmcache_info *info;
|
||||
uint32_t count;
|
||||
const char *pvid = (const char *)(&((struct id *) data)->uuid);
|
||||
|
||||
info = info_from_pvid(pvid);
|
||||
count = info ? list_size(&info->mdas) : 0;
|
||||
|
||||
return _uint32_disp(rh, mem, field, &count, private);
|
||||
}
|
||||
|
||||
static int _vgmdas_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private)
|
||||
{
|
||||
const struct volume_group *vg = (const struct volume_group *) data;
|
||||
uint32_t count;
|
||||
|
||||
count = list_size(&vg->fid->metadata_areas);
|
||||
|
||||
return _uint32_disp(rh, mem, field, &count, private);
|
||||
}
|
||||
|
||||
static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private)
|
||||
@@ -880,8 +906,8 @@ static struct dm_report_field_type _fields[] = {
|
||||
#undef FIELD
|
||||
|
||||
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
report_type_t *report_type, const char *separator,
|
||||
int aligned, int buffered, int headings)
|
||||
report_type_t *report_type, const char *separator,
|
||||
int aligned, int buffered, int headings)
|
||||
{
|
||||
uint32_t report_flags = 0;
|
||||
|
||||
@@ -894,7 +920,7 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
if (headings)
|
||||
report_flags |= DM_REPORT_OUTPUT_HEADINGS;
|
||||
|
||||
return dm_report_init(report_type, _report_types, _fields, format,
|
||||
return dm_report_init(report_type, _report_types, _fields, format,
|
||||
separator, report_flags, keys, cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ static int _snap_target_percent(void **target_state __attribute((unused)),
|
||||
float percent2;
|
||||
uint64_t numerator, denominator;
|
||||
|
||||
if (index(params, '/')) {
|
||||
if (strchr(params, '/')) {
|
||||
if (sscanf(params, "%" PRIu64 "/%" PRIu64,
|
||||
&numerator, &denominator) == 2) {
|
||||
*total_numerator += numerator;
|
||||
|
||||
@@ -592,9 +592,9 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
||||
struct stat buf;
|
||||
char path[PATH_MAX];
|
||||
|
||||
log_print("Warning: Device list may be incomplete with interface "
|
||||
log_warn("WARNING: Device list may be incomplete with interface "
|
||||
"version 1.");
|
||||
log_print("Please upgrade your kernel device-mapper driver.");
|
||||
log_warn("Please upgrade your kernel device-mapper driver.");
|
||||
|
||||
if (!(d = opendir(dev_dir))) {
|
||||
log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
|
||||
@@ -693,7 +693,7 @@ static int _dm_task_run_v1(struct dm_task *dmt)
|
||||
|
||||
if (dmi->flags & DM_BUFFER_FULL_FLAG)
|
||||
/* FIXME Increase buffer size and retry operation (if query) */
|
||||
log_error("Warning: libdevmapper buffer too small for data");
|
||||
log_error("WARNING: libdevmapper buffer too small for data");
|
||||
|
||||
switch (dmt->type) {
|
||||
case DM_DEVICE_CREATE:
|
||||
@@ -1650,7 +1650,7 @@ repeat_ioctl:
|
||||
dm_free(dmi);
|
||||
goto repeat_ioctl;
|
||||
default:
|
||||
log_error("Warning: libdevmapper buffer too small for data");
|
||||
log_error("WARNING: libdevmapper buffer too small for data");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ static void _default_log(int level, const char *file __attribute((unused)),
|
||||
int line __attribute((unused)), const char *f, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int use_stderr = level & _LOG_STDERR;
|
||||
|
||||
level &= ~_LOG_STDERR;
|
||||
|
||||
if (level > _LOG_WARN && !_verbose)
|
||||
return;
|
||||
@@ -51,14 +54,14 @@ static void _default_log(int level, const char *file __attribute((unused)),
|
||||
if (level < _LOG_WARN)
|
||||
vfprintf(stderr, f, ap);
|
||||
else
|
||||
vprintf(f, ap);
|
||||
vfprintf(use_stderr ? stderr : stdout, f, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if (level < _LOG_WARN)
|
||||
fprintf(stderr, "\n");
|
||||
else
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(use_stderr ? stderr : stdout, "\n");
|
||||
}
|
||||
|
||||
dm_log_fn dm_log = _default_log;
|
||||
|
||||
@@ -10,6 +10,7 @@ lvchange \- change attributes of a logical volume
|
||||
[\-\-resync]
|
||||
[\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure]
|
||||
[\-\-ignoremonitoring]
|
||||
[\-\-monitor {y|n}]
|
||||
[\-M/\-\-persistent y/n] [\-\-minor minor]
|
||||
[\-P/\-\-partial]
|
||||
@@ -60,6 +61,11 @@ the failure is handled according to
|
||||
\fBmirror_image_fault_policy\fP and \fBmirror_log_fault_policy\fP
|
||||
set in \fBlvm.conf\fP.
|
||||
.TP
|
||||
.I \-\-ignoremonitoring
|
||||
Make no attempt to interact with dmeventd unless \-\-monitor
|
||||
is specified.
|
||||
Do not use this if dmeventd is already monitoring a device.
|
||||
.TP
|
||||
.I \-M, \-\-persistent y/n
|
||||
Set to y to make the minor number specified persistent.
|
||||
.TP
|
||||
|
||||
@@ -14,10 +14,10 @@ vgcfgrestore \- restore volume group descriptor area
|
||||
.SH DESCRIPTION
|
||||
.B vgcfgrestore
|
||||
allows you to restore the metadata of \fIVolumeGroupName\fP from a text
|
||||
backup file produced by \fBvgcfgbackup\fP. You can specify a backup file to
|
||||
use with the \fP-f\fP option. If no backup file is specified, the latest
|
||||
backup file is used. A list of backup and archive files of
|
||||
\fIVolumeGroupName\fP may be listed with the \fB-l\fP option.
|
||||
backup file produced by \fBvgcfgbackup\fP. You can specify a backup file
|
||||
with \fP--file\fP. If no backup file is specified, the most recent
|
||||
one is used. Use \fB--list\fP for a list of the available
|
||||
backup and archive files of \fIVolumeGroupName\fP.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB-l | --list\fP \(em List files pertaining to \fIVolumeGroupName\fP
|
||||
|
||||
@@ -16,6 +16,7 @@ vgchange \- change attributes of a volume group
|
||||
.IR Tag ]
|
||||
.RB [ \-h | \-\-help]
|
||||
.RB [ \-\-ignorelockingfailure]
|
||||
.RB [ \-\-ignoremonitoring]
|
||||
.RB [ \-l | \-\-logicalvolume
|
||||
.IR MaxLogicalVolumes ]
|
||||
.RB [ -p | \-\-maxphysicalvolumes
|
||||
@@ -80,6 +81,12 @@ and
|
||||
set in
|
||||
.BR lvm.conf (5).
|
||||
.TP
|
||||
.BR \-\-ignoremonitoring
|
||||
Make no attempt to interact with dmeventd unless
|
||||
.BR \-\-monitor
|
||||
is specified.
|
||||
Do not use this if dmeventd is already monitoring a device.
|
||||
.TP
|
||||
.BR \-l ", " \-\-logicalvolume " " \fIMaxLogicalVolumes\fR
|
||||
Changes the maximum logical volume number of an existing inactive
|
||||
volume group.
|
||||
|
||||
@@ -25,7 +25,22 @@ volume group "vg02" to "my_volume_group".
|
||||
.TP
|
||||
"vgrename vg02 my_volume_group" does the same.
|
||||
.TP
|
||||
"vgrename Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 VolGroup00_tmp" renames a volume group with UUID Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 to the volume group named "VolGroup00_tmp". Using the UUID option to name a volume group may be useful in cases where one machine has two physical volumes, each with the same volume group name, but a separate volume group UUID (this situation will cause error messages with lvm commands). One way duplicate volume group names occur is if an old disk with a root volume is moved to a new machine with its own root volume. In this case, both volume groups may have the same name (for example, "VolGroup00"), but different UUIDs.
|
||||
"vgrename Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 VolGroup00_tmp"
|
||||
changes the name of the Volume Group with UUID
|
||||
Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 to
|
||||
"VolGroup00_tmp".
|
||||
|
||||
All the Volume Groups visible to a system need to have different
|
||||
names. Otherwise many LVM2 commands will refuse to run or give
|
||||
warning messages.
|
||||
|
||||
This situation could arise when disks are moved between machines. If
|
||||
a disk is connected and it contains a Volume Group with the same name
|
||||
as the Volume Group containing your root filesystem the machine might
|
||||
not even boot correctly. However, the two Volume Groups should have
|
||||
different UUIDs (unless the disk was cloned) so you can rename
|
||||
one of the conflicting Volume Groups with
|
||||
\fBvgrename\fP.
|
||||
.TP
|
||||
.SH SEE ALSO
|
||||
.BR lvm (8),
|
||||
|
||||
@@ -31,7 +31,7 @@ start()
|
||||
{
|
||||
ret=0
|
||||
# TODO do we want to separate out already active groups only?
|
||||
VGS=`vgs --noheadings -o name`
|
||||
VGS=`vgs --noheadings -o name 2> /dev/null`
|
||||
for vg in $VGS
|
||||
do
|
||||
action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg || ret=$?
|
||||
@@ -49,7 +49,7 @@ stop()
|
||||
echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
|
||||
return 1
|
||||
fi
|
||||
VGS=`vgs --noheadings -o name`
|
||||
VGS=`vgs --noheadings -o name 2> /dev/null`
|
||||
for vg in $VGS
|
||||
do
|
||||
action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n $vg || ret=$?
|
||||
|
||||
@@ -18,6 +18,7 @@ DD=dd
|
||||
CUT=cut
|
||||
DATE=date
|
||||
BASENAME=basename
|
||||
UNAME=uname
|
||||
|
||||
# user may override lvm and dmsetup location by setting LVM_BINARY
|
||||
# and DMSETUP_BINARY respectively
|
||||
@@ -131,6 +132,10 @@ echo "LVM VERSION:" > $dir/versions
|
||||
$LVM lvs --version >> $dir/versions 2>> $log
|
||||
echo "DEVICE MAPPER VERSION:" >> $dir/versions
|
||||
$DMSETUP --version >> $dir/versions 2>> $log
|
||||
echo "KERNEL VERSION:" >> $dir/versions
|
||||
$UNAME -a >> $dir/versions 2>> $log
|
||||
echo "DM TARGETS VERSIONS:" >> $dir/versions
|
||||
$DMSETUP targets >> $dir/versions 2>> $log
|
||||
|
||||
myecho "Gathering dmsetup info..."
|
||||
log "$DMSETUP info -c > $dir/dmsetup_info 2>> $log"
|
||||
|
||||
@@ -51,6 +51,7 @@ arg(corelog_ARG, '\0', "corelog", NULL)
|
||||
arg(monitor_ARG, '\0', "monitor", yes_no_arg)
|
||||
arg(config_ARG, '\0', "config", string_arg)
|
||||
arg(trustcache_ARG, '\0', "trustcache", NULL)
|
||||
arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL)
|
||||
|
||||
/* Allow some variations */
|
||||
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
|
||||
|
||||
@@ -66,6 +66,7 @@ xx(lvchange,
|
||||
"\t[-f|--force]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--ignoremonitoring]\n"
|
||||
"\t[--monitor {y|n}]\n"
|
||||
"\t[-M|--persistent y|n] [--major major] [--minor minor]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
@@ -80,9 +81,9 @@ xx(lvchange,
|
||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||
|
||||
alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
|
||||
ignorelockingfailure_ARG, major_ARG, minor_ARG, monitor_ARG,
|
||||
partial_ARG, permission_ARG, persistent_ARG, readahead_ARG, resync_ARG,
|
||||
refresh_ARG, addtag_ARG, deltag_ARG, test_ARG, yes_ARG)
|
||||
ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG,
|
||||
monitor_ARG, partial_ARG, permission_ARG, persistent_ARG, readahead_ARG,
|
||||
resync_ARG, refresh_ARG, addtag_ARG, deltag_ARG, test_ARG, yes_ARG)
|
||||
|
||||
xx(lvconvert,
|
||||
"Change logical volume layout",
|
||||
@@ -617,6 +618,7 @@ xx(vgchange,
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--ignoremonitoring]\n"
|
||||
"\t[--monitor {y|n}]\n"
|
||||
"\t[-t|--test]" "\n"
|
||||
"\t[-u|--uuid] " "\n"
|
||||
@@ -633,9 +635,9 @@ xx(vgchange,
|
||||
"\t[VolumeGroupName...]\n",
|
||||
|
||||
addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG,
|
||||
clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, logicalvolume_ARG,
|
||||
maxphysicalvolumes_ARG, monitor_ARG, partial_ARG, physicalextentsize_ARG,
|
||||
resizeable_ARG, resizable_ARG, test_ARG, uuid_ARG)
|
||||
clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG,
|
||||
logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, partial_ARG,
|
||||
physicalextentsize_ARG, resizeable_ARG, resizable_ARG, test_ARG, uuid_ARG)
|
||||
|
||||
xx(vgck,
|
||||
"Check the consistency of volume group(s)",
|
||||
|
||||
@@ -1629,7 +1629,7 @@ static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
goto out_abandon;
|
||||
}
|
||||
|
||||
if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
|
||||
if (!dm_pool_grow_object(mem, buf, strlen(buf) + 1)) {
|
||||
log_error("dm_pool_grow_object failed");
|
||||
goto out_abandon;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG,
|
||||
cmd->is_static ?
|
||||
(cmd->is_static || arg_count(cmd, ignoremonitoring_ARG)) ?
|
||||
DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR));
|
||||
|
||||
/* access permission change */
|
||||
|
||||
@@ -447,7 +447,7 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (!lp->zero || !(lv->status & LVM_WRITE))
|
||||
log_print("WARNING: \"%s\" not zeroed", lv->name);
|
||||
log_warn("WARNING: \"%s\" not zeroed", lv->name);
|
||||
else if (!set_lv(cmd, lv, 0, 0)) {
|
||||
log_error("Aborting. Failed to wipe snapshot "
|
||||
"exception store.");
|
||||
|
||||
@@ -587,7 +587,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
return 0;
|
||||
}
|
||||
/* FIXME Allow exclusive activation. */
|
||||
if (vg->status & CLUSTERED) {
|
||||
if (vg_status(vg) & CLUSTERED) {
|
||||
log_error("Clustered snapshots are not yet supported.");
|
||||
return 0;
|
||||
}
|
||||
@@ -693,7 +693,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
init_mirror_in_sync(lp->nosync);
|
||||
|
||||
if (lp->nosync) {
|
||||
log_print("WARNING: New mirror won't be synchronised. "
|
||||
log_warn("WARNING: New mirror won't be synchronised. "
|
||||
"Don't read what you didn't write!");
|
||||
status |= MIRROR_NOTSYNCED;
|
||||
}
|
||||
|
||||
@@ -19,3 +19,8 @@ void *lvm2_init(void)
|
||||
{
|
||||
return cmdlib_lvm2_init(0);
|
||||
}
|
||||
|
||||
int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
init_trust_cache(1);
|
||||
log_print("WARNING: Cache file of PVs will be trusted. "
|
||||
log_warn("WARNING: Cache file of PVs will be trusted. "
|
||||
"New devices holding PVs may get ignored.");
|
||||
} else
|
||||
init_trust_cache(0);
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
int disks_found = 0;
|
||||
int parts_found = 0;
|
||||
int pv_disks_found = 0;
|
||||
int pv_parts_found = 0;
|
||||
int disks_found;
|
||||
int parts_found;
|
||||
int pv_disks_found;
|
||||
int pv_parts_found;
|
||||
int max_len;
|
||||
|
||||
static int _get_max_dev_name_len(struct dev_filter *filter)
|
||||
@@ -99,8 +99,14 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute((unused)),
|
||||
struct device *dev;
|
||||
struct label *label;
|
||||
|
||||
/* initialise these here to avoid problems with the lvm shell */
|
||||
disks_found = 0;
|
||||
parts_found = 0;
|
||||
pv_disks_found = 0;
|
||||
pv_parts_found = 0;
|
||||
|
||||
if (arg_count(cmd, lvmpartition_ARG))
|
||||
log_print("WARNING: only considering LVM devices");
|
||||
log_warn("WARNING: only considering LVM devices");
|
||||
|
||||
max_len = _get_max_dev_name_len(cmd->filter);
|
||||
|
||||
|
||||
@@ -24,10 +24,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
vg = lv->vg;
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg->name);
|
||||
if (!vg_check_status(vg, LVM_WRITE))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_is_origin(lv)) {
|
||||
log_error("Can't remove logical volume \"%s\" under snapshot",
|
||||
@@ -77,7 +75,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
/* If the VG is clustered then make sure no-one else is using the LV
|
||||
we are about to remove */
|
||||
if (vg->status & CLUSTERED) {
|
||||
if (vg_status(vg) & CLUSTERED) {
|
||||
if (!activate_lv_excl(cmd, lv)) {
|
||||
log_error("Can't get exclusive access to volume \"%s\"",
|
||||
lv->name);
|
||||
|
||||
@@ -155,14 +155,14 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
if (vg->fid->fmt->features & FMT_SEGMENTS)
|
||||
lp->stripes = arg_uint_value(cmd, stripes_ARG, 1);
|
||||
else
|
||||
log_print("Varied striping not supported. Ignoring.");
|
||||
log_warn("Varied striping not supported. Ignoring.");
|
||||
}
|
||||
|
||||
if (arg_count(cmd, mirrors_ARG)) {
|
||||
if (vg->fid->fmt->features & FMT_SEGMENTS)
|
||||
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 1) + 1;
|
||||
else
|
||||
log_print("Mirrors not supported. Ignoring.");
|
||||
log_warn("Mirrors not supported. Ignoring.");
|
||||
if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Mirrors argument may not be negative");
|
||||
return 0;
|
||||
@@ -182,7 +182,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
}
|
||||
|
||||
if (!(vg->fid->fmt->features & FMT_SEGMENTS))
|
||||
log_print("Varied stripesize not supported. Ignoring.");
|
||||
log_warn("Varied stripesize not supported. Ignoring.");
|
||||
else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size) {
|
||||
log_error("Reducing stripe size %s to maximum, "
|
||||
"physical extent size %s",
|
||||
@@ -447,7 +447,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
|
||||
if (lp->resize == LV_REDUCE) {
|
||||
if (lp->argc)
|
||||
log_print("Ignoring PVs on command line when reducing");
|
||||
log_warn("Ignoring PVs on command line when reducing");
|
||||
} else if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc,
|
||||
lp->argv, 1) : &vg->pvs)) {
|
||||
stack;
|
||||
@@ -469,13 +469,13 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
||||
}
|
||||
|
||||
if (info.exists && !lp->resizefs && (lp->resize == LV_REDUCE)) {
|
||||
log_print("WARNING: Reducing active%s logical volume "
|
||||
log_warn("WARNING: Reducing active%s logical volume "
|
||||
"to %s", info.open_count ? " and open" : "",
|
||||
display_size(cmd, (uint64_t) lp->extents *
|
||||
vg->extent_size));
|
||||
|
||||
log_print("THIS MAY DESTROY YOUR DATA "
|
||||
"(filesystem etc.)");
|
||||
log_warn("THIS MAY DESTROY YOUR DATA "
|
||||
"(filesystem etc.)");
|
||||
|
||||
if (!arg_count(cmd, force_ARG)) {
|
||||
if (yes_no_prompt("Do you really want to "
|
||||
|
||||
@@ -191,10 +191,8 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
lv_mirr = lvl->lv;
|
||||
|
||||
@@ -26,7 +26,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
uint64_t sector;
|
||||
uint32_t orig_pe_alloc_count;
|
||||
|
||||
const char *pv_name = dev_name(get_pv_dev(pv));
|
||||
const char *pv_name = dev_name(pv_dev(pv));
|
||||
const char *tag = NULL;
|
||||
const char *orig_vg_name;
|
||||
char uuid[64] __attribute((aligned(8)));
|
||||
@@ -51,17 +51,17 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
|
||||
/* If in a VG, must change using volume group. */
|
||||
if (*get_pv_vg_name(pv)) {
|
||||
if (*pv_vg_name(pv)) {
|
||||
log_verbose("Finding volume group of physical volume \"%s\"",
|
||||
pv_name);
|
||||
|
||||
if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for %s", get_pv_vg_name(pv));
|
||||
if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for %s", pv_vg_name(pv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(vg = vg_read(cmd, get_pv_vg_name(pv), NULL, &consistent))) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
if (!(vg = vg_read(cmd, pv_vg_name(pv), NULL, &consistent))) {
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
log_error("Unable to find volume group of \"%s\"",
|
||||
pv_name);
|
||||
return 0;
|
||||
@@ -69,25 +69,25 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
|
||||
if (!vg_check_status(vg,
|
||||
CLUSTERED | EXPORTED_VG | LVM_WRITE)) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
log_error
|
||||
("Unable to find \"%s\" in volume group \"%s\"",
|
||||
pv_name, vg->name);
|
||||
return 0;
|
||||
}
|
||||
if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
log_error("Volume group containing %s does not "
|
||||
"support tags", pv_name);
|
||||
return 0;
|
||||
}
|
||||
if (arg_count(cmd, uuid_ARG) && lvs_in_vg_activated(vg)) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
log_error("Volume group containing %s has active "
|
||||
"logical volumes", pv_name);
|
||||
return 0;
|
||||
@@ -115,7 +115,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
|
||||
if (arg_count(cmd, allocatable_ARG)) {
|
||||
if (!*get_pv_vg_name(pv) &&
|
||||
if (!*pv_vg_name(pv) &&
|
||||
!(pv->fmt->features & FMT_ORPHAN_ALLOCATABLE)) {
|
||||
log_error("Allocatability not supported by orphan "
|
||||
"%s format PV %s", pv->fmt->name, pv_name);
|
||||
@@ -124,21 +124,21 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
|
||||
/* change allocatability for a PV */
|
||||
if (allocatable && (get_pv_status(pv) & ALLOCATABLE_PV)) {
|
||||
if (allocatable && (pv_status(pv) & ALLOCATABLE_PV)) {
|
||||
log_error("Physical volume \"%s\" is already "
|
||||
"allocatable", pv_name);
|
||||
if (*get_pv_vg_name(pv))
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
if (*pv_vg_name(pv))
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
else
|
||||
unlock_vg(cmd, ORPHAN);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!allocatable && !(get_pv_status(pv) & ALLOCATABLE_PV)) {
|
||||
if (!allocatable && !(pv_status(pv) & ALLOCATABLE_PV)) {
|
||||
log_error("Physical volume \"%s\" is already "
|
||||
"unallocatable", pv_name);
|
||||
if (*get_pv_vg_name(pv))
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
if (*pv_vg_name(pv))
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
else
|
||||
unlock_vg(cmd, ORPHAN);
|
||||
return 1;
|
||||
@@ -180,9 +180,9 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
return 0;
|
||||
}
|
||||
log_verbose("Changing uuid of %s to %s.", pv_name, uuid);
|
||||
if (*get_pv_vg_name(pv)) {
|
||||
orig_vg_name = get_pv_vg_name(pv);
|
||||
orig_pe_alloc_count = get_pv_pe_alloc_count(pv);
|
||||
if (*pv_vg_name(pv)) {
|
||||
orig_vg_name = pv_vg_name(pv);
|
||||
orig_pe_alloc_count = pv_pe_alloc_count(pv);
|
||||
pv->vg_name = ORPHAN;
|
||||
pv->pe_alloc_count = 0;
|
||||
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
|
||||
@@ -196,15 +196,15 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
|
||||
log_verbose("Updating physical volume \"%s\"", pv_name);
|
||||
if (*get_pv_vg_name(pv)) {
|
||||
if (*pv_vg_name(pv)) {
|
||||
if (!vg_write(vg) || !vg_commit(vg)) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
log_error("Failed to store physical volume \"%s\" in "
|
||||
"volume group \"%s\"", pv_name, vg->name);
|
||||
return 0;
|
||||
}
|
||||
backup(vg);
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
} else {
|
||||
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
|
||||
unlock_vg(cmd, ORPHAN);
|
||||
|
||||
@@ -47,13 +47,13 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
/* We must have -ff to overwrite a non orphan */
|
||||
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) {
|
||||
log_error("Can't initialize physical volume \"%s\" of "
|
||||
"volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
|
||||
"volume group \"%s\" without -ff", name, pv_vg_name(pv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* prompt */
|
||||
if (pv && !is_orphan(pv) && !arg_count(cmd, yes_ARG) &&
|
||||
yes_no_prompt(_really_init, name, get_pv_vg_name(pv)) == 'n') {
|
||||
yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') {
|
||||
log_print("%s: physical volume not initialized", name);
|
||||
return 0;
|
||||
}
|
||||
@@ -110,10 +110,10 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
return 0;
|
||||
|
||||
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG)) {
|
||||
log_print("WARNING: Forcing physical volume creation on "
|
||||
log_warn("WARNING: Forcing physical volume creation on "
|
||||
"%s%s%s%s", name,
|
||||
!is_orphan(pv) ? " of volume group \"" : "",
|
||||
!is_orphan(pv) ? get_pv_vg_name(pv) : "",
|
||||
!is_orphan(pv) ? pv_vg_name(pv) : "",
|
||||
!is_orphan(pv) ? "\"" : "");
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
uuid, restorefile);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
pe_start = get_pv_pe_start(existing_pv);
|
||||
extent_size = get_pv_pe_size(existing_pv);
|
||||
extent_count = get_pv_pe_count(existing_pv);
|
||||
pe_start = pv_pe_start(existing_pv);
|
||||
extent_size = pv_pe_size(existing_pv);
|
||||
extent_count = pv_pe_count(existing_pv);
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, ORPHAN, LCK_VG_WRITE)) {
|
||||
@@ -220,10 +220,10 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
}
|
||||
|
||||
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
||||
" available sectors", pv_name, get_pv_size(pv));
|
||||
" available sectors", pv_name, pv_size(pv));
|
||||
|
||||
/* Wipe existing label first */
|
||||
if (!label_remove(get_pv_dev(pv))) {
|
||||
if (!label_remove(pv_dev(pv))) {
|
||||
log_error("Failed to wipe existing label on %s", pv_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -24,16 +24,16 @@ static int _pvdisplay_single(struct cmd_context *cmd,
|
||||
int ret = ECMD_PROCESSED;
|
||||
uint64_t size;
|
||||
|
||||
const char *pv_name = dev_name(get_pv_dev(pv));
|
||||
const char *pv_name = dev_name(pv_dev(pv));
|
||||
|
||||
if (get_pv_vg_name(pv)) {
|
||||
if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
|
||||
if (pv_vg_name(pv)) {
|
||||
if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg = vg_read(cmd, get_pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
|
||||
log_error("Can't read %s: skipping", get_pv_vg_name(pv));
|
||||
if (!(vg = vg_read(cmd, pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
|
||||
log_error("Can't read %s: skipping", pv_vg_name(pv));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ static int _pvdisplay_single(struct cmd_context *cmd,
|
||||
pv = pvl->pv;
|
||||
}
|
||||
|
||||
if (!*get_pv_vg_name(pv))
|
||||
size = get_pv_size(pv);
|
||||
if (!*pv_vg_name(pv))
|
||||
size = pv_size(pv);
|
||||
else
|
||||
size = (get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv)) *
|
||||
get_pv_pe_size(pv);
|
||||
size = (pv_pe_count(pv) - pv_pe_alloc_count(pv)) *
|
||||
pv_pe_size(pv);
|
||||
|
||||
if (arg_count(cmd, short_ARG)) {
|
||||
log_print("Device \"%s\" has a capacity of %s", pv_name,
|
||||
@@ -68,11 +68,11 @@ static int _pvdisplay_single(struct cmd_context *cmd,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (get_pv_status(pv) & EXPORTED_VG)
|
||||
if (pv_status(pv) & EXPORTED_VG)
|
||||
log_print("Physical volume \"%s\" of volume group \"%s\" "
|
||||
"is exported", pv_name, get_pv_vg_name(pv));
|
||||
"is exported", pv_name, pv_vg_name(pv));
|
||||
|
||||
if (!get_pv_vg_name(pv))
|
||||
if (!pv_vg_name(pv))
|
||||
log_print("\"%s\" is a new physical volume of \"%s\"",
|
||||
pv_name, display_size(cmd, size));
|
||||
|
||||
@@ -87,8 +87,8 @@ static int _pvdisplay_single(struct cmd_context *cmd,
|
||||
pvdisplay_segments(pv);
|
||||
|
||||
out:
|
||||
if (get_pv_vg_name(pv))
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
if (pv_vg_name(pv))
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc,
|
||||
pvl = list_item(pvh, struct pv_list);
|
||||
|
||||
/* Don't allocate onto the PV we're clearing! */
|
||||
if ((alloc != ALLOC_ANYWHERE) && (pvl->pv->dev == get_pv_dev(pv))) {
|
||||
if ((alloc != ALLOC_ANYWHERE) && (pvl->pv->dev == pv_dev(pv))) {
|
||||
list_del(&pvl->list);
|
||||
continue;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
}
|
||||
|
||||
if (arg_count(cmd, name_ARG)) {
|
||||
if (!(lv_name = _extract_lvname(cmd, get_pv_vg_name(pv),
|
||||
if (!(lv_name = _extract_lvname(cmd, pv_vg_name(pv),
|
||||
arg_value(cmd, name_ARG)))) {
|
||||
stack;
|
||||
return EINVALID_CMD_LINE;
|
||||
@@ -289,14 +289,14 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
}
|
||||
|
||||
/* Read VG */
|
||||
log_verbose("Finding volume group \"%s\"", get_pv_vg_name(pv));
|
||||
log_verbose("Finding volume group \"%s\"", pv_vg_name(pv));
|
||||
|
||||
if (!(vg = _get_vg(cmd, get_pv_vg_name(pv)))) {
|
||||
if (!(vg = _get_vg(cmd, pv_vg_name(pv)))) {
|
||||
stack;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if ((lv_mirr = find_pvmove_lv(vg, get_pv_dev(pv), PVMOVE))) {
|
||||
if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
|
||||
log_print("Detected pvmove in progress for %s", pv_name);
|
||||
if (argc || lv_name)
|
||||
log_error("Ignoring remaining command line arguments");
|
||||
@@ -304,7 +304,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
|
||||
log_error
|
||||
("ABORTING: Failed to generate list of moving LVs");
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!activate_lv_excl(cmd, lv_mirr)) {
|
||||
log_error
|
||||
("ABORTING: Temporary mirror activation failed.");
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!(source_pvl = create_pv_list(cmd->mem, vg, 1,
|
||||
&pv_name_arg, 0))) {
|
||||
stack;
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@@ -334,12 +334,12 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv,
|
||||
vg, pv, alloc))) {
|
||||
stack;
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!archive(vg)) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
stack;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
allocatable_pvs, alloc,
|
||||
&lvs_changed))) {
|
||||
stack;
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
/* Lock lvs_changed for exclusive use and activate (with old metadata) */
|
||||
if (!activate_lvs_excl(cmd, lvs_changed)) {
|
||||
stack;
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@@ -368,13 +368,13 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!_update_metadata
|
||||
(cmd, vg, lv_mirr, lvs_changed, first_time)) {
|
||||
stack;
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
/* LVs are all in status LOCKED */
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ static struct volume_group *_get_move_vg(struct cmd_context *cmd,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _get_vg(cmd, get_pv_vg_name(pv));
|
||||
return _get_vg(cmd, pv_vg_name(pv));
|
||||
}
|
||||
|
||||
static struct poll_functions _pvmove_fns = {
|
||||
|
||||
@@ -50,22 +50,22 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
|
||||
/* we must have -ff to overwrite a non orphan */
|
||||
if (arg_count(cmd, force_ARG) < 2) {
|
||||
log_error("Can't pvremove physical volume \"%s\" of "
|
||||
"volume group \"%s\" without -ff", name, get_pv_vg_name(pv));
|
||||
"volume group \"%s\" without -ff", name, pv_vg_name(pv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* prompt */
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
yes_no_prompt(_really_wipe, name, get_pv_vg_name(pv)) == 'n') {
|
||||
yes_no_prompt(_really_wipe, name, pv_vg_name(pv)) == 'n') {
|
||||
log_print("%s: physical volume label not removed", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, force_ARG)) {
|
||||
log_print("WARNING: Wiping physical volume label from "
|
||||
log_warn("WARNING: Wiping physical volume label from "
|
||||
"%s%s%s%s", name,
|
||||
!is_orphan(pv) ? " of volume group \"" : "",
|
||||
!is_orphan(pv) ? get_pv_vg_name(pv) : "",
|
||||
!is_orphan(pv) ? pv_vg_name(pv) : "",
|
||||
!is_orphan(pv) ? "\"" : "");
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
uint64_t size = 0;
|
||||
uint32_t new_pe_count = 0;
|
||||
struct list mdas;
|
||||
const char *pv_name = dev_name(get_pv_dev(pv));
|
||||
const char *pv_name = dev_name(pv_dev(pv));
|
||||
struct pvresize_params *params = (struct pvresize_params *) handle;
|
||||
const char *vg_name;
|
||||
|
||||
@@ -41,7 +41,7 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
|
||||
params->total++;
|
||||
|
||||
if (!*get_pv_vg_name(pv)) {
|
||||
if (!*pv_vg_name(pv)) {
|
||||
vg_name = ORPHAN;
|
||||
|
||||
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
||||
@@ -63,10 +63,10 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
} else {
|
||||
vg_name = get_pv_vg_name(pv);
|
||||
vg_name = pv_vg_name(pv);
|
||||
|
||||
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for %s", get_pv_vg_name(pv));
|
||||
log_error("Can't get lock for %s", pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
/* Get new size */
|
||||
if (!dev_get_size(get_pv_dev(pv), &size)) {
|
||||
if (!dev_get_size(pv_dev(pv), &size)) {
|
||||
log_error("%s: Couldn't get size.", pv_name);
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
@@ -111,10 +111,10 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
|
||||
if (params->new_size) {
|
||||
if (params->new_size > size)
|
||||
log_print("WARNING: %s: Overriding real size. "
|
||||
log_warn("WARNING: %s: Overriding real size. "
|
||||
"You could lose data.", pv_name);
|
||||
log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
|
||||
" sectors.", pv_name, params->new_size, get_pv_size(pv));
|
||||
" sectors.", pv_name, params->new_size, pv_size(pv));
|
||||
size = params->new_size;
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (size < get_pv_pe_start(pv)) {
|
||||
if (size < pv_pe_start(pv)) {
|
||||
log_error("%s: Size must exceed physical extent start of "
|
||||
"%" PRIu64 " sectors.", pv_name, get_pv_pe_start(pv));
|
||||
"%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
@@ -135,14 +135,14 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
pv->size = size;
|
||||
|
||||
if (vg) {
|
||||
pv->size -= get_pv_pe_start(pv);
|
||||
new_pe_count = get_pv_size(pv) / vg->extent_size;
|
||||
pv->size -= pv_pe_start(pv);
|
||||
new_pe_count = pv_size(pv) / vg->extent_size;
|
||||
|
||||
if (!new_pe_count) {
|
||||
log_error("%s: Size must leave space for at "
|
||||
"least one physical extent of "
|
||||
"%" PRIu32 " sectors.", pv_name,
|
||||
get_pv_pe_size(pv));
|
||||
pv_pe_size(pv));
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
@@ -155,12 +155,12 @@ static int _pvresize_single(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
|
||||
pv_name, get_pv_size(pv));
|
||||
pv_name, pv_size(pv));
|
||||
|
||||
log_verbose("Updating physical volume \"%s\"", pv_name);
|
||||
if (*get_pv_vg_name(pv)) {
|
||||
if (*pv_vg_name(pv)) {
|
||||
if (!vg_write(vg) || !vg_commit(vg)) {
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
log_error("Failed to store physical volume \"%s\" in "
|
||||
"volume group \"%s\"", pv_name, vg->name);
|
||||
return ECMD_FAILED;
|
||||
|
||||
@@ -31,7 +31,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
|
||||
|
||||
/* short listing? */
|
||||
if (arg_count(cmd, short_ARG) > 0) {
|
||||
log_print("%s", dev_name(get_pv_dev(pv)));
|
||||
log_print("%s", dev_name(pv_dev(pv)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
|
||||
|
||||
memset(pv_tmp_name, 0, sizeof(pv_tmp_name));
|
||||
|
||||
vg_name_len = strlen(get_pv_vg_name(pv)) + 1;
|
||||
vg_name_len = strlen(pv_vg_name(pv)) + 1;
|
||||
|
||||
if (arg_count(cmd, uuid_ARG)) {
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
@@ -57,43 +57,43 @@ static void _pvscan_display_single(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
sprintf(pv_tmp_name, "%-*s with UUID %s",
|
||||
pv_max_name_len - 2, dev_name(get_pv_dev(pv)), uuid);
|
||||
pv_max_name_len - 2, dev_name(pv_dev(pv)), uuid);
|
||||
} else {
|
||||
sprintf(pv_tmp_name, "%s", dev_name(get_pv_dev(pv)));
|
||||
sprintf(pv_tmp_name, "%s", dev_name(pv_dev(pv)));
|
||||
}
|
||||
|
||||
if (!*get_pv_vg_name(pv)) {
|
||||
if (!*pv_vg_name(pv)) {
|
||||
log_print("PV %-*s %-*s %s [%s]",
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_max_name_len, " ",
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
display_size(cmd, get_pv_size(pv)));
|
||||
display_size(cmd, pv_size(pv)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_pv_status(pv) & EXPORTED_VG) {
|
||||
strncpy(vg_name_this, get_pv_vg_name(pv), vg_name_len);
|
||||
if (pv_status(pv) & EXPORTED_VG) {
|
||||
strncpy(vg_name_this, pv_vg_name(pv), vg_name_len);
|
||||
log_print("PV %-*s is in exported VG %s "
|
||||
"[%s / %s free]",
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_name_this,
|
||||
display_size(cmd, (uint64_t) get_pv_pe_count(pv) *
|
||||
get_pv_pe_size(pv)),
|
||||
display_size(cmd, (uint64_t) (get_pv_pe_count(pv) -
|
||||
get_pv_pe_alloc_count(pv))
|
||||
* get_pv_pe_size(pv)));
|
||||
display_size(cmd, (uint64_t) pv_pe_count(pv) *
|
||||
pv_pe_size(pv)),
|
||||
display_size(cmd, (uint64_t) (pv_pe_count(pv) -
|
||||
pv_pe_alloc_count(pv))
|
||||
* pv_pe_size(pv)));
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(vg_tmp_name, "%s", get_pv_vg_name(pv));
|
||||
sprintf(vg_tmp_name, "%s", pv_vg_name(pv));
|
||||
log_print("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
|
||||
pv_tmp_name, vg_max_name_len, vg_tmp_name,
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
display_size(cmd, (uint64_t) get_pv_pe_count(pv) *
|
||||
get_pv_pe_size(pv)),
|
||||
display_size(cmd, (uint64_t) (get_pv_pe_count(pv) -
|
||||
get_pv_pe_alloc_count(pv)) *
|
||||
get_pv_pe_size(pv)));
|
||||
display_size(cmd, (uint64_t) pv_pe_count(pv) *
|
||||
pv_pe_size(pv)),
|
||||
display_size(cmd, (uint64_t) (pv_pe_count(pv) -
|
||||
pv_pe_alloc_count(pv)) *
|
||||
pv_pe_size(pv)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
|
||||
}
|
||||
|
||||
if (arg_count(cmd, exported_ARG) || arg_count(cmd, novolumegroup_ARG))
|
||||
log_print("WARNING: only considering physical volumes %s",
|
||||
log_warn("WARNING: only considering physical volumes %s",
|
||||
arg_count(cmd, exported_ARG) ?
|
||||
"of exported volume group(s)" : "in no volume group");
|
||||
|
||||
@@ -136,8 +136,8 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
|
||||
pv = pvl->pv;
|
||||
|
||||
if ((arg_count(cmd, exported_ARG)
|
||||
&& !(get_pv_status(pv) & EXPORTED_VG))
|
||||
|| (arg_count(cmd, novolumegroup_ARG) && (*get_pv_vg_name(pv)))) {
|
||||
&& !(pv_status(pv) & EXPORTED_VG))
|
||||
|| (arg_count(cmd, novolumegroup_ARG) && (*pv_vg_name(pv)))) {
|
||||
list_del(&pvl->list);
|
||||
continue;
|
||||
}
|
||||
@@ -154,22 +154,22 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
|
||||
********/
|
||||
pvs_found++;
|
||||
|
||||
if (!*get_pv_vg_name(pv)) {
|
||||
if (!*pv_vg_name(pv)) {
|
||||
new_pvs_found++;
|
||||
size_new += get_pv_size(pv);
|
||||
size_total += get_pv_size(pv);
|
||||
size_new += pv_size(pv);
|
||||
size_total += pv_size(pv);
|
||||
} else
|
||||
size_total += get_pv_pe_count(pv) * get_pv_pe_size(pv);
|
||||
size_total += pv_pe_count(pv) * pv_pe_size(pv);
|
||||
}
|
||||
|
||||
/* find maximum pv name length */
|
||||
pv_max_name_len = vg_max_name_len = 0;
|
||||
list_iterate_items(pvl, pvslist) {
|
||||
pv = pvl->pv;
|
||||
len = strlen(dev_name(get_pv_dev(pv)));
|
||||
len = strlen(dev_name(pv_dev(pv)));
|
||||
if (pv_max_name_len < len)
|
||||
pv_max_name_len = len;
|
||||
len = strlen(get_pv_vg_name(pv));
|
||||
len = strlen(pv_vg_name(pv));
|
||||
if (vg_max_name_len < len)
|
||||
vg_max_name_len = len;
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv = pvseg->pv;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
|
||||
if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg = vg_read(cmd, get_pv_vg_name(pv), NULL, &consistent))) {
|
||||
log_error("Can't read %s: skipping", get_pv_vg_name(pv));
|
||||
if (!(vg = vg_read(cmd, pv_vg_name(pv), NULL, &consistent))) {
|
||||
log_error("Can't read %s: skipping", pv_vg_name(pv));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
ret = ECMD_FAILED;
|
||||
|
||||
out:
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -106,14 +106,14 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
int consistent = 0;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (get_pv_vg_name(pv)) {
|
||||
if (!lock_vol(cmd, get_pv_vg_name(pv), LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", get_pv_vg_name(pv));
|
||||
if (pv_vg_name(pv)) {
|
||||
if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", pv_vg_name(pv));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg = vg_read(cmd, get_pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
|
||||
log_error("Can't read %s: skipping", get_pv_vg_name(pv));
|
||||
if (!(vg = vg_read(cmd, pv_vg_name(pv), (char *)&pv->vgid, &consistent))) {
|
||||
log_error("Can't read %s: skipping", pv_vg_name(pv));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
ret = ECMD_FAILED;
|
||||
|
||||
out:
|
||||
if (get_pv_vg_name(pv))
|
||||
unlock_vg(cmd, get_pv_vg_name(pv));
|
||||
if (pv_vg_name(pv))
|
||||
unlock_vg(cmd, pv_vg_name(pv));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -159,10 +159,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
struct lv_list *lvl;
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (tags && !list_empty(tags))
|
||||
tags_supplied = 1;
|
||||
@@ -661,7 +659,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
if (sigint_caught())
|
||||
return ret_max;
|
||||
break;
|
||||
}
|
||||
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
@@ -61,7 +61,7 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
if (!consistent)
|
||||
log_error("Warning: Volume group \"%s\" inconsistent", vg_name);
|
||||
log_error("WARNING: Volume group \"%s\" inconsistent", vg_name);
|
||||
|
||||
if (arg_count(cmd, file_ARG)) {
|
||||
if (!(filename = _expand_filename(arg_value(cmd, file_ARG),
|
||||
|
||||
@@ -134,7 +134,7 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (activate && lockingfailed() && (vg->status & CLUSTERED)) {
|
||||
if (activate && lockingfailed() && (vg_status(vg) & CLUSTERED)) {
|
||||
log_error("Locking inactive: ignoring clustered "
|
||||
"volume group %s", vg->name);
|
||||
return ECMD_FAILED;
|
||||
@@ -207,13 +207,13 @@ static int _vgchange_resizeable(struct cmd_context *cmd,
|
||||
{
|
||||
int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
|
||||
|
||||
if (resizeable && (vg->status & RESIZEABLE_VG)) {
|
||||
if (resizeable && (vg_status(vg) & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" is already resizeable",
|
||||
vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!resizeable && !(vg->status & RESIZEABLE_VG)) {
|
||||
if (!resizeable && !(vg_status(vg) & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" is already not resizeable",
|
||||
vg->name);
|
||||
return ECMD_FAILED;
|
||||
@@ -243,13 +243,13 @@ static int _vgchange_clustered(struct cmd_context *cmd,
|
||||
int clustered = !strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y");
|
||||
struct lv_list *lvl;
|
||||
|
||||
if (clustered && (vg->status & CLUSTERED)) {
|
||||
if (clustered && (vg_status(vg) & CLUSTERED)) {
|
||||
log_error("Volume group \"%s\" is already clustered",
|
||||
vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!clustered && !(vg->status & CLUSTERED)) {
|
||||
if (!clustered && !(vg_status(vg) & CLUSTERED)) {
|
||||
log_error("Volume group \"%s\" is already not clustered",
|
||||
vg->name);
|
||||
return ECMD_FAILED;
|
||||
@@ -289,7 +289,7 @@ static int _vgchange_logicalvolume(struct cmd_context *cmd,
|
||||
{
|
||||
uint32_t max_lv = arg_uint_value(cmd, logicalvolume_ARG, 0);
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
if (!(vg_status(vg) & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" must be resizeable "
|
||||
"to change MaxLogicalVolume", vg->name);
|
||||
return ECMD_FAILED;
|
||||
@@ -331,7 +331,7 @@ static int _vgchange_physicalvolumes(struct cmd_context *cmd,
|
||||
{
|
||||
uint32_t max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
if (!(vg_status(vg) & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" must be resizeable "
|
||||
"to change MaxPhysicalVolumes", vg->name);
|
||||
return ECMD_FAILED;
|
||||
@@ -377,7 +377,7 @@ static int _vgchange_pesize(struct cmd_context *cmd, struct volume_group *vg)
|
||||
{
|
||||
uint32_t extent_size;
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
if (!(vg_status(vg) & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" must be resizeable "
|
||||
"to change PE size", vg->name);
|
||||
return ECMD_FAILED;
|
||||
@@ -525,18 +525,18 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE) && !arg_count(cmd, available_ARG)) {
|
||||
if (!(vg_status(vg) & LVM_WRITE) && !arg_count(cmd, available_ARG)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
if (vg_status(vg) & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG,
|
||||
cmd->is_static ?
|
||||
(cmd->is_static || arg_count(cmd, ignoremonitoring_ARG)) ?
|
||||
DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR));
|
||||
|
||||
if (arg_count(cmd, available_ARG))
|
||||
|
||||
@@ -30,10 +30,8 @@ static int vgck_single(struct cmd_context *cmd __attribute((unused)),
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg_name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
@@ -45,15 +45,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg->name);
|
||||
if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->fid->fmt == cmd->fmt) {
|
||||
log_error("Volume group \"%s\" already uses format %s",
|
||||
@@ -114,18 +107,18 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
existing_pv = pvl->pv;
|
||||
|
||||
pe_start = get_pv_pe_start(existing_pv);
|
||||
pe_end = get_pv_pe_count(existing_pv) * get_pv_pe_size(existing_pv)
|
||||
pe_start = pv_pe_start(existing_pv);
|
||||
pe_end = pv_pe_count(existing_pv) * pv_pe_size(existing_pv)
|
||||
+ pe_start - 1;
|
||||
|
||||
list_init(&mdas);
|
||||
if (!(pv = pv_create(cmd->fmt, get_pv_dev(existing_pv),
|
||||
if (!(pv = pv_create(cmd->fmt, pv_dev(existing_pv),
|
||||
&existing_pv->id, size,
|
||||
pe_start, get_pv_pe_count(existing_pv),
|
||||
get_pv_pe_size(existing_pv), pvmetadatacopies,
|
||||
pe_start, pv_pe_count(existing_pv),
|
||||
pv_pe_size(existing_pv), pvmetadatacopies,
|
||||
pvmetadatasize, &mdas))) {
|
||||
log_error("Failed to setup physical volume \"%s\"",
|
||||
dev_name(get_pv_dev(existing_pv)));
|
||||
dev_name(pv_dev(existing_pv)));
|
||||
if (change_made)
|
||||
log_error("Use pvcreate and vgcfgrestore to "
|
||||
"repair from archived metadata.");
|
||||
@@ -136,30 +129,30 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
change_made = 1;
|
||||
|
||||
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
||||
" available sectors", dev_name(get_pv_dev(pv)), get_pv_size(pv));
|
||||
" available sectors", dev_name(pv_dev(pv)), pv_size(pv));
|
||||
|
||||
/* Wipe existing label first */
|
||||
if (!label_remove(get_pv_dev(pv))) {
|
||||
if (!label_remove(pv_dev(pv))) {
|
||||
log_error("Failed to wipe existing label on %s",
|
||||
dev_name(get_pv_dev(pv)));
|
||||
dev_name(pv_dev(pv)));
|
||||
log_error("Use pvcreate and vgcfgrestore to repair "
|
||||
"from archived metadata.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
dev_name(get_pv_dev(pv)));
|
||||
dev_name(pv_dev(pv)));
|
||||
if (!(pv_write(cmd, pv, &mdas,
|
||||
arg_int64_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR)))) {
|
||||
log_error("Failed to write physical volume \"%s\"",
|
||||
dev_name(get_pv_dev(pv)));
|
||||
dev_name(pv_dev(pv)));
|
||||
log_error("Use pvcreate and vgcfgrestore to repair "
|
||||
"from archived metadata.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
log_verbose("Physical volume \"%s\" successfully created",
|
||||
dev_name(get_pv_dev(pv)));
|
||||
dev_name(pv_dev(pv)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -95,12 +95,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
|
||||
if (max_lv != vg->max_lv)
|
||||
log_error("Warning: Setting maxlogicalvolumes to %d "
|
||||
"(0 means unlimited)", vg->max_lv);
|
||||
log_warn("WARNING: Setting maxlogicalvolumes to %d "
|
||||
"(0 means unlimited)", vg->max_lv);
|
||||
|
||||
if (max_pv != vg->max_pv)
|
||||
log_error("Warning: Setting maxphysicalvolumes to %d "
|
||||
"(0 means unlimited)", vg->max_pv);
|
||||
log_warn("WARNING: Setting maxphysicalvolumes to %d "
|
||||
"(0 means unlimited)", vg->max_pv);
|
||||
|
||||
if (arg_count(cmd, addtag_ARG)) {
|
||||
if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {
|
||||
|
||||
@@ -28,8 +28,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
|
||||
if (!consistent)
|
||||
log_error("WARNING: Volume group \"%s\" inconsistent", vg_name);
|
||||
|
||||
if (vg->status & EXPORTED_VG)
|
||||
log_print("WARNING: volume group \"%s\" is exported", vg_name);
|
||||
vg_check_status(vg, EXPORTED_VG);
|
||||
|
||||
if (arg_count(cmd, colon_ARG)) {
|
||||
vgdisplay_colons(vg);
|
||||
|
||||
@@ -33,13 +33,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is already exported", vg_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg_name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto error;
|
||||
|
||||
/* extend vg */
|
||||
if (!vg_extend(vg->fid, vg, argc, argv))
|
||||
if (!vg_extend(vg, argc, argv))
|
||||
goto error;
|
||||
|
||||
/* ret > 0 */
|
||||
|
||||
@@ -29,12 +29,12 @@ static int vgimport_single(struct cmd_context *cmd __attribute((unused)),
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(vg->status & EXPORTED_VG)) {
|
||||
if (!(vg_status(vg) & EXPORTED_VG)) {
|
||||
log_error("Volume group \"%s\" is not exported", vg_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (vg->status & PARTIAL_VG) {
|
||||
if (vg_status(vg) & PARTIAL_VG) {
|
||||
log_error("Volume group \"%s\" is partially missing", vg_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
/* FIXME Also check for segs on deleted LVs */
|
||||
|
||||
pv = seg_pv(seg, s);
|
||||
if (!pv || !get_pv_dev(pv)) {
|
||||
if (!pv || !pv_dev(pv)) {
|
||||
if (arg_count(cmd, mirrorsonly_ARG) &&
|
||||
!(lv->status & MIRROR_IMAGE)) {
|
||||
log_error("Non-mirror-image LV %s found: can't remove.", lv->name);
|
||||
@@ -365,9 +365,9 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
void *handle __attribute((unused)))
|
||||
{
|
||||
struct pv_list *pvl;
|
||||
const char *name = dev_name(get_pv_dev(pv));
|
||||
const char *name = dev_name(pv_dev(pv));
|
||||
|
||||
if (get_pv_pe_alloc_count(pv)) {
|
||||
if (pv_pe_alloc_count(pv)) {
|
||||
log_error("Physical volume \"%s\" still in use", name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
@@ -391,14 +391,14 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
pv->vg_name = ORPHAN;
|
||||
pv->status = ALLOCATABLE_PV;
|
||||
|
||||
if (!dev_get_size(get_pv_dev(pv), &pv->size)) {
|
||||
log_error("%s: Couldn't get size.", dev_name(get_pv_dev(pv)));
|
||||
if (!dev_get_size(pv_dev(pv), &pv->size)) {
|
||||
log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
vg->pv_count--;
|
||||
vg->free_count -= get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv);
|
||||
vg->extent_count -= get_pv_pe_count(pv);
|
||||
vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
|
||||
vg->extent_count -= pv_pe_count(pv);
|
||||
|
||||
if (!vg_write(vg) || !vg_commit(vg)) {
|
||||
log_error("Removal of physical volume \"%s\" from "
|
||||
@@ -532,21 +532,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_print("Wrote out consistent volume group %s", vg_name);
|
||||
|
||||
} else {
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg_name);
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" is not reducible",
|
||||
vg_name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG)) {
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
struct pv_list *pvl;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (!vg || !consistent || (vg->status & PARTIAL_VG)) {
|
||||
if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
|
||||
log_error("Volume group \"%s\" not found or inconsistent.",
|
||||
vg_name);
|
||||
log_error("Consider vgreduce --removemissing if metadata "
|
||||
@@ -31,10 +31,8 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->lv_count) {
|
||||
log_error("Volume group \"%s\" still contains %d "
|
||||
@@ -54,12 +52,12 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
pv = pvl->pv;
|
||||
log_verbose("Removing physical volume \"%s\" from "
|
||||
"volume group \"%s\"", dev_name(get_pv_dev(pv)), vg_name);
|
||||
"volume group \"%s\"", dev_name(pv_dev(pv)), vg_name);
|
||||
pv->vg_name = ORPHAN;
|
||||
pv->status = ALLOCATABLE_PV;
|
||||
|
||||
if (!dev_get_size(get_pv_dev(pv), &pv->size)) {
|
||||
log_error("%s: Couldn't get size.", dev_name(get_pv_dev(pv)));
|
||||
if (!dev_get_size(pv_dev(pv), &pv->size)) {
|
||||
log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
|
||||
ret = ECMD_FAILED;
|
||||
continue;
|
||||
}
|
||||
@@ -68,7 +66,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
|
||||
log_error("Failed to remove physical volume \"%s\""
|
||||
" from volume group \"%s\"",
|
||||
dev_name(get_pv_dev(pv)), vg_name);
|
||||
dev_name(pv_dev(pv)), vg_name);
|
||||
ret = ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
log_print("Found %svolume group \"%s\" using metadata type %s",
|
||||
(vg->status & EXPORTED_VG) ? "exported " : "", vg_name,
|
||||
(vg_status(vg) & EXPORTED_VG) ? "exported " : "", vg_name,
|
||||
vg->fid->fmt->name);
|
||||
|
||||
check_current_backup(vg);
|
||||
|
||||
@@ -35,11 +35,11 @@ static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
|
||||
|
||||
pv = list_item(pvl, struct pv_list)->pv;
|
||||
|
||||
vg_from->extent_count -= get_pv_pe_count(pv);
|
||||
vg_to->extent_count += get_pv_pe_count(pv);
|
||||
vg_from->extent_count -= pv_pe_count(pv);
|
||||
vg_to->extent_count += pv_pe_count(pv);
|
||||
|
||||
vg_from->free_count -= get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv);
|
||||
vg_to->free_count += get_pv_pe_count(pv) - get_pv_pe_alloc_count(pv);
|
||||
vg_from->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
|
||||
vg_to->free_count += pv_pe_count(pv) - pv_pe_alloc_count(pv);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
|
||||
continue;
|
||||
}
|
||||
log_error("Physical Volume %s not found",
|
||||
dev_name(get_pv_dev(pv)));
|
||||
dev_name(pv_dev(pv)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto error;
|
||||
|
||||
/* Split metadata areas and check if both vgs have at least one area */
|
||||
if (!(vg_split_mdas(cmd, vg_from, vg_to))) {
|
||||
if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) {
|
||||
log_error("Cannot split: Nowhere to store metadata for new Volume Group");
|
||||
goto error;
|
||||
}
|
||||
@@ -344,10 +344,12 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
|
||||
backup(vg_to);
|
||||
|
||||
/* Write out updated old VG */
|
||||
if (!vg_write(vg_from) || !vg_commit(vg_from))
|
||||
goto error;
|
||||
if (vg_from->pv_count) {
|
||||
if (!vg_write(vg_from) || !vg_commit(vg_from))
|
||||
goto error;
|
||||
|
||||
backup(vg_from);
|
||||
backup(vg_from);
|
||||
}
|
||||
|
||||
/* Remove EXPORTED flag from new VG */
|
||||
consistent = 1;
|
||||
|
||||
Reference in New Issue
Block a user