1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-25 01:34:38 +03:00
Commit Graph

936 Commits

Author SHA1 Message Date
Dave Wysochanski
38cc6383b7 Create _init_globals() and call from bottom of create_toolcontext().
Move init_full_scan_done(0) and init_mirror_in_sync(0) from init_lvm()
after call to create_toolcontext() to _init_globals(), called from bottom
of create_toolcontext().  No functional change.

Author: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: James Cameron <james.cameron@hp.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2008-12-12 03:30:41 +00:00
Dave Wysochanski
f31e8d08cd Move initialization of cmd->fmt into init_formats().
init_formats() sets up the command formats, and currently sets cmd->fmt_backup
but does not set cmd->fmt to a default value.  This seems incorrect so we
set it to cmd->default_settings.fmt before returning.

The call we remove here may set cmd->fmt based on a command line setting.
But it is safe to remove this, because the only caller of init_lvm() that
cares about the cmdline override is the cmdline tools (clvmd does not care),
called from lvm2_main().  After lvm2_main() calls init_lvm(), it later calls
lvm_run_command().  In lvm_run_command(), we have a call to _apply_settings(),
which has the identical assignment of cmd->fmt that this patch removes.
2008-12-11 03:36:16 +00:00
Dave Wysochanski
224c8ec0fa Remove redundant init_msg_prefix() and init_cmd_name().
This is very obvious - _init_logging() makes the identical init_msg_prefix()
and init_cmd_name() calls with cmd->default_settings so these calls are
clearly redundant after calling create_toolcontext().
2008-12-11 03:34:43 +00:00
Dave Wysochanski
309c19ef63 Remove redundant set_activation() call after create_toolcontext() calls.
Very similar argument to removal of init_debug() and other calls.

create_toolcontext() calls _process_config() which sets
cmd->default_settings.activation, then calls
set_activation(cmd->default_settings.activation).  Later, create_toolcontext()
sets cmd->current_settings = cmd->default_settings.  So these calls
set_activation(cmd->current_settings.activation) are redundant.
2008-12-11 03:34:12 +00:00
Dave Wysochanski
13aad7e8b4 Remove backup_enable() calls after create_toolcontext() calls.
Identical argument to previous patch which removed archive_enable() calls.
We add a new parameter to backup_init() which sets the enable value based
on the cmd->default_settings.backup value.  This value was used to set
cmd->current_settings.backup, used in the removed backup_enable() call.
2008-12-11 03:33:35 +00:00
Dave Wysochanski
6f36d0d06c Remove archive_enable() calls after create_toolcontext() calls.
_init_backup() calls archive_init(), which originally set 'enabled' to
a hardcoded '1' value.  This seems incorrect based on my read of other
areas of the code so here we add a 'enabled' paramter to archive_init().
We pass in cmd->default_settings.archive, which is obtained from the
config tree.  Later in create_toolcontext, cmd->current_settings is
set to cmd->default_settings.  The archive_enable() call we remove
here was using cmd->current_settings to set the 'archive' enable
value.  The final value of cmd->archive_params->enabled should thus
be equivalent to the original code.
2008-12-11 03:32:56 +00:00
Dave Wysochanski
76d734a4bd Move init_test() from _apply_settings into _init_logging().
This one we actually need to move.  _init_logging() is called from
    create_toolcontext(), which makes this call:
        /* Test mode */
        cmd->default_settings.test =
            find_config_tree_int(cmd, "global/test", 0);

But it does not call init_test().  So we need an init_test() somewhere.
The most logical place is to put it inside _init_logging(), since this
is where the config value is read and default_settings are set.  Placing
the init_test() call here matches what is done with other variables and
seems to make sense.
2008-12-11 03:31:47 +00:00
Dave Wysochanski
b14f29b5b7 Remove handles_missing_pvs assignment after call to create_toolcontext().
This variable is set at the top of create_toolcontext() to 0.
Nothing later in create_toolcontext() changes the value.
In init_lvm(), nothing between create_toolcontext() call and this assignment
changes the value.  Thus, the assignment is redundant.
2008-12-11 03:31:10 +00:00
Dave Wysochanski
c57b30e342 Remove init_verbose() calls immediately after create_toolcontext() calls.
The rationale for removing init_verbose() call is very similar to removing
init_debug() call.  create_toolcontext() calls _init_logging() which
makes these calls:
        /* Verbose level for tty output */
        cmd->default_settings.verbose =
            find_config_tree_int(cmd, "log/verbose", DEFAULT_VERBOSE);
        init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL);

And being that create_toolcontext() copies default_settings into
current_settings at the bottom, the init_verbose() call we are removing:
        init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);

is redundant.
2008-12-11 03:30:19 +00:00
Dave Wysochanski
f6023a7c76 Remove init_debug() calls immediately after create_toolcontext() call.
We can safely remove because create_toolcontext() calls _init_logging(),
which makes these calls:
        /* Debug level for log file output */
        cmd->default_settings.debug =
            find_config_tree_int(cmd, "log/level", DEFAULT_LOGLEVEL);
        init_debug(cmd->default_settings.debug);

Then at the bottom of create_toolcontext() we do this:
        cmd->current_settings = cmd->default_settings;

So the call we are removing from init_lvm() functions (clvmd and lvmcmdline):
        init_debug(cmd->current_settings.debug);

Just sets the value of debug based on 'cmd->current_settings.debug'.
Since cmd->current_settings is equivalent to cmd->default_settings, and
init_debug() was called with cmd->default_settings, the call we remove is
redundant.
2008-12-11 03:29:37 +00:00
Dave Wysochanski
6357a2d9b8 Replace _apply_settings() after create_toolcontext() with equivalent inline.
Subsequent patches will refactor / remove each of these lines, as many of
them are redundant when called immediately after create_toolcontext().
2008-12-11 03:28:54 +00:00
Dave Wysochanski
647314d3cc Make _init_rand() thread safe - use rand_r() instead of rand().
Use good entropy for seed value if possible.
2008-12-07 04:27:56 +00:00
prajnoha
481618826d Added displayable_lvs_in_vg and lv_is_displayable functions to deal with
the counts of visible LVs from user's perspective consistently throughout
the code.
2008-12-04 15:54:26 +00:00
Dave Wysochanski
befcada36a Fix vgcreate race which could allow two parallel vgcreates to succeed,
with the second vgcreate overwriting the first.

Obtain lock before calling vg_create(), which checks for existence of vgname
and fails if it already exists.
2008-12-01 20:14:33 +00:00
Zdeněk Kabeláč
a0d668e850 fix missing const char* 2008-11-18 10:13:23 +00:00
Dave Wysochanski
f7d624e684 Fix "lvremove -f vgname" when vgname contains snapshots.
Prior to this patch, "lvremove -f vgname" would fail if vgname contained
one or more snapshot LVs.  Now this passes, but has a side-effect.
If you issue "lvremove vgname" where vgname contains one or more snaps,
you will get an extra "y/n" prompt to remove the same snapshot.
Example:
$ lvs
  LV     VG     Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lvsnap vgtest swi-a- 16.00M lvtest   0.05
  lvtest vgtest owi-a- 64.00M
$ lvremove vgtest
Do you really want to remove active logical volume "lvsnap"? [y/n]: n
  Logical volume "lvsnap" not removed
Do you really want to remove active logical volume "lvsnap"? [y/n]: n
  Logical volume "lvsnap" not removed
  Command failed with status code 5.

Fixing this will most likely require modification of the iterator
function, process_each_lvs_in_vg() to iterate over snaps in some
cases (e.g. lvs, vgdisplay -v) but not in others (lvremove).
2008-11-17 18:20:13 +00:00
Alasdair Kergon
f5c395adb2 some makefile fixes for liblvm2cmd & remove some hardcoded .so 2008-11-14 20:59:56 +00:00
Zdeněk Kabeláč
1c38ce8245 cleaner const char* usage for last_path_component() 2008-11-12 09:53:33 +00:00
Zdeněk Kabeláč
702cfe15be minor compiler warning fix for function declaration prototype 2008-11-12 09:49:06 +00:00
Milan Broz
a98888ad07 Fix lvm2.static build. 2008-11-10 13:41:43 +00:00
Dave Wysochanski
640d07bf35 Fix vgdisplay return code and exit status. 2008-11-07 19:02:47 +00:00
Alasdair Kergon
abba6e0642 make install_device-mapper 2008-11-04 17:25:32 +00:00
Alasdair Kergon
03ed7d73fc more missing bits 2008-11-04 14:57:06 +00:00
Alasdair Kergon
a2bfad1c29 Right, a simple build (without options) is working again. 2008-11-03 22:14:30 +00:00
Alasdair Kergon
ba70dce803 further progress 2008-11-01 02:19:19 +00:00
Alasdair Kergon
424bdade0b drop explicit libdevmapper.h 2008-10-30 17:52:06 +00:00
Alasdair Kergon
759e49f025 Split out lvm-logging.h from log.h. 2008-10-30 17:27:28 +00:00
Alasdair Kergon
43924e31b8 Split out dm-logging.h from log.h 2008-10-30 17:24:04 +00:00
Milan Broz
c350798528 Fix validation of --minor and --major in lvcreate to require -My always. 2008-09-24 16:32:51 +00:00
Alasdair Kergon
04d52b450b fix last release 2008-09-19 15:44:03 +00:00
Alasdair Kergon
a586a89547 . 2008-09-19 07:18:03 +00:00
Alasdair Kergon
1905eacf15 rename var 2008-09-19 07:12:45 +00:00
Alasdair Kergon
95d43e17b3 Improve the way VGs with PVs missing are handled so manual intervention
is required in fewer circumstances.  (mornfall)
2008-09-19 06:42:00 +00:00
Alasdair Kergon
5ee86fc5d0 remove unused var 2008-09-19 03:45:34 +00:00
Alasdair Kergon
1be3e86aa0 Avoid shuffling remaining mirror images when removing one, retaining primary. 2008-09-18 19:56:50 +00:00
Alasdair Kergon
410904bef1 Prevent resizing an LV while lvconvert is using it. 2008-09-18 18:51:58 +00:00
Milan Broz
fbc34d70b0 Fix pvresize to not allow resize if PV has two metadata areas.
If the PV has two metadata areas, second one is located at the end of the device.

Do not allow resize of PV or second metadata area can be overwritten.
(The check was active only for orphan PVs.)
2008-09-12 15:26:45 +00:00
Milan Broz
1989ef4ebc Fix setting of volume limit count if converting to lvm1 format.
Fixes problem when after downconvert to lvm1 VG is broken:

# lvcreate -n lv1 -l 4 vg_test
  Invalid LV in extent map (PV /dev/sdb1, PE 0, LV 0, LE 0)
  ...
2008-08-29 13:41:21 +00:00
Milan Broz
666cc72661 Fix vgconvert logical volume id metadata validation.
If volume group is downconverted to lvm1 format,
check if lvid has supported format for conversion to lv_num in lvm1.
2008-08-28 18:41:51 +00:00
Milan Broz
6594fe077d Fix vgcfgbackup to properly check filename if template is used. 2008-08-13 12:44:24 +00:00
Alasdair Kergon
2d364d4d80 Improve file descriptor leak detection to display likely culprit and filename. 2008-08-01 19:51:27 +00:00
Alasdair Kergon
d30a2653b5 remove now-redundant slash-stripping 2008-07-31 15:38:52 +00:00
Alasdair Kergon
5936ac58c2 Change lvchange exit status to indicate if any part of the operation failed. 2008-07-31 13:03:01 +00:00
Alasdair Kergon
ded77e3f5c remove unused mdas variable 2008-07-31 12:40:52 +00:00
Alasdair Kergon
8a29df0a6c fix pvremove for pvs without mdas 2008-07-31 12:38:31 +00:00
Alasdair Kergon
9db22babaf Fix pvchange to handle PVs without mdas. 2008-07-31 12:28:51 +00:00
Dave Wysochanski
61243c65cd Add pvcreate tests to verify failure on md array detection. 2008-07-29 21:05:20 +00:00
Dave Wysochanski
cbf1447ebd Refactor pvcreate - simplify return codes. 2008-07-25 14:59:51 +00:00
Dave Wysochanski
30104441bf Refactor pvcreate - --yes argument 2008-07-25 14:45:24 +00:00
Dave Wysochanski
b4a70804f0 Refactor pvcreate - --force parameter. 2008-07-25 14:36:55 +00:00