mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-25 18:50:51 +03:00
Add per-command flags to control which commands use the VG metadata cache.
This commit is contained in:
parent
cbfbc6766e
commit
bf7dea978e
@ -1,5 +1,6 @@
|
||||
Version 2.02.34 -
|
||||
===================================
|
||||
Add per-command flags to control which commands use the VG metadata cache.
|
||||
Fix vgsplit locking, remove unneeded error messages when split into new VG.
|
||||
Suppress duplicate message when lvresize fails because of invalid vgname.
|
||||
Cache VG metadata internally while VG lock is held.
|
||||
|
3
lib/cache/lvmcache.c
vendored
3
lib/cache/lvmcache.c
vendored
@ -868,7 +868,8 @@ int lvmcache_update_vg(struct volume_group *vg, unsigned precommitted)
|
||||
}
|
||||
|
||||
/* store text representation of vg to cache */
|
||||
if ((vginfo = vginfo_from_vgname(vg->name, NULL)))
|
||||
if (vg->cmd->current_settings.cache_vgmetadata &&
|
||||
(vginfo = vginfo_from_vgname(vg->name, NULL)))
|
||||
_store_metadata(vginfo, vg, precommitted);
|
||||
|
||||
return 1;
|
||||
|
@ -34,6 +34,7 @@ struct config_info {
|
||||
int archive; /* should we archive ? */
|
||||
int backup; /* should we backup ? */
|
||||
int read_ahead; /* DM_READ_AHEAD_NONE or _AUTO */
|
||||
int cache_vgmetadata;
|
||||
const char *msg_prefix;
|
||||
struct format_type *fmt;
|
||||
uint64_t unit_factor;
|
||||
|
@ -30,6 +30,7 @@ xx(e2fsadm,
|
||||
|
||||
xx(dumpconfig,
|
||||
"Dump active configuration",
|
||||
0,
|
||||
"dumpconfig "
|
||||
"\t[-f|--file filename] " "\n"
|
||||
"[ConfigurationVariable...]\n",
|
||||
@ -37,10 +38,12 @@ xx(dumpconfig,
|
||||
|
||||
xx(formats,
|
||||
"List available metadata formats",
|
||||
0,
|
||||
"formats\n")
|
||||
|
||||
xx(help,
|
||||
"Display help for commands",
|
||||
0,
|
||||
"help <command>" "\n")
|
||||
|
||||
/*********
|
||||
@ -55,6 +58,7 @@ xx(lvactivate,
|
||||
|
||||
xx(lvchange,
|
||||
"Change the attributes of logical volume(s)",
|
||||
CACHE_VGMETADATA,
|
||||
"lvchange\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-a|--available [e|l]y|n]\n"
|
||||
@ -87,6 +91,7 @@ xx(lvchange,
|
||||
|
||||
xx(lvconvert,
|
||||
"Change logical volume layout",
|
||||
0,
|
||||
"lvconvert "
|
||||
"[-m|--mirrors Mirrors [{--mirrorlog {disk|core}|--corelog}]]\n"
|
||||
"\t[-R|--regionsize MirrorLogRegionSize]\n"
|
||||
@ -114,6 +119,7 @@ xx(lvconvert,
|
||||
|
||||
xx(lvcreate,
|
||||
"Create a logical volume",
|
||||
0,
|
||||
"lvcreate " "\n"
|
||||
"\t[-A|--autobackup {y|n}]\n"
|
||||
"\t[--addtag Tag]\n"
|
||||
@ -165,6 +171,7 @@ xx(lvcreate,
|
||||
|
||||
xx(lvdisplay,
|
||||
"Display information about a logical volume",
|
||||
0,
|
||||
"lvdisplay\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-c|--colon]\n"
|
||||
@ -205,6 +212,7 @@ xx(lvdisplay,
|
||||
|
||||
xx(lvextend,
|
||||
"Add space to a logical volume",
|
||||
0,
|
||||
"lvextend\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[--alloc AllocationPolicy]\n"
|
||||
@ -228,6 +236,7 @@ xx(lvextend,
|
||||
|
||||
xx(lvmchange,
|
||||
"With the device mapper, this is obsolete and does nothing.",
|
||||
0,
|
||||
"lvmchange\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -239,6 +248,7 @@ xx(lvmchange,
|
||||
|
||||
xx(lvmdiskscan,
|
||||
"List devices that may be used as physical volumes",
|
||||
0,
|
||||
"lvmdiskscan\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -249,6 +259,7 @@ xx(lvmdiskscan,
|
||||
|
||||
xx(lvmsadc,
|
||||
"Collect activity data",
|
||||
0,
|
||||
"lvmsadc\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -258,6 +269,7 @@ xx(lvmsadc,
|
||||
|
||||
xx(lvmsar,
|
||||
"Create activity report",
|
||||
0,
|
||||
"lvmsar\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--full]\n"
|
||||
@ -271,6 +283,7 @@ xx(lvmsar,
|
||||
|
||||
xx(lvreduce,
|
||||
"Reduce the size of a logical volume",
|
||||
0,
|
||||
"lvreduce\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
@ -291,6 +304,7 @@ xx(lvreduce,
|
||||
|
||||
xx(lvremove,
|
||||
"Remove logical volume(s) from the system",
|
||||
0,
|
||||
"lvremove\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
@ -305,6 +319,7 @@ xx(lvremove,
|
||||
|
||||
xx(lvrename,
|
||||
"Rename a logical volume",
|
||||
0,
|
||||
"lvrename "
|
||||
"\t[-A|--autobackup {y|n}] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
@ -319,6 +334,7 @@ xx(lvrename,
|
||||
|
||||
xx(lvresize,
|
||||
"Resize a logical volume",
|
||||
0,
|
||||
"lvresize\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[--alloc AllocationPolicy]\n"
|
||||
@ -340,6 +356,7 @@ xx(lvresize,
|
||||
|
||||
xx(lvs,
|
||||
"Display information about logical volumes",
|
||||
0,
|
||||
"lvs" "\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[--aligned]\n"
|
||||
@ -366,6 +383,7 @@ xx(lvs,
|
||||
|
||||
xx(lvscan,
|
||||
"List all logical volumes in all volume groups",
|
||||
0,
|
||||
"lvscan " "\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-b|--blockdevice] " "\n"
|
||||
@ -380,6 +398,7 @@ xx(lvscan,
|
||||
|
||||
xx(pvchange,
|
||||
"Change attributes of physical volume(s)",
|
||||
0,
|
||||
"pvchange\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
@ -399,6 +418,7 @@ xx(pvchange,
|
||||
|
||||
xx(pvresize,
|
||||
"Resize physical volume(s)",
|
||||
0,
|
||||
"pvresize " "\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
@ -412,6 +432,7 @@ xx(pvresize,
|
||||
|
||||
xx(pvck,
|
||||
"Check the consistency of physical volume(s)",
|
||||
0,
|
||||
"pvck "
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -424,6 +445,7 @@ xx(pvck,
|
||||
|
||||
xx(pvcreate,
|
||||
"Initialize physical volume(s) for use by LVM",
|
||||
0,
|
||||
"pvcreate " "\n"
|
||||
"\t[--restorefile file]\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
@ -448,6 +470,7 @@ xx(pvcreate,
|
||||
|
||||
xx(pvdata,
|
||||
"Display the on-disk metadata for physical volume(s)",
|
||||
0,
|
||||
"pvdata " "\n"
|
||||
"\t[-a|--all] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
@ -466,6 +489,7 @@ xx(pvdata,
|
||||
|
||||
xx(pvdisplay,
|
||||
"Display various attributes of physical volume(s)",
|
||||
0,
|
||||
"pvdisplay\n"
|
||||
"\t[-c|--colon]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
@ -502,6 +526,7 @@ xx(pvdisplay,
|
||||
|
||||
xx(pvmove,
|
||||
"Move extents from one physical volume to another",
|
||||
0,
|
||||
"pvmove " "\n"
|
||||
"\t[--abort]\n"
|
||||
"\t[-A|--autobackup {y|n}]\n"
|
||||
@ -523,6 +548,7 @@ xx(pvmove,
|
||||
|
||||
xx(pvremove,
|
||||
"Remove LVM label(s) from physical volume(s)",
|
||||
0,
|
||||
"pvremove " "\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-f[f]|--force [--force]] " "\n"
|
||||
@ -537,6 +563,7 @@ xx(pvremove,
|
||||
|
||||
xx(pvs,
|
||||
"Display information about physical volumes",
|
||||
0,
|
||||
"pvs" "\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-a|--all]\n"
|
||||
@ -563,6 +590,7 @@ xx(pvs,
|
||||
|
||||
xx(pvscan,
|
||||
"List all physical volumes",
|
||||
0,
|
||||
"pvscan " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t{-e|--exported | -n|--novolumegroup} " "\n"
|
||||
@ -579,10 +607,12 @@ xx(pvscan,
|
||||
|
||||
xx(segtypes,
|
||||
"List available segment types",
|
||||
0,
|
||||
"segtypes\n")
|
||||
|
||||
xx(vgcfgbackup,
|
||||
"Backup volume group configuration(s)",
|
||||
0,
|
||||
"vgcfgbackup " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-f|--file filename] " "\n"
|
||||
@ -597,6 +627,7 @@ xx(vgcfgbackup,
|
||||
|
||||
xx(vgcfgrestore,
|
||||
"Restore volume group configuration",
|
||||
0,
|
||||
"vgcfgrestore " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-f|--file filename] " "\n"
|
||||
@ -613,6 +644,7 @@ xx(vgcfgrestore,
|
||||
|
||||
xx(vgchange,
|
||||
"Change volume group attributes",
|
||||
CACHE_VGMETADATA,
|
||||
"vgchange" "\n"
|
||||
"\t[-A|--autobackup {y|n}] " "\n"
|
||||
"\t[--alloc AllocationPolicy] " "\n"
|
||||
@ -643,6 +675,7 @@ xx(vgchange,
|
||||
|
||||
xx(vgck,
|
||||
"Check the consistency of volume group(s)",
|
||||
0,
|
||||
"vgck "
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -652,6 +685,7 @@ xx(vgck,
|
||||
|
||||
xx(vgconvert,
|
||||
"Change volume group metadata format",
|
||||
0,
|
||||
"vgconvert " "\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
@ -669,6 +703,7 @@ xx(vgconvert,
|
||||
|
||||
xx(vgcreate,
|
||||
"Create a volume group",
|
||||
0,
|
||||
"vgcreate" "\n"
|
||||
"\t[-A|--autobackup {y|n}] " "\n"
|
||||
"\t[--addtag Tag] " "\n"
|
||||
@ -690,6 +725,7 @@ xx(vgcreate,
|
||||
|
||||
xx(vgdisplay,
|
||||
"Display volume group information",
|
||||
0,
|
||||
"vgdisplay " "\n"
|
||||
"\t[-c|--colon | -s|--short | -v|--verbose]" "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
@ -725,6 +761,7 @@ xx(vgdisplay,
|
||||
|
||||
xx(vgexport,
|
||||
"Unregister volume group(s) from the system",
|
||||
0,
|
||||
"vgexport " "\n"
|
||||
"\t[-a|--all] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
@ -737,6 +774,7 @@ xx(vgexport,
|
||||
|
||||
xx(vgextend,
|
||||
"Add physical volumes to a volume group",
|
||||
0,
|
||||
"vgextend\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
@ -750,6 +788,7 @@ xx(vgextend,
|
||||
|
||||
xx(vgimport,
|
||||
"Register exported volume group with system",
|
||||
0,
|
||||
"vgimport " "\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
@ -764,6 +803,7 @@ xx(vgimport,
|
||||
|
||||
xx(vgmerge,
|
||||
"Merge volume groups",
|
||||
0,
|
||||
"vgmerge\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
@ -778,6 +818,7 @@ xx(vgmerge,
|
||||
|
||||
xx(vgmknodes,
|
||||
"Create the special files for volume group devices in /dev",
|
||||
0,
|
||||
"vgmknodes\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -790,6 +831,7 @@ xx(vgmknodes,
|
||||
|
||||
xx(vgreduce,
|
||||
"Remove physical volume(s) from a volume group",
|
||||
0,
|
||||
"vgreduce\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
@ -807,6 +849,7 @@ xx(vgreduce,
|
||||
|
||||
xx(vgremove,
|
||||
"Remove volume group(s)",
|
||||
0,
|
||||
"vgremove\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--force]\n"
|
||||
@ -820,6 +863,7 @@ xx(vgremove,
|
||||
|
||||
xx(vgrename,
|
||||
"Rename a volume group",
|
||||
0,
|
||||
"vgrename\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
@ -834,6 +878,7 @@ xx(vgrename,
|
||||
|
||||
xx(vgs,
|
||||
"Display information about volume groups",
|
||||
0,
|
||||
"vgs" "\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-a|--all]\n"
|
||||
@ -859,6 +904,7 @@ xx(vgs,
|
||||
|
||||
xx(vgscan,
|
||||
"Search for all volume groups",
|
||||
0,
|
||||
"vgscan "
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
@ -872,6 +918,7 @@ xx(vgscan,
|
||||
|
||||
xx(vgsplit,
|
||||
"Move physical volumes into a new or existing volume group",
|
||||
0,
|
||||
"vgsplit " "\n"
|
||||
"\t[-A|--autobackup {y|n}] " "\n"
|
||||
"\t[--alloc AllocationPolicy] " "\n"
|
||||
@ -893,5 +940,6 @@ xx(vgsplit,
|
||||
|
||||
xx(version,
|
||||
"Display software and driver version information",
|
||||
0,
|
||||
"version\n" )
|
||||
|
||||
|
@ -421,6 +421,7 @@ static void _alloc_command(void)
|
||||
}
|
||||
|
||||
static void _create_new_command(const char *name, command_fn command,
|
||||
unsigned flags,
|
||||
const char *desc, const char *usagestr,
|
||||
int nargs, int *args)
|
||||
{
|
||||
@ -434,12 +435,13 @@ static void _create_new_command(const char *name, command_fn command,
|
||||
nc->desc = desc;
|
||||
nc->usage = usagestr;
|
||||
nc->fn = command;
|
||||
nc->flags = flags;
|
||||
nc->num_args = nargs;
|
||||
nc->valid_args = args;
|
||||
}
|
||||
|
||||
static void _register_command(const char *name, command_fn fn,
|
||||
const char *desc, const char *usagestr, ...)
|
||||
static void _register_command(const char *name, command_fn fn, const char *desc,
|
||||
unsigned flags, const char *usagestr, ...)
|
||||
{
|
||||
int nargs = 0, i;
|
||||
int *args;
|
||||
@ -464,16 +466,16 @@ static void _register_command(const char *name, command_fn fn,
|
||||
va_end(ap);
|
||||
|
||||
/* enter the command in the register */
|
||||
_create_new_command(name, fn, desc, usagestr, nargs, args);
|
||||
_create_new_command(name, fn, flags, desc, usagestr, nargs, args);
|
||||
}
|
||||
|
||||
void lvm_register_commands(void)
|
||||
{
|
||||
#define xx(a, b, c...) _register_command(# a, a, b, ## c, \
|
||||
driverloaded_ARG, \
|
||||
debug_ARG, help_ARG, help2_ARG, \
|
||||
version_ARG, verbose_ARG, \
|
||||
quiet_ARG, config_ARG, -1);
|
||||
#define xx(a, b, c, d...) _register_command(# a, a, b, c, ## d, \
|
||||
driverloaded_ARG, \
|
||||
debug_ARG, help_ARG, help2_ARG, \
|
||||
version_ARG, verbose_ARG, \
|
||||
quiet_ARG, config_ARG, -1);
|
||||
#include "commands.h"
|
||||
#undef xx
|
||||
}
|
||||
@ -707,6 +709,7 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
|
||||
cmd->current_settings.archive = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.archive);
|
||||
cmd->current_settings.backup = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.backup);
|
||||
cmd->current_settings.cache_vgmetadata = cmd->command->flags & CACHE_VGMETADATA ? 1 : 0;
|
||||
|
||||
if (arg_count(cmd, partial_ARG)) {
|
||||
init_partial(1);
|
||||
|
@ -117,6 +117,8 @@ struct arg {
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
#define CACHE_VGMETADATA 0x00000001
|
||||
|
||||
/* a register of the lvm commands */
|
||||
struct command {
|
||||
const char *name;
|
||||
@ -124,6 +126,8 @@ struct command {
|
||||
const char *usage;
|
||||
command_fn fn;
|
||||
|
||||
unsigned flags;
|
||||
|
||||
int num_args;
|
||||
int *valid_args;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user