1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

10397 Commits

Author SHA1 Message Date
Zdenek Kabelac
7e7411966a lib: avoid reparsing same metadata
When reading VG mda from multiple PVs - do all the validation only
when mda is seen for the first time and  when mda checksum and length
is same just return already existing VG pointer.

(i.e. using 300PVs for a VG would lead to create and destroy 300 config trees....)
2015-03-06 13:53:12 +01:00
Zdenek Kabelac
6a2ae250ff cleanup: add stack trace
Missed stack in error path.
2015-03-06 13:51:54 +01:00
Zdenek Kabelac
60427d5d42 lib: return value
Drop label out: with goto and return NULL directly.
Add log_debug() for zero metadata offset.
2015-03-06 13:51:43 +01:00
Zdenek Kabelac
4d16bfaabb lib: zero returned labeller struct
Return zeroed struct.
(Structure will be extended, so ensure all members are initilized.)
2015-03-06 13:17:39 +01:00
Zdenek Kabelac
6f68f4364b devices: avoid extra open() syscall
If the device is already opened by lvm's device cache,
avoid extra syscall opening devices for obtaining its size.
2015-03-06 13:17:39 +01:00
David Teigland
b48ff3b94e man: add info to lvmsystemid
about losing access to a VG if lvm is downgraded
to an earlier version.
2015-03-05 12:12:42 -06:00
David Teigland
5e25bca1a9 system_id: avoid munging vg and lv fields
Munge the WRITE/WRITE_LOCKED flags in a temp variable
instead of in the vg/lv fields.
2015-03-05 10:23:16 -06:00
David Teigland
8bb76aea81 system_id: undo the previous changes to the lvm1 code
The system_id and lock_type compat changes do not apply
to the lvm1 code.
2015-03-05 10:13:05 -06:00
David Teigland
1e65fdd9ba system_id: make new VGs read-only for old lvm versions
Previous versions of lvm will not obey the restrictions
imposed by the new system_id, and would allow such a VG
to be written.  So, a VG with a new system_id is further
changed to force previous lvm versions to treat it as
read-only.  This is done by removing the WRITE flag from
the metadata status line of these VGs, and putting a new
WRITE_LOCKED flag in the flags line of the metadata.

Versions of lvm that recognize WRITE_LOCKED, also obey the
new system_id.  For these lvm versions, WRITE_LOCKED is
identical to WRITE, and the rules associated with matching
system_id's are imposed.

A new VG lock_type field is also added that causes the same
WRITE/WRITE_LOCKED transformation when set.  A previous
version of lvm will also see a VG with lock_type as read-only.

Versions of lvm that recognize WRITE_LOCKED, must also obey
the lock_type setting.  Until the lock_type feature is added,
lvm will fail to read any VG with lock_type set and report an
error about an unsupported lock_type.  Once the lock_type
feature is added, lvm will allow VGs with lock_type to be
used according to the rules imposed by the lock_type.

When both system_id and lock_type settings are removed, a VG
is written with the old WRITE status flag, and without the
new WRITE_LOCKED flag.  This allows old versions of lvm to
use the VG as before.
2015-03-05 09:50:43 -06:00
David Teigland
c6a57dc4f3 Revert "systemid: Add ACCESS_NEEDS_SYSTEM_ID VG flag."
This reverts commit bfbb5d269a.

This will be done differently.
2015-03-05 09:50:43 -06:00
David Teigland
06b408ecce system_id: enable the options in config file and command line 2015-03-05 09:50:43 -06:00
Peter Rajnoha
190d591fbe report: fix seg_monitor field to display monitoring status for thick snapshots and mirrors
The seg_monitor did not display monitored status for thick snapshots
and mirrors (with mirror log *not* mirrored). The seg monitor did work
correctly even before for other segtypes - thins and raids.

Before (mirrors and snapshots, only mirrors with mirrored log properly displayed monitoring status):

[0] f21/~ # lvs -a -o lv_name,lv_layout,lv_role,seg_monitor vg
  LV                                     Layout     Role                             Monitor
  mirror                                 mirror     public
  [mirror_mimage_0]                      linear     private,mirror,image
  [mirror_mimage_1]                      linear     private,mirror,image
  [mirror_mlog]                          linear     private,mirror,log

  mirror_with_mirror_log                 mirror     public                           monitored
  [mirror_with_mirror_log_mimage_0]      linear     private,mirror,image
  [mirror_with_mirror_log_mimage_1]      linear     private,mirror,image
  [mirror_with_mirror_log_mlog]          mirror     private,mirror,log               monitored
  [mirror_with_mirror_log_mlog_mimage_0] linear     private,mirror,image
  [mirror_with_mirror_log_mlog_mimage_1] linear     private,mirror,image

  thick_origin                           linear     public,origin,thickorigin
  thick_snapshot                         linear     public,snapshot,thicksnapshot

With this patch applied (monitoring status displayed for all mirrors and snapshots):

[0] f21/~ # lvs -a -o lv_name,lv_layout,lv_role,seg_monitor vg
  LV                                     Layout     Role                             Monitor
  mirror                                 mirror     public                           monitored
  [mirror_mimage_0]                      linear     private,mirror,image
  [mirror_mimage_1]                      linear     private,mirror,image
  [mirror_mlog]                          linear     private,mirror,log

  mirror_with_mirror_log                 mirror     public                           monitored
  [mirror_with_mirror_log_mimage_0]      linear     private,mirror,image
  [mirror_with_mirror_log_mimage_1]      linear     private,mirror,image
  [mirror_with_mirror_log_mlog]          mirror     private,mirror,log               monitored
  [mirror_with_mirror_log_mlog_mimage_0] linear     private,mirror,image
  [mirror_with_mirror_log_mlog_mimage_1] linear     private,mirror,image

  thick_origin                           linear     public,origin,thickorigin
  thick_snapshot                         linear     public,snapshot,thicksnapshot    monitored
2015-03-05 14:05:34 +01:00
Alasdair G Kergon
56606b5f21 post-release 2015-03-04 14:00:46 +00:00
Alasdair G Kergon
930fa3290d pre-release 2015-03-04 13:49:51 +00:00
Peter Rajnoha
a7bfc2cbb5 cleanup: tools: "or use -S for selection" --> "or use --select for selection" 2015-03-04 14:40:58 +01:00
Alasdair G Kergon
733bfe36f5 systemid: Disable --systemid.
Disable use of --systemid for this release.
2015-03-04 13:14:51 +00:00
Peter Rajnoha
67c52a4453 config: add CFG_DISABLED flag and mark system_id settings with that flag
If configuration setting is marked in config_setting.h with CFG_DISABLED
flag, default value is always used for such setting, no matter if it's defined
by user (in --config/lvm.conf/lvmlocal.conf).

A warning message is displayed if this happens:

For example:

[1] f21/~ # lvm dumpconfig --validate
  WARNING: Configuration setting global/system_id_source is disabled. Using default value.
  LVM configuration valid.

[1] f21/~ # pvs
  WARNING: Configuration setting global/system_id_source is disabled. Using default value.
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sdb          lvm2 ---  128.00m 128.00m
  ...
2015-03-04 14:08:47 +01:00
Peter Rajnoha
e73dad7874 vgremove: select: direct selection to be done per-VG, not per-LV
Though vgremove operates per VG by definition, internally, it
actually means iterating over each LV it contains to do the
remove.

So we need to direct selection a bit in this case so that the
selection is done per-VG, not per-LV.

That means, use processing handle with void_handle.internal_report_for_select=0
for the process_each_lv_in_vg that is called later in vgremove_single fn.
We need to disable internal selection for process_each_lv_in_vg
here as selection is already done by process_each_vg which calls
vgremove_single. Otherwise selection would be done per-LV and not
per-VG as we intend!

An intra-release fix for commit 00744b053f.
2015-03-04 10:44:31 +01:00
Alasdair G Kergon
bfbb5d269a systemid: Add ACCESS_NEEDS_SYSTEM_ID VG flag.
Set ACCESS_NEEDS_SYSTEM_ID VG status flag whenever there is
a non-lvm1 system_id set.  Prevents concurrent access from
older LVM2 versions.
Not set on VGs that bear a system_id only due to conversion
from lvm1 metadata.
2015-03-04 01:16:32 +00:00
Alasdair G Kergon
3562b5ab39 systemid: Init and merge lvm2 and lvm1 fields.
Use system_id field in preference to lvm1_system_id.
Initialise both for now.
2015-03-04 01:00:51 +00:00
Alasdair G Kergon
dcba4781ea vgchange: Prevent lvm1 system ID changes.
(This system_id setting code shouldn't be in two places.)
2015-03-04 00:50:54 +00:00
Alasdair G Kergon
340369ab25 format1: Export generate_lvm1_system_id.
Export _lvm1_system_id as generate_lvm1_system_id and call it in
vg_setup() so it is set before writing the metadata to disk
and not missing from the initial metadata backup file.
2015-03-04 00:44:15 +00:00
Alasdair G Kergon
4e6f3e5162 archives: Preserve format type in file.
format_text processes both lvm2 on-disk metadata and metadata read
from other sources such as backup files.  Add original_fmt field
to retain the format type of the original metadata.
Before this patch, /etc/lvm/archives would contain backups of
lvm1 metadata with format = "lvm2" unless the source was lvm1 on-disk
metadata.
2015-03-04 00:30:26 +00:00
David Teigland
2477495922 lvchange, vgchange: fix the system_id check
The check for matching system_id needs to check
that the system_id is not blank.
2015-03-03 16:45:16 -06:00
David Teigland
cccc2b2980 vgchange: deactivate LVs in foreign VG
Apply the same logic as lvchange, which allows
deactivating LVs in a foreign VG.
2015-03-03 13:23:13 -06:00
Petr Rockai
926b38c0d7 spec: Add lvmlocal.conf to RPMs. 2015-03-03 15:47:13 +01:00
Peter Rajnoha
1a41e649a6 metadata: vg: alloc lvm1_system_id in alloc_vg sooner 2015-03-02 13:00:45 +01:00
Peter Rajnoha
eeaf3f2e88 metadata: vg: add missing vg->lvm1_system_id initialization
The vg->lvm1_systemd_id needs to be initialized as all the code around
counts with that. Just like we initialize lvm1_system_id in vg_create
(no matter if it's actually LVM1 or LVM2 format), this patch adds this
init in alloc_vg as well so the rest of the code does not segfaul
 when trying to access vg->lvm1_system_id.
2015-03-02 12:17:27 +01:00
Peter Rajnoha
047fe6c59f report: check value of args_are_pvs, not the pointer (fix for commit 9ea77b7) 2015-03-02 10:36:32 +01:00
David Teigland
c32efc7f7e system_id: apply consistent naming
In log messages refer to it as system ID (not System ID).

Do not put quotes around the system_id string when printing.

On the command line use systemid.

In code, metadata, and config files use system_id.

In lvmsystemid refer to the concept/entity as system_id.
2015-02-27 13:32:00 -06:00
Peter Rajnoha
e09f8a82f1 initscripts: lvm2-monitor: use @DMEVENTD_PIDFILE@ instead of hardcoded /var/run/dmeventd.pid 2015-02-27 15:48:10 +01:00
Jose Castillo
57e9e76da4 initscripts: lvm2-monitor: implement status action
Two new functions added in the init script: rh_status and rh_status_q.
First one to be used in status() and second one to be used in start(),
stop(), force_stop(). Check for 'dmeventd' added and print list of
lvs being monitored in status().
2015-02-27 15:38:34 +01:00
Peter Rajnoha
379fb90b05 cleanup: change check order in condition in _check_pv_list fn
"!dev_cache_get(argv[i], cmd->full_filter) && !rescan_done" --> "!rescan_done && !dev_cache_get(argv[i], cmd->full_filter)

Check the simple condition first (variable), then the function return value
(which in this case certainly takes more time to evaluate) - save some time.
2015-02-27 14:52:38 +01:00
Alasdair G Kergon
ee4cd2c737 lvchange: Allow -pr to change kernel only. 2015-02-27 13:38:26 +00:00
Peter Rajnoha
5b154ae4a3 report: one more comment explaining change of report type when tags are used for original LABEL reporting 2015-02-27 13:48:47 +01:00
Peter Rajnoha
9ea77b788b report: fix handling of reports with pure label fields
Two problems fixed by this patch:
  - PV tags were not recognized at all when using them with pvs
    report that has only label fields (regression since 2.02.105)
  - incorrect persistent .cache file to be generated after pvs
    report that has only label fields (regression since 2.02.106)

These bugs come from the transition from process_each_pv to
process_each_label introduced by commit
67a7b7a87d and commit
490226fc47 and related.
2015-02-27 13:39:25 +01:00
Peter Rajnoha
8bceb1e0bb conf: be more clear about wipe_signatures_when_zeroing_new_lvs option in comments 2015-02-27 09:17:10 +01:00
David Teigland
0a19238aa3 system_id: remove unwanted foreign error for some commands
Commands that can never use foreign VGs begin with
cmd->error_foreign_vgs = 1.  This tells the vg_read
lib layer to print an error as soon as a foreign VG
is read.

The toollib process_each layer also prints an error if a
foreign VG is read, but is more selective about it.  It
won't print an error if the command did not explicitly
name the foreign VG.  We want to silently ignore foreign VGs
unless a command attempts to use one explicitly.

So, foreign VG errors are printed from two different layers:
vg_read (lower layer) and process_each (upper layer).

Commands that use toollib process_each, only want errors from
the process_each layer, not from both layers.  So, process_each
disables the lower layer vg_read error message by setting
error_foreign_vgs = 0.

Commands that do not use toollib process_each, want errors
from the vg_read layer, otherwise they would get no error
message.  The original cmd->error_foreign_vgs setting
enables this error.

(Commands that are allowed to operate on foreign VGs always
begin with cmd->error_foreign_vgs = 0, and all the commands
in this group use toollib process_each with the selective
error reporting.)
2015-02-26 16:33:36 -06:00
Alasdair G Kergon
a432066c7c mirror: Explicit cast in region_size_max 2015-02-26 19:49:25 +00:00
Alasdair G Kergon
cb727a1ccc mirror: Avoid region size compiler warning.
format ‘%u’ expects type ‘unsigned int’, but argument 7 has type ‘uint64_t’
2015-02-26 19:45:55 +00:00
David Teigland
66d074e913 tests: more system_id tests 2015-02-26 13:23:22 -06:00
Alasdair G Kergon
b5394c8f26 lvchange: Allow -prw to change kernel only.
If an LV is already rw but still ro in the kernel, allow -prw to issue a
refresh to try to change the kernel state to rw.

Intended for use after clearing activation/read_only_volume_list in
lvm.conf.
2015-02-26 18:38:26 +00:00
David Teigland
71d97fd88a man: lvmsystemid: empty string equals no system_id 2015-02-25 16:55:56 -06:00
David Teigland
efd7480de3 tests: add more system_id tests 2015-02-25 16:13:28 -06:00
David Teigland
1248f94a42 pvscan, vgscan: include foreign vgs with --cache
pvscan --cache and vgscan --cache scan devices to refresh lvmetad,
and they should also refresh the lvmetad copy of foreign vgs.
2015-02-25 15:46:27 -06:00
David Teigland
bbaabb8a59 WHATS_NEW: vgimport with lvmetad 2015-02-25 14:59:24 -06:00
David Teigland
2c50cbe8cb tests: fix the system_id tests
That were broken by yesterday's system_id changes.
2015-02-25 14:58:49 -06:00
David Teigland
ebb2205b4c tests: add more systemid tests 2015-02-25 14:58:49 -06:00
David Teigland
dd6a202831 lvchange: deactivate is always possible in foreign vgs
The only realistic way for a host to have active LVs in a
foreign VG is if the host's system_id (or system_id_source)
is changed while LVs are active.

In this case, the active LVs produce an warning, and access
to the VG is implicitly allowed (without requiring --foreign.)
This allows the active LVs to be deactivated.

In this case, rescanning PVs for the VG offers no benefit.
It is not possible that rescanning would reveal an LV that
is active but wasn't previously in the VG metadata.
2015-02-25 14:58:49 -06:00
Jonathan Brassow
dd0ee35378 cmirror: Adjust region size to work around CPG msg limit to avoid hang.
cmirror uses the CPG library to pass messages around the cluster and maintain
its bitmaps.  When a cluster mirror starts-up, it must send the current state
to any joining members - a checkpoint.  When mirrors are large (or the region
size is small), the bitmap size can exceed the message limit of the CPG
library.  When this happens, the CPG library returns CPG_ERR_TRY_AGAIN.
(This is also a bug in CPG, since the message will never be successfully sent.)

There is an outstanding bug (bug 682771) that is meant to lift this message
length restriction in CPG, but for now we work around the issue by increasing
the mirror region size.  This limits the size of the bitmap and avoids any
issues we would otherwise have around checkpointing.

Since this issue only affects cluster mirrors, the region size adjustments
are only made on cluster mirrors.  This patch handles cluster mirror issues
involving pvmove, lvconvert (from linear to mirror), and lvcreate.  It also
ensures that when users convert a VG from single-machine to clustered, any
mirrors with too many regions (i.e. a bitmap that would be too large to
properly checkpoint) are trapped.
2015-02-25 14:42:15 -06:00