1
0
mirror of git://sourceware.org/git/lvm2.git synced 2026-02-04 12:32:46 +03:00

Compare commits

...

16 Commits

Author SHA1 Message Date
Alasdair Kergon
8ac9fabd07 pre-release 2007-08-24 21:01:52 +00:00
Patrick Caulfield
44c2b4b281 Fix clvmd logging so you can get lvm-level debugging out of it. 2007-08-24 08:29:39 +00:00
Patrick Caulfield
4cd97611e5 Locking P_global causes a cache refresh. 2007-08-23 15:43:20 +00:00
Alasdair Kergon
da27380ab5 Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R. 2007-08-23 15:02:26 +00:00
Patrick Caulfield
756e539661 Force a device scan after init_full_scan_done() per agk. 2007-08-23 12:44:09 +00:00
Patrick Caulfield
cde44e3172 Call init_full_scan_done() when refreshing the cache. This should fix clvmd -R. 2007-08-23 12:19:13 +00:00
Alasdair Kergon
e79a4b34b0 Change lvconvert_mirrors to use mirror segtype not striped. 2007-08-22 20:03:46 +00:00
Alasdair Kergon
e9f0bdd72c Fix lvconvert_mirrors detection of number of existing mirrors. 2007-08-22 19:32:39 +00:00
Alasdair Kergon
d080291150 Clean up numerous compiler warnings that crept in recently.
Remove several unused parameters from _allocate().
2007-08-22 14:38:18 +00:00
Jim Meyering
06c69c56ba Avoid static link failure with some SELinux libraries. 2007-08-21 20:32:29 +00:00
Alasdair Kergon
d79710ba9d Fix (C) ! 2007-08-21 19:56:18 +00:00
Alasdair Kergon
c9bc7dd0b6 Clean up mirrorlog argument processing.
Only permit --force, --verbose and --debug arguments to be repeated.
2007-08-21 19:46:36 +00:00
Alasdair Kergon
ebc26c7421 Remove obsolete dmfs code from tree and update INSTALL. 2007-08-21 18:41:58 +00:00
Dave Wysochanski
3769425f6b Move guts of vgremove into lvm library.
Include archiver.h in metadata.c as a result of prior move.
2007-08-21 17:38:20 +00:00
Alasdair Kergon
a50957443e post-release 2007-08-21 17:03:07 +00:00
Dave Wysochanski
63fa007af0 Prepare to move guts of vgremove into lvm library.
Fixup force_t.
2007-08-21 16:40:33 +00:00
54 changed files with 570 additions and 492 deletions

View File

@@ -1 +1 @@
2.02.28-cvs (2007-07-17)
2.02.28-cvs (2007-08-24)

View File

@@ -1,27 +1,37 @@
Version 2.02.28 -
================================
Version 2.02.28 - 24th August 2007
==================================
Fix clvmd logging so you can get lvm-level debugging out of it.
Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R.
Change locking_flags from int to uint32_t.
Fix clvmd -R, so it fully refreshes the caches.
Change lvconvert_mirrors to use mirror segtype not striped.
Fix lvconvert_mirrors detection of number of existing mirrors.
Clean up numerous compiler warnings that appeared in recent releases.
Remove several unused parameters from _allocate().
Only permit --force, --verbose and --debug arguments to be repeated.
Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.
Move guts of lvremove into library.
Allow clvmd debug to be turned on in a running daemon using clvmd -d
Move guts of vgremove and lvremove into library, including yes_no_prompt.
Allow clvmd debug to be turned on in a running daemon using clvmd -d [-C].
Update to use autoconf 2.61, while still supporting 2.57.
Add more cluster info to lvmdump
Add const attributes where possible, first cut.
Add more cluster info to lvmdump.
Add further const attributes throughout.
Add support for renaming mirrored LVs.
Factor out core of lvrename() to lv_rename lvm library function.
Add --log argument to specify log type for mirrors.
Don't try to monitor devices which we failed to create.
Don't leak a file descriptor in fcntl_lock_file(), when fcntl fails.
Remove create_dir function; use now-equivalent dm_create_dir instead
Detect stream write failure reliably; new fn: lvm_fclose; use dm_fclose
Factor out core of lvrename() to library function.
Add --mirrorlog argument to specify log type for mirrors.
Don't attempt to monitor devices if their creation failed in _lv_activate.
Don't leak a file descriptor in fcntl_lock_file() when fcntl fails.
Replace create_dir with dm_create_dir.
Detect stream write failure reliably with lvm_fclose using dm_fclose.
Fix clvmd if compiled with gulm support. (2.02.26)
Trivial fix to lvdisplay man page.
Fix lvdisplay man page to say LV size is reported in sectors, not KB.
Add vg_lock_and_read() external library function.
Fix loading of persistent cache if cache_dir is used. (2.02.23)
Eliminate uses of strdup+basename. Use last_path_component instead.
Reduce _compare_paths lstat error message from log_error to log_very_verbose.
Create util.h with last_path_component replacing strdup + basename.
Use gcc's printf attribute wherever possible.
In _line_append, use "sizeof buf - 1" rather than equivalent "4095"
In _line_append, use "sizeof buf - 1" rather than equivalent "4095".
Introduce is_same_inode macro, now including a comparison of st_dev.
Don't leak a file descriptor in _lock_file(), when flock fails.
Don't leak a file descriptor in _lock_file() when flock fails.
Add SUN's LDOM virtual block device (vdisk) and ps3disk to filters.
Split metadata-external.h out from metadata.h for the tools to use.

View File

@@ -1,3 +1,8 @@
Version 1.02.23 -
==================================
Avoid static link failure with some SELinux libraries.
Remove obsolete dmfs code from tree and update INSTALL.
Version 1.02.22 - 21st August 2007
==================================
Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.

View File

@@ -115,8 +115,13 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
break;
case CLVMD_CMD_LOCK_VG:
lockname = &args[2];
/* Check to see if the VG is in use by LVM1 */
status = do_check_lvm1(&args[2]);
status = do_check_lvm1(lockname);
/* P_global causes a cache refresh */
if (strcmp(lockname, "P_global") == 0)
do_refresh_cache();
break;
case CLVMD_CMD_LOCK_LV:

View File

@@ -42,6 +42,7 @@
/* LVM2 headers */
#include "toolcontext.h"
#include "lvmcache.h"
#include "log.h"
#include "activate.h"
#include "locking.h"
@@ -442,9 +443,15 @@ int do_check_lvm1(const char *vgname)
int do_refresh_cache()
{
int ret;
DEBUGLOG("Refreshing context\n");
log_notice("Refreshing context");
return refresh_toolcontext(cmd)==1?0:-1;
ret = refresh_toolcontext(cmd);
init_full_scan_done(0);
lvmcache_label_scan(cmd, 2);
return ret==1?0:-1;
}
@@ -541,6 +548,15 @@ static void *get_initial_state()
static void lvm2_log_fn(int level, const char *file, int line,
const char *message)
{
/* Send messages to the normal LVM2 logging system too,
so we get debug output when it's asked for.
We need to NULL the function ptr otherwise it will just call
back into here! */
init_log_fn(NULL);
print_log(level, file, line, "%s", message);
init_log_fn(lvm2_log_fn);
/*
* Ignore non-error messages, but store the latest one for returning
* to the user.
@@ -594,7 +610,10 @@ int init_lvm(int using_gulm)
/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
init_syslog(LOG_DAEMON);
init_debug(_LOG_ERR);
openlog("clvmd", LOG_PID, LOG_DAEMON);
init_debug(cmd->current_settings.debug);
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
set_activation(cmd->current_settings.activation);
/* Check lvm.conf is setup for cluster-LVM */
check_config();

View File

@@ -156,7 +156,7 @@ static int _parse_config_file(struct parser *p, struct config_tree *cft)
return 1;
}
struct config_tree *create_config_tree_from_string(struct cmd_context *cmd,
struct config_tree *create_config_tree_from_string(struct cmd_context *cmd __attribute((unused)),
const char *config_settings)
{
struct cs *c;
@@ -371,7 +371,7 @@ static int _line_append(struct output_line *outline, const char *fmt, ...)
va_start(ap, fmt);
n = vsnprintf(&buf[0], sizeof buf - 1, fmt, ap);
if (n < 0 || n > sizeof buf - 1) {
if (n < 0 || n > (int) sizeof buf - 1) {
log_error("vsnprintf failed for config line");
return 0;
}
@@ -1248,13 +1248,13 @@ static char _token_type_to_char(int type)
* Returns:
* # of 'type' tokens in 'str'.
*/
static unsigned _count_tokens (const char *str, unsigned len, int type)
static unsigned _count_tokens(const char *str, unsigned len, int type)
{
char c;
c = _token_type_to_char(type);
return(count_chars_len(str, len, c));
return count_chars_len(str, len, c);
}
/*

View File

@@ -39,6 +39,7 @@
#define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1
#define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
#define DEFAULT_MIRRORLOG "disk"
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
#define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
#define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"

View File

@@ -67,7 +67,7 @@ static int _errseg_target_present(const struct lv_segment *seg __attribute((unus
#endif
static int _errseg_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg,
const struct lv_segment *seg __attribute((unused)),
struct list *modules)
{
if (!str_list_add(mem, modules, "error")) {

View File

@@ -299,7 +299,7 @@ struct dev_filter *sysfs_filter_create(const char *proc)
#else
struct dev_filter *sysfs_filter_create(const char *proc)
struct dev_filter *sysfs_filter_create(const char *proc __attribute((unused)))
{
return NULL;
}

View File

@@ -80,7 +80,7 @@ static const device_info_t device_info[] = {
{NULL, 0}
};
static int _passes_lvm_type_device_filter(struct dev_filter *f,
static int _passes_lvm_type_device_filter(struct dev_filter *f __attribute((unused)),
struct device *dev)
{
const char *name = dev_name(dev);

View File

@@ -653,7 +653,7 @@ static int _write_pvd(struct disk_list *data)
/*
* assumes the device has been opened.
*/
static int __write_all_pvd(const struct format_type *fmt,
static int __write_all_pvd(const struct format_type *fmt __attribute((unused)),
struct disk_list *data)
{
const char *pv_name = dev_name(data->dev);

View File

@@ -175,7 +175,7 @@ static struct volume_group *_build_vg(struct format_instance *fid,
static struct volume_group *_format1_vg_read(struct format_instance *fid,
const char *vg_name,
struct metadata_area *mda)
struct metadata_area *mda __attribute((unused)))
{
struct dm_pool *mem = dm_pool_create("lvm1 vg_read", 1024 * 10);
struct list pvs;
@@ -261,7 +261,7 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
}
static int _format1_vg_write(struct format_instance *fid, struct volume_group *vg,
struct metadata_area *mda)
struct metadata_area *mda __attribute((unused)))
{
struct dm_pool *mem = dm_pool_create("lvm1 vg_write", 1024 * 10);
struct list pvds;
@@ -284,7 +284,7 @@ static int _format1_vg_write(struct format_instance *fid, struct volume_group *v
}
static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
struct physical_volume *pv, struct list *mdas)
struct physical_volume *pv, struct list *mdas __attribute((unused)))
{
struct dm_pool *mem = dm_pool_create("lvm1 pv_read", 1024);
struct disk_list *dl;
@@ -325,9 +325,9 @@ static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
static int _format1_pv_setup(const struct format_type *fmt,
uint64_t pe_start, uint32_t extent_count,
uint32_t extent_size,
int pvmetadatacopies,
uint64_t pvmetadatasize, struct list *mdas,
struct physical_volume *pv, struct volume_group *vg)
int pvmetadatacopies __attribute((unused)),
uint64_t pvmetadatasize __attribute((unused)), struct list *mdas __attribute((unused)),
struct physical_volume *pv, struct volume_group *vg __attribute((unused)))
{
if (pv->size > MAX_PV_SIZE)
pv->size--;
@@ -381,7 +381,7 @@ static int _format1_lv_setup(struct format_instance *fid, struct logical_volume
}
static int _format1_pv_write(const struct format_type *fmt, struct physical_volume *pv,
struct list *mdas, int64_t sector)
struct list *mdas __attribute((unused)), int64_t sector __attribute((unused)))
{
struct dm_pool *mem;
struct disk_list *dl;
@@ -470,7 +470,7 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
return 1;
}
static int _format1_segtype_supported(struct format_instance *fid,
static int _format1_segtype_supported(struct format_instance *fid __attribute((unused)),
const struct segment_type *segtype)
{
if (!(segtype->flags & SEG_FORMAT1_SUPPORT)) {
@@ -487,9 +487,9 @@ static struct metadata_area_ops _metadata_format1_ops = {
};
static struct format_instance *_format1_create_instance(const struct format_type *fmt,
const char *vgname,
const char *vgid,
void *private)
const char *vgname __attribute((unused)),
const char *vgid __attribute((unused)),
void *private __attribute((unused)))
{
struct format_instance *fid;
struct metadata_area *mda;
@@ -516,7 +516,7 @@ static struct format_instance *_format1_create_instance(const struct format_type
return fid;
}
static void _format1_destroy_instance(struct format_instance *fid)
static void _format1_destroy_instance(struct format_instance *fid __attribute((unused)))
{
return;
}

View File

@@ -134,7 +134,7 @@ static int _system_id(struct cmd_context *cmd, char *s, const char *prefix)
return 1;
}
int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute((unused)),
struct volume_group *vg,
struct pv_disk *pvd, struct physical_volume *pv)
{
@@ -588,7 +588,7 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
/*
* FIXME: More inefficient code.
*/
int import_snapshots(struct dm_pool *mem, struct volume_group *vg,
int import_snapshots(struct dm_pool *mem __attribute((unused)), struct volume_group *vg,
struct list *pvds)
{
struct logical_volume *lvs[MAX_LV];
@@ -679,7 +679,7 @@ int export_uuids(struct disk_list *dl, struct volume_group *vg)
* This calculates the nasty pv_number field
* used by LVM1.
*/
void export_numbers(struct list *pvds, struct volume_group *vg)
void export_numbers(struct list *pvds, struct volume_group *vg __attribute((unused)))
{
struct disk_list *dl;
int pv_num = 1;

View File

@@ -30,7 +30,7 @@ static void _not_supported(const char *op)
op);
}
static int _lvm1_can_handle(struct labeller *l, void *buf, uint64_t sector)
static int _lvm1_can_handle(struct labeller *l __attribute((unused)), void *buf, uint64_t sector)
{
struct pv_disk *pvd = (struct pv_disk *) buf;
uint32_t version;
@@ -48,7 +48,7 @@ static int _lvm1_can_handle(struct labeller *l, void *buf, uint64_t sector)
return 0;
}
static int _lvm1_write(struct label *label, void *buf)
static int _lvm1_write(struct label *label __attribute((unused)), void *buf __attribute((unused)))
{
_not_supported("write");
return 0;
@@ -85,14 +85,14 @@ static int _lvm1_read(struct labeller *l, struct device *dev, void *buf,
return 1;
}
static int _lvm1_initialise_label(struct labeller *l, struct label *label)
static int _lvm1_initialise_label(struct labeller *l __attribute((unused)), struct label *label)
{
strcpy(label->type, "LVM1");
return 1;
}
static void _lvm1_destroy_label(struct labeller *l, struct label *label)
static void _lvm1_destroy_label(struct labeller *l __attribute((unused)), struct label *label __attribute((unused)))
{
return;
}

View File

@@ -33,8 +33,8 @@
#define CPOUT_64(x, y) {(y) = xlate64_be((x));}
static int __read_pool_disk(const struct format_type *fmt, struct device *dev,
struct dm_pool *mem, struct pool_list *pl,
const char *vg_name)
struct dm_pool *mem __attribute((unused)), struct pool_list *pl,
const char *vg_name __attribute((unused)))
{
char buf[512] __attribute((aligned(8)));

View File

@@ -172,7 +172,7 @@ static struct volume_group *_build_vg_from_pds(struct format_instance
static struct volume_group *_pool_vg_read(struct format_instance *fid,
const char *vg_name,
struct metadata_area *mda)
struct metadata_area *mda __attribute((unused)))
{
struct dm_pool *mem = dm_pool_create("pool vg_read", 1024);
struct list pds;
@@ -207,18 +207,22 @@ static struct volume_group *_pool_vg_read(struct format_instance *fid,
return vg;
}
static int _pool_pv_setup(const struct format_type *fmt,
uint64_t pe_start, uint32_t extent_count,
uint32_t extent_size,
int pvmetadatacopies,
uint64_t pvmetadatasize, struct list *mdas,
struct physical_volume *pv, struct volume_group *vg)
static int _pool_pv_setup(const struct format_type *fmt __attribute((unused)),
uint64_t pe_start __attribute((unused)),
uint32_t extent_count __attribute((unused)),
uint32_t extent_size __attribute((unused)),
int pvmetadatacopies __attribute((unused)),
uint64_t pvmetadatasize __attribute((unused)),
struct list *mdas __attribute((unused)),
struct physical_volume *pv __attribute((unused)),
struct volume_group *vg __attribute((unused)))
{
return 1;
}
static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
struct physical_volume *pv, struct list *mdas)
struct physical_volume *pv,
struct list *mdas __attribute((unused)))
{
struct dm_pool *mem = dm_pool_create("pool pv_read", 1024);
struct pool_list *pl;
@@ -268,9 +272,9 @@ static struct metadata_area_ops _metadata_format_pool_ops = {
/* *INDENT-ON* */
static struct format_instance *_pool_create_instance(const struct format_type *fmt,
const char *vgname,
const char *vgid,
void *private)
const char *vgname __attribute((unused)),
const char *vgid __attribute((unused)),
void *private __attribute((unused)))
{
struct format_instance *fid;
struct metadata_area *mda;
@@ -299,7 +303,7 @@ static struct format_instance *_pool_create_instance(const struct format_type *f
return fid;
}
static void _pool_destroy_instance(struct format_instance *fid)
static void _pool_destroy_instance(struct format_instance *fid __attribute((unused)))
{
return;
}

View File

@@ -29,7 +29,7 @@ static void _pool_not_supported(const char *op)
op);
}
static int _pool_can_handle(struct labeller *l, void *buf, uint64_t sector)
static int _pool_can_handle(struct labeller *l __attribute((unused)), void *buf, uint64_t sector)
{
struct pool_disk pd;
@@ -50,7 +50,7 @@ static int _pool_can_handle(struct labeller *l, void *buf, uint64_t sector)
return 0;
}
static int _pool_write(struct label *label, void *buf)
static int _pool_write(struct label *label __attribute((unused)), void *buf __attribute((unused)))
{
_pool_not_supported("write");
return 0;
@@ -64,14 +64,14 @@ static int _pool_read(struct labeller *l, struct device *dev, void *buf,
return read_pool_label(&pl, l, dev, buf, label);
}
static int _pool_initialise_label(struct labeller *l, struct label *label)
static int _pool_initialise_label(struct labeller *l __attribute((unused)), struct label *label)
{
strcpy(label->type, "POOL");
return 1;
}
static void _pool_destroy_label(struct labeller *l, struct label *label)
static void _pool_destroy_label(struct labeller *l __attribute((unused)), struct label *label __attribute((unused)))
{
return;
}

View File

@@ -140,8 +140,8 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
int i;
uint64_t offset;
uint64_t offset2;
uint64_t size;
uint64_t size2;
size_t size;
size_t size2;
char *buf=NULL;
struct device_area *area;
struct mda_context *mdac;
@@ -149,9 +149,8 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
mdac = (struct mda_context *) mda->metadata_locn;
log_print("Found text metadata area, offset=%"PRIu64", size=%"PRIu64,
mdac->area.start,
mdac->area.size);
log_print("Found text metadata area: offset=%" PRIu64 ", size=%"
PRIu64, mdac->area.start, mdac->area.size);
area = &mdac->area;
if (!dev_open(area->dev))
@@ -201,12 +200,12 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
/*
* FIXME: We could add more sophisticated metadata detection
*/
if (maybe_config_section(buf, size+size2)) {
if (maybe_config_section(buf, size + size2)) {
/* FIXME: Validate region, pull out timestamp?, etc */
/* FIXME: Do something with this region */
log_verbose ("Found LVM2 metadata record at "
"offset=%"PRIu64", size=%"PRIu64", "
"offset2=%"PRIu64" size2=%"PRIu64,
"offset=%"PRIu64", size=%"PRIsize_t", "
"offset2=%"PRIu64" size2=%"PRIsize_t,
offset, size, offset2, size2);
offset = prev_sector;
size = SECTOR_SIZE;
@@ -840,8 +839,8 @@ static struct volume_group *_vg_read_precommit_file(struct format_instance *fid,
return vg;
}
static int _vg_write_file(struct format_instance *fid, struct volume_group *vg,
struct metadata_area *mda)
static int _vg_write_file(struct format_instance *fid __attribute((unused)),
struct volume_group *vg, struct metadata_area *mda)
{
struct text_context *tc = (struct text_context *) mda->metadata_locn;
@@ -905,7 +904,7 @@ static int _vg_write_file(struct format_instance *fid, struct volume_group *vg,
return 1;
}
static int _vg_commit_file_backup(struct format_instance *fid,
static int _vg_commit_file_backup(struct format_instance *fid __attribute((unused)),
struct volume_group *vg,
struct metadata_area *mda)
{
@@ -972,7 +971,8 @@ static int _vg_commit_file(struct format_instance *fid, struct volume_group *vg,
return 1;
}
static int _vg_remove_file(struct format_instance *fid, struct volume_group *vg,
static int _vg_remove_file(struct format_instance *fid __attribute((unused)),
struct volume_group *vg __attribute((unused)),
struct metadata_area *mda)
{
struct text_context *tc = (struct text_context *) mda->metadata_locn;
@@ -1164,7 +1164,8 @@ static int _mda_setup(const struct format_type *fmt,
uint64_t pe_start, uint64_t pe_end,
int pvmetadatacopies,
uint64_t pvmetadatasize, struct list *mdas,
struct physical_volume *pv, struct volume_group *vg)
struct physical_volume *pv,
struct volume_group *vg __attribute((unused)))
{
uint64_t mda_adjustment, disk_size, alignment;
uint64_t start1, mda_size1; /* First area - start of disk */

View File

@@ -111,7 +111,8 @@ static int _read_id(struct id *id, struct config_node *cn, const char *path)
static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
struct volume_group *vg, struct config_node *pvn,
struct config_node *vgn, struct dm_hash_table *pv_hash)
struct config_node *vgn __attribute((unused)),
struct dm_hash_table *pv_hash)
{
struct physical_volume *pv;
struct pv_list *pvl;
@@ -383,12 +384,12 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
/* FIXME Cope if LV not yet read in */
if ((pv = dm_hash_lookup(pv_hash, cv->v.str))) {
if (!set_lv_segment_area_pv(seg, s, pv, cv->next->v.i)) {
if (!set_lv_segment_area_pv(seg, s, pv, (uint32_t) cv->next->v.i)) {
stack;
return 0;
}
} else if ((lv1 = find_lv(seg->lv->vg, cv->v.str))) {
set_lv_segment_area_lv(seg, s, lv1, cv->next->v.i,
set_lv_segment_area_lv(seg, s, lv1, (uint32_t) cv->next->v.i,
flags);
} else {
log_error("Couldn't find volume '%s' "
@@ -469,9 +470,11 @@ static int _read_segments(struct dm_pool *mem, struct volume_group *vg,
return 1;
}
static int _read_lvnames(struct format_instance *fid, struct dm_pool *mem,
static int _read_lvnames(struct format_instance *fid __attribute((unused)),
struct dm_pool *mem,
struct volume_group *vg, struct config_node *lvn,
struct config_node *vgn, struct dm_hash_table *pv_hash)
struct config_node *vgn __attribute((unused)),
struct dm_hash_table *pv_hash __attribute((unused)))
{
struct logical_volume *lv;
struct lv_list *lvl;
@@ -544,9 +547,11 @@ static int _read_lvnames(struct format_instance *fid, struct dm_pool *mem,
return 1;
}
static int _read_lvsegs(struct format_instance *fid, struct dm_pool *mem,
static int _read_lvsegs(struct format_instance *fid __attribute((unused)),
struct dm_pool *mem,
struct volume_group *vg, struct config_node *lvn,
struct config_node *vgn, struct dm_hash_table *pv_hash)
struct config_node *vgn __attribute((unused)),
struct dm_hash_table *pv_hash)
{
struct logical_volume *lv;
struct lv_list *lvl;

View File

@@ -31,7 +31,7 @@
#include <unistd.h>
#ifndef CLUSTER_LOCKING_INTERNAL
int lock_resource(struct cmd_context *cmd, const char *resource, int flags);
int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags);
void locking_end(void);
int locking_init(int type, struct config_tree *cf, uint32_t *flags);
#endif
@@ -295,7 +295,7 @@ static int _cluster_free_request(lvm_response_t * response, int num)
return 1;
}
static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
static int _lock_for_cluster(unsigned char cmd, uint32_t flags, char *name)
{
int status;
int i;
@@ -330,11 +330,14 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
* locks are cluster-wide.
* Also, if the lock is exclusive it makes no sense to try to
* acquire it on all nodes, so just do that on the local node too.
* One exception, is that P_ locks /do/ get distributed across
* the cluster because they might have side-effects.
*/
if (cmd == CLVMD_CMD_LOCK_VG ||
(flags & LCK_TYPE_MASK) == LCK_EXCL ||
(flags & LCK_LOCAL) ||
!(flags & LCK_CLUSTER_VG))
if (strncmp(name, "P_", 2) &&
(cmd == CLVMD_CMD_LOCK_VG ||
(flags & LCK_TYPE_MASK) == LCK_EXCL ||
(flags & LCK_LOCAL) ||
!(flags & LCK_CLUSTER_VG)))
node = ".";
status = _cluster_request(cmd, node, args, len,
@@ -368,9 +371,9 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
/* API entry point for LVM */
#ifdef CLUSTER_LOCKING_INTERNAL
static int _lock_resource(struct cmd_context *cmd, const char *resource,
int flags)
uint32_t flags)
#else
int lock_resource(struct cmd_context *cmd, const char *resource, int flags)
int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
#endif
{
char lockname[PATH_MAX];
@@ -382,8 +385,10 @@ int lock_resource(struct cmd_context *cmd, const char *resource, int flags)
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
/* If the VG name is empty then lock the unused PVs */
if (!*resource)
if (!*resource) /* FIXME Deprecated */
dm_snprintf(lockname, sizeof(lockname), "P_orphans");
else if (*resource == '#')
dm_snprintf(lockname, sizeof(lockname), "P_%s", resource + 1);
else
dm_snprintf(lockname, sizeof(lockname), "V_%s",
resource);

View File

@@ -23,12 +23,12 @@ static void *_locking_lib = NULL;
static void (*_reset_fn) (void) = NULL;
static void (*_end_fn) (void) = NULL;
static int (*_lock_fn) (struct cmd_context * cmd, const char *resource,
int flags) = NULL;
uint32_t flags) = NULL;
static int (*_init_fn) (int type, struct config_tree * cft,
uint32_t *flags) = NULL;
static int _lock_resource(struct cmd_context *cmd, const char *resource,
int flags)
uint32_t flags)
{
if (_lock_fn)
return _lock_fn(cmd, resource, flags);

View File

@@ -124,7 +124,7 @@ static void _install_ctrl_c_handler()
siginterrupt(SIGINT, 1);
}
static int _lock_file(const char *file, int flags)
static int _lock_file(const char *file, uint32_t flags)
{
int operation;
int r = 1;
@@ -204,7 +204,7 @@ static int _lock_file(const char *file, int flags)
}
static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
int flags)
uint32_t flags)
{
char lockfile[PATH_MAX];
@@ -212,9 +212,12 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
if (!*resource)
if (!*resource) /* FIXME Deprecated */
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_orphans", _lock_dir);
else if (*resource == '#')
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_%s", _lock_dir, resource + 1);
else
dm_snprintf(lockfile, sizeof(lockfile),
"%s/V_%s", _lock_dir, resource);

View File

@@ -118,7 +118,7 @@ void sigint_restore(void)
sigaction(SIGINT, &_oldhandler, NULL);
}
static void _block_signals(int flags __attribute((unused)))
static void _block_signals(uint32_t flags __attribute((unused)))
{
sigset_t set;
@@ -156,7 +156,7 @@ static void _unblock_signals(void)
return;
}
static void _lock_memory(int flags)
static void _lock_memory(uint32_t flags)
{
if (!(_locking.flags & LCK_PRE_MEMLOCK))
return;
@@ -165,7 +165,7 @@ static void _lock_memory(int flags)
memlock_inc();
}
static void _unlock_memory(int flags)
static void _unlock_memory(uint32_t flags)
{
if (!(_locking.flags & LCK_PRE_MEMLOCK))
return;
@@ -187,7 +187,7 @@ void reset_locking(void)
_unblock_signals();
}
static void _update_vg_lock_count(int flags)
static void _update_vg_lock_count(uint32_t flags)
{
if ((flags & LCK_SCOPE_MASK) != LCK_VG)
return;
@@ -313,7 +313,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
* VG locking is by VG name.
* FIXME This should become VG uuid.
*/
static int _lock_vol(struct cmd_context *cmd, const char *resource, int flags)
static int _lock_vol(struct cmd_context *cmd, const char *resource, uint32_t flags)
{
_block_signals(flags);
_lock_memory(flags);
@@ -331,7 +331,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, int flags)
return 1;
}
int lock_vol(struct cmd_context *cmd, const char *vol, int flags)
int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
{
char resource[258] __attribute((aligned(8)));

View File

@@ -28,14 +28,14 @@ int locking_is_clustered(void);
/*
* LCK_VG:
* Lock/unlock on-disk volume group data
* Use "" to lock orphan PVs
* Use VG_ORPHANS to lock orphan PVs
* char *vol holds volume group name
*
* LCK_LV:
* Lock/unlock an individual logical volume
* char *vol holds lvid
*/
int lock_vol(struct cmd_context *cmd, const char *vol, int flags);
int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags);
/*
* Does the LVM1 driver have this VG active?
@@ -45,38 +45,43 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
/*
* Lock type - these numbers are the same as VMS and the IBM DLM
*/
#define LCK_TYPE_MASK 0x00000007
#define LCK_TYPE_MASK 0x00000007U
#define LCK_NULL 0x00000000 /* LCK$_NLMODE */
#define LCK_READ 0x00000001 /* LCK$_CRMODE */
#define LCK_NULL 0x00000000U /* LCK$_NLMODE */
#define LCK_READ 0x00000001U /* LCK$_CRMODE */
/* LCK$_CWMODE */
#define LCK_PREAD 0x00000003 /* LCK$_PRMODE */
#define LCK_WRITE 0x00000004 /* LCK$_PWMODE */
#define LCK_EXCL 0x00000005 /* LCK$_EXMODE */
#define LCK_UNLOCK 0x00000006 /* This is ours */
#define LCK_PREAD 0x00000003U /* LCK$_PRMODE */
#define LCK_WRITE 0x00000004U /* LCK$_PWMODE */
#define LCK_EXCL 0x00000005U /* LCK$_EXMODE */
#define LCK_UNLOCK 0x00000006U /* This is ours */
/*
* Lock scope
*/
#define LCK_SCOPE_MASK 0x00000008
#define LCK_VG 0x00000000
#define LCK_LV 0x00000008
#define LCK_SCOPE_MASK 0x00000008U
#define LCK_VG 0x00000000U
#define LCK_LV 0x00000008U
/*
* Lock bits
*/
#define LCK_NONBLOCK 0x00000010 /* Don't block waiting for lock? */
#define LCK_HOLD 0x00000020 /* Hold lock when lock_vol returns? */
#define LCK_LOCAL 0x00000040 /* Don't propagate to other nodes */
#define LCK_CLUSTER_VG 0x00000080 /* VG is clustered */
#define LCK_NONBLOCK 0x00000010U /* Don't block waiting for lock? */
#define LCK_HOLD 0x00000020U /* Hold lock when lock_vol returns? */
#define LCK_LOCAL 0x00000040U /* Don't propagate to other nodes */
#define LCK_CLUSTER_VG 0x00000080U /* VG is clustered */
/*
* Additional lock bits for cluster communication
*/
#define LCK_PARTIAL_MODE 0x00000001 /* Running in partial mode */
#define LCK_MIRROR_NOSYNC_MODE 0x00000002 /* Mirrors don't require sync */
#define LCK_DMEVENTD_MONITOR_MODE 0x00000004 /* Register with dmeventd */
#define LCK_PARTIAL_MODE 0x00000001U /* Running in partial mode */
#define LCK_MIRROR_NOSYNC_MODE 0x00000002U /* Mirrors don't require sync */
#define LCK_DMEVENTD_MONITOR_MODE 0x00000004U /* Register with dmeventd */
/*
* Special cases of VG locks.
*/
#define VG_ORPHANS "#orphans"
#define VG_GLOBAL "#global"
/*
* Common combinations

View File

@@ -17,7 +17,7 @@
#include "config.h"
typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource,
int flags);
uint32_t flags);
typedef void (*fin_lock_fn) (void);
typedef void (*reset_lock_fn) (void);

View File

@@ -37,7 +37,7 @@ static void _no_reset_locking(void)
}
static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
int flags)
uint32_t flags)
{
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
@@ -76,7 +76,7 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
return 1;
}
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd)
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
{
locking->lock_resource = _no_lock_resource;
locking->reset_locking = _no_reset_locking;

View File

@@ -50,7 +50,6 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
uint32_t extents,
struct physical_volume *mirrored_pv,
uint32_t mirrored_pe,
uint32_t status,
struct list *allocatable_pvs,
alloc_policy_t alloc,
struct list *parallel_areas);

View File

@@ -735,13 +735,13 @@ static int _for_each_pv(struct cmd_context *cmd, struct logical_volume *lv,
(le - seg->le) / area_multiple,
area_len, max_seg_len,
only_single_area_segments ? 0 : 0,
only_single_area_segments ? 1 : 0,
top_level_area_index != -1 ? top_level_area_index : s,
only_single_area_segments ? 1U : 0U,
top_level_area_index != -1 ? top_level_area_index : (int) s,
only_single_area_segments, fn,
data)))
stack;
} else if (seg_type(seg, s) == AREA_PV)
if (!(r = fn(cmd, seg_pvseg(seg, s), top_level_area_index != -1 ? top_level_area_index : s, data)))
if (!(r = fn(cmd, seg_pvseg(seg, s), top_level_area_index != -1 ? (uint32_t) top_level_area_index : s, data)))
stack;
if (r != 1)
return r;
@@ -813,7 +813,7 @@ static int _is_contiguous(struct pv_segment *pvseg, struct pv_area *pva)
return 1;
}
static int _is_condition(struct cmd_context *cmd,
static int _is_condition(struct cmd_context *cmd __attribute((unused)),
struct pv_segment *pvseg, uint32_t s,
void *data)
{
@@ -1068,11 +1068,9 @@ static int _find_parallel_space(struct alloc_handle *ah, alloc_policy_t alloc,
*/
static int _allocate(struct alloc_handle *ah,
struct volume_group *vg,
struct logical_volume *lv, uint32_t status,
struct logical_volume *lv,
uint32_t new_extents,
struct list *allocatable_pvs,
uint32_t stripes, uint32_t mirrors,
const struct segment_type *segtype)
struct list *allocatable_pvs)
{
struct pv_area **areas;
uint32_t allocated = lv ? lv->le_count : 0;
@@ -1197,7 +1195,6 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
uint32_t extents,
struct physical_volume *mirrored_pv,
uint32_t mirrored_pe,
uint32_t status,
struct list *allocatable_pvs,
alloc_policy_t alloc,
struct list *parallel_areas)
@@ -1230,8 +1227,8 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
}
if (!segtype_is_virtual(segtype) &&
!_allocate(ah, vg, lv, status, (lv ? lv->le_count : 0) + extents,
allocatable_pvs, stripes, mirrors, segtype)) {
!_allocate(ah, vg, lv, (lv ? lv->le_count : 0) + extents,
allocatable_pvs)) {
stack;
alloc_destroy(ah);
return NULL;
@@ -1334,8 +1331,8 @@ int lv_add_mirror_segment(struct alloc_handle *ah,
struct logical_volume *lv,
struct logical_volume **sub_lvs,
uint32_t mirrors,
const struct segment_type *segtype,
uint32_t status,
const struct segment_type *segtype __attribute((unused)),
uint32_t status __attribute((unused)),
uint32_t region_size,
struct logical_volume *log_lv)
{
@@ -1431,7 +1428,7 @@ int lv_extend(struct logical_volume *lv,
return lv_add_virtual_segment(lv, status, extents, segtype);
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors, 0,
extents, mirrored_pv, mirrored_pe, status,
extents, mirrored_pv, mirrored_pe,
allocatable_pvs, alloc, NULL))) {
stack;
return 0;
@@ -1556,7 +1553,7 @@ static int _for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv,
void *data)
{
struct lv_segment *seg;
int s;
uint32_t s;
list_iterate_items(seg, &lv->segments) {
if (seg->log_lv && !func(cmd, seg->log_lv, data))
@@ -1574,7 +1571,6 @@ static int _for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv,
/*
* Core of LV renaming routine.
* VG must be locked by caller.
* Returns 0 on failure, 1 on success.
*/
int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
const char *new_name)
@@ -1850,7 +1846,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
if (info.exists && (force == DONT_FORCE)) {
if (info.exists && (force == PROMPT)) {
if (yes_no_prompt("Do you really want to remove active "
"logical volume \"%s\"? [y/n]: ",
lv->name) == 'n') {

View File

@@ -107,9 +107,9 @@ typedef enum {
* Whether or not to force an operation.
*/
typedef enum {
DONT_FORCE = 0,
FORCE_NO_CONFIRM = 1, /* skip yes/no confirmation of operation */
FORCE_OVERRIDE = 2 /* skip confirmation and bypass a second condition */
PROMPT = 0, /* Issue yes/no prompt to confirm operation */
DONT_PROMPT = 1, /* Skip yes/no prompt */
DONT_PROMPT_OVERRIDE = 2 /* Skip prompt + override a second condition */
} force_t;
struct cmd_context;
@@ -323,13 +323,16 @@ pv_t *pv_create(const struct format_type *fmt,
int pv_resize(struct physical_volume *pv, struct volume_group *vg,
uint32_t new_pe_count);
int pv_analyze(struct cmd_context *cmd, const char *pv_name,
int64_t label_sector);
uint64_t label_sector);
struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
uint32_t extent_size, uint32_t max_pv,
uint32_t max_lv, alloc_policy_t alloc,
int pv_count, char **pv_names);
int vg_remove(struct volume_group *vg);
int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
force_t force);
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
const char *new_name);
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
@@ -427,9 +430,9 @@ int create_mirror_layers(struct alloc_handle *ah,
struct logical_volume *log_lv);
int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
struct list *removable_pvs, int remove_log);
struct list *removable_pvs, unsigned remove_log);
int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
struct list *removable_pvs, int remove_log);
struct list *removable_pvs, unsigned remove_log);
int insert_pvmove_mirrors(struct cmd_context *cmd,
struct logical_volume *lv_mirr,

View File

@@ -25,6 +25,7 @@
#include "activate.h"
#include "display.h"
#include "locking.h"
#include "archiver.h"
#include <sys/param.h>
@@ -248,6 +249,72 @@ int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
return 1;
}
int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
force_t force __attribute((unused)))
{
struct physical_volume *pv;
struct pv_list *pvl;
int ret = 1;
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 "
"is inconsistent.");
return 0;
}
if (!vg_check_status(vg, EXPORTED_VG))
return 0;
if (vg->lv_count) {
log_error("Volume group \"%s\" still contains %d "
"logical volume(s)", vg_name, vg->lv_count);
return 0;
}
if (!archive(vg))
return 0;
if (!vg_remove(vg)) {
log_error("vg_remove %s failed", vg_name);
return 0;
}
/* init physical volumes */
list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv_dev(pv)), vg_name);
pv->vg_name = ORPHAN;
pv->status = ALLOCATABLE_PV;
if (!dev_get_size(pv_dev(pv), &pv->size)) {
log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
ret = 0;
continue;
}
/* FIXME Write to same sector label was read from */
if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
dev_name(pv_dev(pv)), vg_name);
ret = 0;
}
}
backup_remove(cmd, vg_name);
if (ret)
log_print("Volume group \"%s\" successfully removed", vg_name);
else
log_error("Volume group \"%s\" not properly removed", vg_name);
return ret;
}
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
{
int i;
@@ -399,8 +466,8 @@ static int _recalc_extents(uint32_t *extents, const char *desc1,
return 1;
}
int vg_change_pesize(struct cmd_context *cmd, struct volume_group *vg,
uint32_t new_size)
int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
struct volume_group *vg, uint32_t new_size)
{
uint32_t old_size = vg->extent_size;
struct pv_list *pvl;
@@ -550,8 +617,8 @@ int vg_change_pesize(struct cmd_context *cmd, struct volume_group *vg,
return 1;
}
int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
struct volume_group *vg_to)
int vg_split_mdas(struct cmd_context *cmd __attribute((unused)),
struct volume_group *vg_from, struct volume_group *vg_to)
{
struct metadata_area *mda, *mda2;
struct list *mdas_from, *mdas_to;
@@ -1716,7 +1783,7 @@ int is_orphan(pv_t *pv)
* 1 - success
*/
int pv_analyze(struct cmd_context *cmd, const char *pv_name,
int64_t label_sector)
uint64_t label_sector)
{
struct label *label;
struct device *dev;

View File

@@ -118,7 +118,7 @@ static int _delete_lv(struct lv_segment *mirrored_seg, struct logical_volume *lv
* Reduce mirrored_seg to num_mirrors images.
*/
int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
struct list *removable_pvs, int remove_log)
struct list *removable_pvs, unsigned remove_log)
{
uint32_t m;
uint32_t extents;
@@ -255,7 +255,8 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
return 1;
}
static int get_mirror_fault_policy(struct cmd_context *cmd, int log_policy)
static int get_mirror_fault_policy(struct cmd_context *cmd __attribute((unused)),
int log_policy)
{
const char *policy;
@@ -347,7 +348,7 @@ static int replace_mirror_images(struct lv_segment *mirrored_seg,
}
int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
struct list *removable_pvs, int remove_log)
struct list *removable_pvs, unsigned remove_log)
{
int r;
int insync = 0;
@@ -416,7 +417,7 @@ static int _create_layers_for_mirror(struct alloc_handle *ah,
uint32_t first_area,
uint32_t num_mirrors,
struct logical_volume *lv,
const struct segment_type *segtype,
const struct segment_type *segtype __attribute((unused)),
struct logical_volume **img_lvs)
{
uint32_t m;
@@ -467,7 +468,7 @@ int create_mirror_layers(struct alloc_handle *ah,
uint32_t num_mirrors,
struct logical_volume *lv,
const struct segment_type *segtype,
uint32_t status,
uint32_t status __attribute((unused)),
uint32_t region_size,
struct logical_volume *log_lv)
{
@@ -508,7 +509,7 @@ int create_mirror_layers(struct alloc_handle *ah,
int add_mirror_layers(struct alloc_handle *ah,
uint32_t num_mirrors,
uint32_t existing_mirrors,
uint32_t existing_mirrors __attribute((unused)),
struct logical_volume *lv,
const struct segment_type *segtype)
{

View File

@@ -27,7 +27,7 @@ int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...)
n = vsnprintf(*buffer, *size, fmt, ap);
va_end(ap);
if (n < 0 || (n == *size))
if (n < 0 || ((size_t)n == *size))
return 0;
*buffer += n;
@@ -40,10 +40,10 @@ int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...)
*
* Returns:
* len - incremented for each char we encounter, whether 'c' or not.
* count - number of occurences of 'c'
* count - number of occurrences of 'c'
*/
void count_chars(const char *str, size_t *len, int *count,
const char c)
const int c)
{
const char *ptr;
@@ -56,18 +56,18 @@ void count_chars(const char *str, size_t *len, int *count,
* Count occurences of 'c' in 'str' of length 'size'.
*
* Returns:
* # of occurences of 'c'
* Number of occurrences of 'c'
*/
unsigned count_chars_len(const char *str, size_t size, const char c)
unsigned count_chars_len(const char *str, size_t len, const int c)
{
int i;
unsigned count=0;
size_t i;
unsigned count = 0;
for (i=0; i < size; i++)
for (i = 0; i < len; i++)
if (str[i] == c)
count++;
return count;
return count;
}
/*

View File

@@ -32,7 +32,7 @@ char *build_dm_name(struct dm_pool *mem, const char *vg,
int validate_name(const char *n);
void count_chars(const char *str, size_t *len, int *count,
char c);
unsigned count_chars_len(const char *str, size_t size, char c);
const int c);
unsigned count_chars_len(const char *str, size_t len, const int c);
#endif

View File

@@ -62,25 +62,25 @@ static char _alloc_policy_char(alloc_policy_t alloc)
/*
* Data-munging functions to prepare each data type for display and sorting
*/
static int _string_disp(struct dm_report *rh, struct dm_pool *mem,
static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
return dm_report_field_string(rh, field, (const char **) data);
}
static int _dev_name_disp(struct dm_report *rh, struct dm_pool *mem,
static int _dev_name_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const char *name = dev_name(*(const struct device **) data);
return dm_report_field_string(rh, field, &name);
}
static int _devices_disp(struct dm_report *rh, struct dm_pool *mem,
static int _devices_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct lv_segment *seg = (const struct lv_segment *) data;
unsigned int s;
@@ -141,9 +141,9 @@ static int _devices_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _tags_disp(struct dm_report *rh, struct dm_pool *mem,
static int _tags_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct list *tags = (const struct list *) data;
struct str_list *sl;
@@ -218,9 +218,9 @@ static int _pvfmt_disp(struct dm_report *rh, struct dm_pool *mem,
return _string_disp(rh, mem, field, &pv->fmt->name, private);
}
static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem,
static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info;
@@ -232,9 +232,9 @@ static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem,
return dm_report_field_uint64(rh, field, &minusone);
}
static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem,
static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info;
@@ -246,9 +246,9 @@ static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem,
return dm_report_field_uint64(rh, field, &minusone);
}
static int _lvstatus_disp(struct dm_report *rh, struct dm_pool *mem,
static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info;
@@ -331,9 +331,9 @@ static int _lvstatus_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _pvstatus_disp(struct dm_report *rh, struct dm_pool *mem,
static int _pvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const uint32_t status = *(const uint32_t *) data;
char *repstr;
@@ -357,9 +357,9 @@ static int _pvstatus_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _vgstatus_disp(struct dm_report *rh, struct dm_pool *mem,
static int _vgstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct volume_group *vg = (const struct volume_group *) data;
char *repstr;
@@ -401,9 +401,9 @@ static int _vgstatus_disp(struct dm_report *rh, struct dm_pool *mem,
}
static int _segtype_disp(struct dm_report *rh __attribute((unused)),
struct dm_pool *mem,
struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct lv_segment *seg = (const struct lv_segment *) data;
@@ -416,9 +416,9 @@ static int _segtype_disp(struct dm_report *rh __attribute((unused)),
return 1;
}
static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
static int _origin_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
@@ -430,9 +430,9 @@ static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem,
static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lv_segment *seg;
@@ -450,7 +450,7 @@ static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem,
static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
char *repstr, *lvname;
@@ -482,9 +482,9 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _movepv_disp(struct dm_report *rh, struct dm_pool *mem,
static int _movepv_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
const char *name;
@@ -501,7 +501,7 @@ static int _movepv_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _size32_disp(struct dm_report *rh, struct dm_pool *mem,
static int _size32_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
@@ -531,7 +531,8 @@ static int _size32_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _size64_disp(struct dm_report *rh, struct dm_pool *mem,
static int _size64_disp(struct dm_report *rh __attribute((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
@@ -684,9 +685,9 @@ static int _vgfree_disp(struct dm_report *rh, struct dm_pool *mem,
return _size64_disp(rh, mem, field, &freespace, private);
}
static int _uuid_disp(struct dm_report *rh, struct dm_pool *mem,
static int _uuid_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
char *repstr = NULL;
@@ -704,16 +705,16 @@ static int _uuid_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _uint32_disp(struct dm_report *rh, struct dm_pool *mem,
static int _uint32_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
return dm_report_field_uint32(rh, field, data);
}
static int _int32_disp(struct dm_report *rh, struct dm_pool *mem,
static int _int32_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
return dm_report_field_int32(rh, field, data);
}
@@ -756,9 +757,9 @@ static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem,
return _uint32_disp(rh, mem, field, &count, private);
}
static int _snpercent_disp(struct dm_report *rh, struct dm_pool *mem,
static int _snpercent_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info;
@@ -806,9 +807,9 @@ static int _snpercent_disp(struct dm_report *rh, struct dm_pool *mem,
return 1;
}
static int _copypercent_disp(struct dm_report *rh, struct dm_pool *mem,
static int _copypercent_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
const void *data, void *private __attribute((unused)))
{
struct logical_volume *lv = (struct logical_volume *) data;
float percent;

View File

@@ -128,7 +128,7 @@ static int _snap_target_present(const struct lv_segment *seg __attribute((unused
#endif
static int _snap_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg,
const struct lv_segment *seg __attribute((unused)),
struct list *modules)
{
if (!str_list_add(mem, modules, "snapshot")) {

View File

@@ -65,7 +65,7 @@ static int _zero_target_present(const struct lv_segment *seg __attribute((unused
#endif
static int _zero_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg,
const struct lv_segment *seg __attribute((unused)),
struct list *modules)
{
if (!str_list_add(mem, modules, "zero")) {

View File

@@ -48,7 +48,7 @@ DEFS += -DDEVICE_UID=@DEVICE_UID@ -DDEVICE_GID=@DEVICE_GID@ \
include ../make.tmpl
.PHONY: install_dynamic install_static install_include \
install_fs install_ioctl install_ioctl_static \
install_ioctl install_ioctl_static \
install_pkgconfig
INSTALL_TYPE = install_dynamic
@@ -74,10 +74,6 @@ install_dynamic: install_@interface@
install_static: install_@interface@_static
$(LN_S) -f libdevmapper.a.$(LIB_VERSION) $(libdir)/libdevmapper.a
install_fs: fs/libdevmapper.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
$(libdir)/libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
install_ioctl: ioctl/libdevmapper.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
$(libdir)/libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)

View File

@@ -3,7 +3,7 @@
lvconvert \- convert a logical volume from linear to mirror or snapshot
.SH SYNOPSIS
.B lvconvert
\-m/\-\-mirrors Mirrors [\-\-log {disk|core}] [\-\-corelog] [\-R/\-\-regionsize MirrorLogRegionSize]
\-m/\-\-mirrors Mirrors [\-\-mirrorlog {disk|core}] [\-\-corelog] [\-R/\-\-regionsize MirrorLogRegionSize]
[\-A/\-\-alloc AllocationPolicy]
[\-h/\-?/\-\-help]
[\-v/\-\-verbose]
@@ -37,10 +37,14 @@ For example, "-m 1" would convert the original logical
volume to a mirror volume with 2-sides; that is, a
linear volume plus one copy.
.TP
.I \-\-log disk/core
This optional argument switches the logging type of a
mirror. The logging type can be either "disk" (persistent)
or "core" (non-persistent). The default logging type is "disk".
.I \-\-mirrorlog {disk|core}
Specifies the type of log to use.
The default is disk, which is persistent and requires
a small amount of storage space, usually on a separate device
from the data being mirrored.
Core may be useful for short-lived mirrors: It means the mirror is
regenerated by copying the data from the first device again every
time the device is activated - perhaps, for example, after every reboot.
.TP
.I \-\-corelog
The optional argument "--corelog" is the same as specifying "--log core".

View File

@@ -11,7 +11,7 @@ lvcreate \- create a logical volume in an existing volume group
{\-l/\-\-extents LogicalExtentsNumber[%{VG|FREE}] |
\-L/\-\-size LogicalVolumeSize[kKmMgGtT]}
[\-M/\-\-persistent y/n] [\-\-minor minor]
[\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-log {disk|log}] [\-\-corelog]
[\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-mirrorlog {disk|log}] [\-\-corelog]
[\-R/\-\-regionsize MirrorLogRegionSize]]
[\-n/\-\-name LogicalVolumeName]
[\-p/\-\-permission r/rw] [\-r/\-\-readahead ReadAheadSectors]
@@ -85,25 +85,24 @@ Set the minor number.
Set to y to make the minor number specified persistent.
.TP
.I \-m, \-\-mirrors Mirrors
Creates a mirrored logical volume with "Mirrors" copies. For example,
Creates a mirrored logical volume with Mirrors copies. For example,
specifying "-m 1" would result in a mirror with two-sides; that is, a
linear volume plus one copy.
Specifying the optional argument "--nosync" will cause the creation
Specifying the optional argument --nosync will cause the creation
of the mirror to skip the initial resynchronization. Any data written
afterwards will be mirrored, but the original contents will not be
copied. This is useful for skipping a potentially long and resource
intensive initial sync.
intensive initial sync of an empty device.
The optional argument "--log" gives the ability to specify the type
of mirror log to be used. The available types are "disk" and "core",
where "disk" is the default. The "disk" log is persistent and requires
a small amount of storage space - usually on a separate device from the
mirror devices. While the "disk" log may cause the mirror to be slightly
slower during writes, it prevents the need to completely resynchronize
the mirror upon each instantiation (e.g. a reboot).
The optional argument --mirrorlog specifies the type of log to be used.
The default is disk, which is persistent and requires
a small amount of storage space, usually on a separate device from the
data being mirrored. Using core means the mirror is regenerated
by copying the data from the first device again each time the
device is activated, for example, after every reboot.
The optional argument "--corelog" is the same as specifying "--log core".
The optional argument --corelog is equivalent to --log core.
.TP
.I \-n, \-\-name LogicalVolumeName

View File

@@ -18,114 +18,114 @@
* corresponding short option first ...
*/
/* *INDENT-OFF* */
arg(version_ARG, '\0', "version", NULL)
arg(quiet_ARG, '\0', "quiet", NULL)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg)
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL)
arg(nolocking_ARG, '\0', "nolocking", NULL)
arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg)
arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg)
arg(restorefile_ARG, '\0', "restorefile", string_arg)
arg(labelsector_ARG, '\0', "labelsector", int_arg)
arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg)
arg(aligned_ARG, '\0', "aligned", NULL)
arg(unbuffered_ARG, '\0', "unbuffered", NULL)
arg(noheadings_ARG, '\0', "noheadings", NULL)
arg(segments_ARG, '\0', "segments", NULL)
arg(units_ARG, '\0', "units", string_arg)
arg(nosuffix_ARG, '\0', "nosuffix", NULL)
arg(removemissing_ARG, '\0', "removemissing", NULL)
arg(abort_ARG, '\0', "abort", NULL)
arg(addtag_ARG, '\0', "addtag", tag_arg)
arg(deltag_ARG, '\0', "deltag", tag_arg)
arg(refresh_ARG, '\0', "refresh", NULL)
arg(mknodes_ARG, '\0', "mknodes", NULL)
arg(minor_ARG, '\0', "minor", minor_arg)
arg(type_ARG, '\0', "type", segtype_arg)
arg(alloc_ARG, '\0', "alloc", alloc_arg)
arg(separator_ARG, '\0', "separator", string_arg)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL)
arg(nosync_ARG, '\0', "nosync", NULL)
arg(resync_ARG, '\0', "resync", NULL)
arg(corelog_ARG, '\0', "corelog", NULL)
arg(mirrorlog_ARG, '\0', "log", string_arg)
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)
arg(version_ARG, '\0', "version", NULL, 0)
arg(quiet_ARG, '\0', "quiet", NULL, 0)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
arg(nolocking_ARG, '\0', "nolocking", NULL, 0)
arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg, 0)
arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
arg(restorefile_ARG, '\0', "restorefile", string_arg, 0)
arg(labelsector_ARG, '\0', "labelsector", int_arg, 0)
arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg, 0)
arg(aligned_ARG, '\0', "aligned", NULL, 0)
arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
arg(noheadings_ARG, '\0', "noheadings", NULL, 0)
arg(segments_ARG, '\0', "segments", NULL, 0)
arg(units_ARG, '\0', "units", string_arg, 0)
arg(nosuffix_ARG, '\0', "nosuffix", NULL, 0)
arg(removemissing_ARG, '\0', "removemissing", NULL, 0)
arg(abort_ARG, '\0', "abort", NULL, 0)
arg(addtag_ARG, '\0', "addtag", tag_arg, 0)
arg(deltag_ARG, '\0', "deltag", tag_arg, 0)
arg(refresh_ARG, '\0', "refresh", NULL, 0)
arg(mknodes_ARG, '\0', "mknodes", NULL, 0)
arg(minor_ARG, '\0', "minor", minor_arg, 0)
arg(type_ARG, '\0', "type", segtype_arg, 0)
arg(alloc_ARG, '\0', "alloc", alloc_arg, 0)
arg(separator_ARG, '\0', "separator", string_arg, 0)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL, 0)
arg(nosync_ARG, '\0', "nosync", NULL, 0)
arg(resync_ARG, '\0', "resync", NULL, 0)
arg(corelog_ARG, '\0', "corelog", NULL, 0)
arg(mirrorlog_ARG, '\0', "mirrorlog", string_arg, 0)
arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0)
arg(config_ARG, '\0', "config", string_arg, 0)
arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
arg(allocation_ARG, '\0', "allocation", yes_no_arg)
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
arg(allocation_ARG, '\0', "allocation", yes_no_arg, 0)
/*
* ... and now the short args.
*/
arg(available_ARG, 'a', "available", yes_no_excl_arg)
arg(all_ARG, 'a', "all", NULL)
arg(autobackup_ARG, 'A', "autobackup", yes_no_arg)
arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL)
arg(background_ARG, 'b', "background", NULL)
arg(blockdevice_ARG, 'b', "blockdevice", NULL)
arg(chunksize_ARG, 'c', "chunksize", size_kb_arg)
arg(clustered_ARG, 'c', "clustered", yes_no_arg)
arg(colon_ARG, 'c', "colon", NULL)
arg(columns_ARG, 'C', "columns", NULL)
arg(contiguous_ARG, 'C', "contiguous", yes_no_arg)
arg(debug_ARG, 'd', "debug", NULL)
arg(disk_ARG, 'D', "disk", NULL)
arg(exported_ARG, 'e', "exported", NULL)
arg(physicalextent_ARG, 'E', "physicalextent", NULL)
arg(file_ARG, 'f', "file", string_arg)
arg(force_ARG, 'f', "force", NULL)
arg(full_ARG, 'f', "full", NULL)
arg(help_ARG, 'h', "help", NULL)
arg(help2_ARG, '?', "", NULL)
arg(stripesize_ARG, 'I', "stripesize", size_kb_arg)
arg(stripes_ARG, 'i', "stripes", int_arg)
arg(interval_ARG, 'i', "interval", int_arg)
arg(iop_version_ARG, 'i', "iop_version", NULL)
arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg)
arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg)
arg(extents_ARG, 'l', "extents", int_arg_with_sign_and_percent)
arg(lvmpartition_ARG, 'l', "lvmpartition", NULL)
arg(list_ARG, 'l', "list", NULL)
arg(size_ARG, 'L', "size", size_mb_arg)
arg(logicalextent_ARG, 'L', "logicalextent", int_arg_with_sign)
arg(persistent_ARG, 'M', "persistent", yes_no_arg)
arg(major_ARG, 'j', "major", major_arg)
arg(mirrors_ARG, 'm', "mirrors", int_arg_with_sign)
arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_arg)
arg(maps_ARG, 'm', "maps", NULL)
arg(name_ARG, 'n', "name", string_arg)
arg(oldpath_ARG, 'n', "oldpath", NULL)
arg(nofsck_ARG, 'n', "nofsck", NULL)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL)
arg(options_ARG, 'o', "options", string_arg)
arg(sort_ARG, 'O', "sort", string_arg)
arg(permission_ARG, 'p', "permission", permission_arg)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg)
arg(partial_ARG, 'P', "partial", NULL)
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL)
arg(readahead_ARG, 'r', "readahead", int_arg)
arg(resizefs_ARG, 'r', "resizefs", NULL)
arg(reset_ARG, 'R', "reset", NULL)
arg(regionsize_ARG, 'R', "regionsize", size_mb_arg)
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg)
arg(stdin_ARG, 's', "stdin", NULL)
arg(snapshot_ARG, 's', "snapshot", NULL)
arg(short_ARG, 's', "short", NULL)
arg(test_ARG, 't', "test", NULL)
arg(uuid_ARG, 'u', "uuid", NULL)
arg(uuidstr_ARG, 'u', "uuid", string_arg)
arg(uuidlist_ARG, 'U', "uuidlist", NULL)
arg(verbose_ARG, 'v', "verbose", NULL)
arg(volumegroup_ARG, 'V', "volumegroup", NULL)
arg(allocatable_ARG, 'x', "allocatable", yes_no_arg)
arg(resizeable_ARG, 'x', "resizeable", yes_no_arg)
arg(yes_ARG, 'y', "yes", NULL)
arg(zero_ARG, 'Z', "zero", yes_no_arg)
arg(available_ARG, 'a', "available", yes_no_excl_arg, 0)
arg(all_ARG, 'a', "all", NULL, 0)
arg(autobackup_ARG, 'A', "autobackup", yes_no_arg, 0)
arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL, 0)
arg(background_ARG, 'b', "background", NULL, 0)
arg(blockdevice_ARG, 'b', "blockdevice", NULL, 0)
arg(chunksize_ARG, 'c', "chunksize", size_kb_arg, 0)
arg(clustered_ARG, 'c', "clustered", yes_no_arg, 0)
arg(colon_ARG, 'c', "colon", NULL, 0)
arg(columns_ARG, 'C', "columns", NULL, 0)
arg(contiguous_ARG, 'C', "contiguous", yes_no_arg, 0)
arg(debug_ARG, 'd', "debug", NULL, ARG_REPEATABLE)
arg(disk_ARG, 'D', "disk", NULL, 0)
arg(exported_ARG, 'e', "exported", NULL, 0)
arg(physicalextent_ARG, 'E', "physicalextent", NULL, 0)
arg(file_ARG, 'f', "file", string_arg, 0)
arg(force_ARG, 'f', "force", NULL, ARG_REPEATABLE)
arg(full_ARG, 'f', "full", NULL, 0)
arg(help_ARG, 'h', "help", NULL, 0)
arg(help2_ARG, '?', "", NULL, 0)
arg(stripesize_ARG, 'I', "stripesize", size_kb_arg, 0)
arg(stripes_ARG, 'i', "stripes", int_arg, 0)
arg(interval_ARG, 'i', "interval", int_arg, 0)
arg(iop_version_ARG, 'i', "iop_version", NULL, 0)
arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg, 0)
arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg, 0)
arg(extents_ARG, 'l', "extents", int_arg_with_sign_and_percent, 0)
arg(lvmpartition_ARG, 'l', "lvmpartition", NULL, 0)
arg(list_ARG, 'l', "list", NULL, 0)
arg(size_ARG, 'L', "size", size_mb_arg, 0)
arg(logicalextent_ARG, 'L', "logicalextent", int_arg_with_sign, 0)
arg(persistent_ARG, 'M', "persistent", yes_no_arg, 0)
arg(major_ARG, 'j', "major", major_arg, 0)
arg(mirrors_ARG, 'm', "mirrors", int_arg_with_sign, 0)
arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_arg, 0)
arg(maps_ARG, 'm', "maps", NULL, 0)
arg(name_ARG, 'n', "name", string_arg, 0)
arg(oldpath_ARG, 'n', "oldpath", NULL, 0)
arg(nofsck_ARG, 'n', "nofsck", NULL, 0)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL, 0)
arg(options_ARG, 'o', "options", string_arg, 0)
arg(sort_ARG, 'O', "sort", string_arg, 0)
arg(permission_ARG, 'p', "permission", permission_arg, 0)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg, 0)
arg(partial_ARG, 'P', "partial", NULL, 0)
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL, 0)
arg(readahead_ARG, 'r', "readahead", int_arg, 0)
arg(resizefs_ARG, 'r', "resizefs", NULL, 0)
arg(reset_ARG, 'R', "reset", NULL, 0)
arg(regionsize_ARG, 'R', "regionsize", size_mb_arg, 0)
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg, 0)
arg(stdin_ARG, 's', "stdin", NULL, 0)
arg(snapshot_ARG, 's', "snapshot", NULL, 0)
arg(short_ARG, 's', "short", NULL, 0)
arg(test_ARG, 't', "test", NULL, 0)
arg(uuid_ARG, 'u', "uuid", NULL, 0)
arg(uuidstr_ARG, 'u', "uuid", string_arg, 0)
arg(uuidlist_ARG, 'U', "uuidlist", NULL, 0)
arg(verbose_ARG, 'v', "verbose", NULL, ARG_REPEATABLE)
arg(volumegroup_ARG, 'V', "volumegroup", NULL, 0)
arg(allocatable_ARG, 'x', "allocatable", yes_no_arg, 0)
arg(resizeable_ARG, 'x', "resizeable", yes_no_arg, 0)
arg(yes_ARG, 'y', "yes", NULL, 0)
arg(zero_ARG, 'Z', "zero", yes_no_arg, 0)
/* this should always be last */
arg(ARG_COUNT, '-', "", NULL)
arg(ARG_COUNT, '-', "", NULL, 0)
/* *INDENT-ON* */

View File

@@ -88,7 +88,7 @@ xx(lvchange,
xx(lvconvert,
"Change logical volume layout",
"lvconvert "
"[-m|--mirrors Mirrors [--log {disk|core}]]\n"
"[-m|--mirrors Mirrors [{--mirrorlog {disk|core}|--corelog}]]\n"
"\t[-R|--regionsize MirrorLogRegionSize]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-d|--debug]\n"
@@ -107,7 +107,7 @@ xx(lvconvert,
"\t[--version]" "\n"
"\tOriginalLogicalVolume[Path] SnapshotLogicalVolume[Path]\n",
alloc_ARG, chunksize_ARG, mirrors_ARG, corelog_ARG, mirrorlog_ARG,
alloc_ARG, chunksize_ARG, corelog_ARG, mirrorlog_ARG, mirrors_ARG,
regionsize_ARG, snapshot_ARG, test_ARG, zero_ARG)
xx(lvcreate,
@@ -123,7 +123,7 @@ xx(lvcreate,
"\t{-l|--extents LogicalExtentsNumber |\n"
"\t -L|--size LogicalVolumeSize[kKmMgGtTpPeE]}\n"
"\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n"
"\t[-m|--mirrors Mirrors [--nosync] [--log {disk|core}]]\n"
"\t[-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core}|--corelog}]]\n"
"\t[-n|--name LogicalVolumeName]\n"
"\t[-p|--permission {r|rw}]\n"
"\t[-r|--readahead ReadAheadSectors]\n"
@@ -156,10 +156,10 @@ xx(lvcreate,
"\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
corelog_ARG, mirrorlog_ARG, extents_ARG, major_ARG, minor_ARG, mirrors_ARG, name_ARG,
nosync_ARG, permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG,
size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, type_ARG,
zero_ARG)
corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
name_ARG, nosync_ARG, permission_ARG, persistent_ARG, readahead_ARG,
regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG,
test_ARG, type_ARG, zero_ARG)
xx(lvdisplay,
"Display information about a logical volume",

View File

@@ -101,29 +101,13 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
int argc, char **argv)
{
int count = 0;
int region_size;
int pagesize = lvm_getpagesize();
memset(lp, 0, sizeof(*lp));
if (arg_count(cmd, mirrorlog_ARG) > 1) {
log_error("Too many --log arguments supplied.");
return 0;
}
if (arg_count(cmd, mirrors_ARG) > 1) {
log_error("Too many --mirrors arguments supplied.");
return 0;
}
if (arg_count(cmd, snapshot_ARG) > 1) {
log_error("Too many --snapshot arguments supplied.");
return 0;
}
if (arg_count(cmd, mirrorlog_ARG) || arg_count(cmd, mirrors_ARG))
count = 1;
count += arg_count(cmd, snapshot_ARG);
if (count != 1) {
if (arg_count(cmd, snapshot_ARG) &&
(arg_count(cmd, mirrorlog_ARG) || arg_count(cmd, mirrors_ARG))) {
log_error("--snapshots argument cannot be mixed "
"with --mirrors or --log");
return 0;
@@ -224,7 +208,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return 0;
}
if (!(lp->segtype = get_segtype_from_string(cmd, "striped")))
if (!(lp->segtype = get_segtype_from_string(cmd, "mirror")))
return_0;
}
@@ -252,13 +236,12 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
struct alloc_handle *ah = NULL;
struct logical_volume *log_lv;
struct list *parallel_areas;
struct segment_type *segtype; /* FIXME: could I just use lp->segtype */
float sync_percent;
const char *log_arg;
int corelog = 0;
const char *mirrorlog;
unsigned corelog = 0;
seg = first_seg(lv);
existing_mirrors = seg->area_count;
existing_mirrors = (lv->status & MIRRORED) ? seg->area_count : 1;
/*
* Adjust required number of mirrors
@@ -289,25 +272,26 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
/*
* Adjust log type
*/
if (arg_count(cmd, corelog_ARG)) {
log_verbose("Setting logging type to \"core\"");
if (arg_count(cmd, corelog_ARG))
corelog = 1;
}
if (arg_count(cmd, mirrorlog_ARG)) {
log_arg = arg_str_value(cmd, mirrorlog_ARG, "disk");
if (!strcmp("disk", log_arg)) {
log_verbose("Setting logging type to \"disk\"");
corelog = 0;
} else if (!strcmp("core", log_arg)) {
log_verbose("Setting logging type to \"core\"");
corelog = 1;
} else {
log_error("Unknown logging type, \"%s\"", log_arg);
mirrorlog = arg_str_value(cmd, mirrorlog_ARG, DEFAULT_MIRRORLOG);
if (!strcmp("disk", mirrorlog)) {
if (corelog) {
log_error("--mirrorlog disk and --corelog "
"are incompatible");
return 0;
}
corelog = 0;
} else if (!strcmp("core", mirrorlog))
corelog = 1;
else {
log_error("Unknown mirrorlog type: %s", mirrorlog);
return 0;
}
log_verbose("Setting logging type to %s", mirrorlog);
/*
* Region size must not change on existing mirrors
*/
@@ -353,9 +337,9 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
if (!(ah = allocate_extents(lv->vg, NULL, lp->segtype,
1, lp->mirrors - 1,
corelog ? 0 : 1,
lv->le_count * (lp->mirrors - 1),
NULL, 0, 0, lp->pvh,
corelog ? 0U : 1U,
lv->le_count,
NULL, 0, lp->pvh,
lp->alloc,
parallel_areas)))
return_0;
@@ -401,11 +385,9 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
return 0;
}
segtype = get_segtype_from_string(cmd, "striped");
if (!(ah = allocate_extents(lv->vg, NULL, segtype, 0,
if (!(ah = allocate_extents(lv->vg, NULL, lp->segtype, 0,
0, 1, 0,
NULL, 0, 0, lp->pvh,
NULL, 0, lp->pvh,
lp->alloc,
parallel_areas))) {
stack;
@@ -518,7 +500,7 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
if (!lp->zero || !(lv->status & LVM_WRITE))
log_warn("WARNING: \"%s\" not zeroed", lv->name);
else if (!set_lv(cmd, lv, 0, 0)) {
else if (!set_lv(cmd, lv, UINT64_C(0), 0)) {
log_error("Aborting. Failed to wipe snapshot "
"exception store.");
return 0;

View File

@@ -241,7 +241,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
int argc = *pargc;
int region_size;
int pagesize = lvm_getpagesize();
const char *log_arg;
const char *mirrorlog;
if (argc && (unsigned) argc < lp->mirrors) {
log_error("Too few physical volumes on "
@@ -285,25 +285,26 @@ static int _read_mirror_params(struct lvcreate_params *lp,
return 0;
}
if (arg_count(cmd, corelog_ARG)) {
log_verbose("Setting logging type to \"core\"");
if (arg_count(cmd, corelog_ARG))
lp->corelog = 1;
}
if (arg_count(cmd, mirrorlog_ARG)) {
log_arg = arg_str_value(cmd, mirrorlog_ARG, "disk");
if (!strcmp("disk", log_arg)) {
log_verbose("Setting logging type to \"disk\"");
lp->corelog = 0;
} else if (!strcmp("core", log_arg)) {
log_verbose("Setting logging type to \"core\"");
lp->corelog = 1;
} else {
log_error("Unknown logging type, \"%s\"", log_arg);
mirrorlog = arg_str_value(cmd, mirrorlog_ARG, DEFAULT_MIRRORLOG);
if (!strcmp("disk", mirrorlog)) {
if (lp->corelog) {
log_error("--mirrorlog disk and --corelog "
"are incompatible");
return 0;
}
lp->corelog = 0;
} else if (!strcmp("core", mirrorlog))
lp->corelog = 1;
else {
log_error("Unknown mirrorlog type: %s", mirrorlog);
return 0;
}
log_verbose("Setting logging type to %s", mirrorlog);
lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
return 1;
@@ -571,7 +572,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
log_error("Volume too large (%s) for extent size %s. "
"Upper limit is %s.",
display_size(cmd, tmp_size),
display_size(cmd, vg->extent_size),
display_size(cmd, (uint64_t) vg->extent_size),
display_size(cmd, (uint64_t) UINT32_MAX *
vg->extent_size));
return 0;
@@ -706,8 +707,8 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
/* FIXME Calculate how many extents needed for the log */
if (!(ah = allocate_extents(vg, NULL, lp->segtype, lp->stripes,
lp->mirrors, lp->corelog ? 0 : 1,
lp->extents, NULL, 0, 0,
lp->mirrors, lp->corelog ? 0U : 1U,
lp->extents, NULL, 0,
pvh, lp->alloc, NULL))) {
stack;
return 0;
@@ -803,7 +804,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
}
if ((lp->zero || lp->snapshot) && activation()) {
if (!set_lv(cmd, lv, 0, 0) && lp->snapshot) {
if (!set_lv(cmd, lv, UINT64_C(0), 0) && lp->snapshot) {
/* FIXME Remove the failed lv we just added */
log_error("Aborting. Failed to wipe snapshot "
"exception store. Remove new LV and retry.");

View File

@@ -45,7 +45,7 @@ extern char *optarg;
* Table of valid switches
*/
static struct arg _the_args[ARG_COUNT + 1] = {
#define arg(a, b, c, d) {b, "", "--" c, d, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), SIGN_NONE, PERCENT_NONE, NULL},
#define arg(a, b, c, d, e) {b, "", "--" c, d, e, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), SIGN_NONE, PERCENT_NONE, NULL},
#include "args.h"
#undef arg
};
@@ -568,16 +568,16 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
return 0;
}
if (a->fn) {
if (a->count) {
log_error("Option%s%c%s%s may not be repeated",
a->short_arg ? " -" : "",
a->short_arg ? : ' ',
(a->short_arg && a->long_arg) ?
"/" : "", a->long_arg ? : "");
return 0;
}
if (a->count && !(a->flags & ARG_REPEATABLE)) {
log_error("Option%s%c%s%s may not be repeated",
a->short_arg ? " -" : "",
a->short_arg ? : ' ',
(a->short_arg && a->long_arg) ?
"/" : "", a->long_arg ? : "");
return 0;
}
if (a->fn) {
if (!optarg) {
log_error("Option requires argument.");
return 0;

View File

@@ -32,7 +32,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
log_verbose("Scanning %s", argv[i]);
pv_analyze(cmd, argv[i],
arg_int64_value(cmd, labelsector_ARG,
arg_uint64_value(cmd, labelsector_ARG,
UINT64_C(0)));
}

View File

@@ -124,12 +124,19 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
arg_count(cmd, exported_ARG) ?
"of exported volume group(s)" : "in no volume group");
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
persistent_filter_wipe(cmd->filter);
lvmcache_destroy();
log_verbose("Walking through all physical volumes");
if (!(pvslist = get_pvs(cmd)))
if (!(pvslist = get_pvs(cmd))) {
unlock_vg(cmd, VG_GLOBAL);
return ECMD_FAILED;
}
/* eliminate exported/new if required */
list_iterate_items(pvl, pvslist) {
@@ -181,6 +188,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
if (!pvs_found) {
log_print("No matching physical volumes found");
unlock_vg(cmd, VG_GLOBAL);
return ECMD_PROCESSED;
}
@@ -191,5 +199,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
display_size(cmd, (size_total - size_new)),
new_pvs_found, display_size(cmd, size_new));
unlock_vg(cmd, VG_GLOBAL);
return ECMD_PROCESSED;
}

View File

@@ -134,7 +134,8 @@ out:
}
static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
struct volume_group *vg,
int consistent __attribute((unused)),
void *handle)
{
if (!vg) {
@@ -146,7 +147,8 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
}
static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
struct volume_group *vg,
int consistent __attribute((unused)),
void *handle)
{
if (!vg) {

View File

@@ -221,7 +221,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
}
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
int lock_type, void *handle,
uint32_t lock_type, void *handle,
int (*process_single) (struct cmd_context * cmd,
struct logical_volume * lv,
void *handle))
@@ -392,7 +392,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
list_init(&lvnames);
break;
} else if (!strncmp(vg_name, vgname, strlen(vgname)) &&
strlen(vgname) == lv_name - vg_name) {
strlen(vgname) == (size_t) (lv_name - vg_name)) {
if (!str_list_add(cmd->mem, &lvnames,
dm_pool_strdup(cmd->mem,
lv_name + 1))) {
@@ -463,7 +463,7 @@ int process_each_segment_in_lv(struct cmd_context *cmd,
static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
const char *vgid,
struct list *tags, struct list *arg_vgnames,
int lock_type, int consistent, void *handle,
uint32_t lock_type, int consistent, void *handle,
int ret_max,
int (*process_single) (struct cmd_context * cmd,
const char *vg_name,
@@ -513,7 +513,7 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
}
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int lock_type, int consistent, void *handle,
uint32_t lock_type, int consistent, void *handle,
int (*process_single) (struct cmd_context * cmd,
const char *vg_name,
struct volume_group * vg,
@@ -1133,7 +1133,7 @@ struct list *clone_pv_list(struct dm_pool *mem, struct list *pvsl)
* Attempt metadata recovery
*/
struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
int lock_type)
uint32_t lock_type)
{
int consistent = 1;

View File

@@ -24,10 +24,10 @@ int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
int autobackup(struct volume_group *vg);
struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
int lock_type);
uint32_t lock_type);
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int lock_type, int consistent, void *handle,
uint32_t lock_type, int consistent, void *handle,
int (*process_single) (struct cmd_context * cmd,
const char *vg_name,
struct volume_group * vg,
@@ -49,7 +49,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
void *handle));
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
int lock_type, void *handle,
uint32_t lock_type, void *handle,
int (*process_single) (struct cmd_context * cmd,
struct logical_volume * lv,
void *handle));

View File

@@ -68,7 +68,7 @@ typedef int (*command_fn) (struct cmd_context * cmd, int argc, char **argv);
/* define the enums for the command line switches */
enum {
#define arg(a, b, c, d) a ,
#define arg(a, b, c, d, e) a ,
#include "args.h"
#undef arg
};
@@ -94,6 +94,8 @@ enum {
CHANGE_ALN = 4
};
#define ARG_REPEATABLE 0x00000001
/* a global table of possible arguments */
struct arg {
const char short_arg;
@@ -101,6 +103,7 @@ struct arg {
const char *long_arg;
int (*fn) (struct cmd_context * cmd, struct arg * a);
uint32_t flags;
unsigned count;
char *value;

View File

@@ -301,7 +301,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
}
}
if ((mimages != mirrored_seg->area_count) || (remove_log)){
if ((mimages != mirrored_seg->area_count) || remove_log){
if (!reconfigure_mirror_images(mirrored_seg, mimages,
NULL, remove_log)) {
stack;

View File

@@ -19,66 +19,11 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
void *handle __attribute((unused)))
{
struct physical_volume *pv;
struct pv_list *pvl;
int ret = ECMD_PROCESSED;
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 "
"is inconsistent.");
return ECMD_FAILED;
}
if (!vg_check_status(vg, EXPORTED_VG))
if (!vg_remove_single(cmd, vg_name, vg, consistent,
arg_count(cmd, force_ARG)))
return ECMD_FAILED;
if (vg->lv_count) {
log_error("Volume group \"%s\" still contains %d "
"logical volume(s)", vg_name, vg->lv_count);
return ECMD_FAILED;
}
if (!archive(vg))
return ECMD_FAILED;
if (!vg_remove(vg)) {
log_error("vg_remove %s failed", vg_name);
return ECMD_FAILED;
}
/* init physical volumes */
list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv_dev(pv)), vg_name);
pv->vg_name = ORPHAN;
pv->status = ALLOCATABLE_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;
}
/* FIXME Write to same sector label was read from */
if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
dev_name(pv_dev(pv)), vg_name);
ret = ECMD_FAILED;
}
}
backup_remove(cmd, vg_name);
if (ret == ECMD_PROCESSED)
log_print("Volume group \"%s\" successfully removed", vg_name);
else
log_error("Volume group \"%s\" not properly removed", vg_name);
return ret;
return ECMD_PROCESSED;
}
int vgremove(struct cmd_context *cmd, int argc, char **argv)

View File

@@ -51,6 +51,11 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
persistent_filter_wipe(cmd->filter);
lvmcache_destroy();
@@ -65,5 +70,6 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
maxret = ret;
}
unlock_vg(cmd, VG_GLOBAL);
return maxret;
}

View File

@@ -173,7 +173,7 @@ static int _move_mirrors(struct volume_group *vg_from,
struct list *lvh, *lvht;
struct logical_volume *lv;
struct lv_segment *seg;
int i, seg_in, log_in;
unsigned s, seg_in, log_in;
list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = list_item(lvh, struct lv_list)->lv;
@@ -184,8 +184,8 @@ static int _move_mirrors(struct volume_group *vg_from,
seg = first_seg(lv);
seg_in = 0;
for (i = 0; i < seg->area_count; i++)
if (_lv_is_in_vg(vg_to, seg_lv(seg, i)))
for (s = 0; s < seg->area_count; s++)
if (_lv_is_in_vg(vg_to, seg_lv(seg, s)))
seg_in++;
log_in = (!seg->log_lv || _lv_is_in_vg(vg_to, seg->log_lv));