1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
Commit Graph

5041 Commits

Author SHA1 Message Date
David Teigland
04a83148ce lvmetad: use the disabled flag in commands
Commands already check if the lvmetad token is valid,
and if not, they rescan devices to repopulate lvmetad
before running.  Now, in addition to checking the
lvmetad token, they also check if the lvmetad disabled
flag is set.  If so, they do not use the lvmetad cache
and revert to disk scanning.
2016-04-19 09:41:18 -05:00
David Teigland
ff867c2ef6 lvmetad: set disabled flag in lvmetad if lvm1 metadata is found
When devices are being scanned, if lvm1 metadata is seen,
tell lvmetad to set its disabled flag because of lvm1 metadata.
2016-04-19 09:41:18 -05:00
David Teigland
a4ef8fa25e lvmetad: add disabled state
A global flag in lvmetad indicates it has been disabled.
Other flags indicate the reason it was disabled.
These flags can be queried using get_global_info.

The lvmetactl debugging utility can set and clear the
disabled flag in lvmetad.  Nothing else sets the
disabled flag yet.

Commands will check these flags after connecting to
lvmetad.  If the disabled flag is set, the command
will not use the lvmetad cache, but revert to disk
scanning.

To test this feature:

$ lvmetactl get_global_info
response = "OK"
global_invalid = 0
global_disable = 0
disable_reason = "none"
token = "filter:3041577944"

$ vgs
(should report VGs from lvmetad)

$ lvmetactl set_global_disable 1

$ lvmetactl get_global_info
response = "OK"
global_invalid = 0
global_disable = 1
disable_reason = "DIRECT"
token = "filter:3041577944"

$ vgs
  WARNING: Not using lvmetad because the disable flag was set directly.
(should report VGs without contacting lvmetad)

$ lvmetactl set_global_disable 0

$ vgs
(should report VGs from lvmetad)
2016-04-19 09:41:18 -05:00
David Teigland
a6a32a7c0e metadata: don't repair shared VGs
When the in-use flag looks like it needs to be repaired.
2016-04-19 09:19:32 -05:00
David Teigland
a400eba174 lvmlockd: skip unnecessary lvmetad cache update
In cases where a VG is reread from disk, but the
seqno matches what is currently in lvmetad, the
metadata in lvmetad doesn't need to be updated.
2016-04-19 09:19:32 -05:00
Zdenek Kabelac
7e5881dd13 snapshot: improve merge
Improve code for snapshot merge for readabilty
and also reduce number of tests needed to decide
if merging can or cannot be started.

(Further improving 9cccf5245a)
2016-04-18 23:05:17 +02:00
Zdenek Kabelac
f5cf6cc9ed debug: fix error message
log_error is replaced with warn since the result
of function is not result in command error.
2016-04-18 12:32:56 +02:00
Zdenek Kabelac
9cccf5245a thin: improve recognizing of merge in progress
Rewrite too condensed condition in more readable form,
wher decision are clearly separated and commented and
also add debug messages for them.
2016-04-18 12:32:52 +02:00
Zdenek Kabelac
e2cd882f2e thin: check runtime table line for merging
To recognize in runtime if we are merging or not
to make consistent decision between suspend and resume
add function to parse thin table line when add
merging thin device to the table.
2016-04-18 11:18:35 +02:00
Alasdair G Kergon
6954de22e2 activate: Improve snapshot merge initiation
A snapshot merge into its origin cannot be initiated while the devices
are in use.  If there is outside interference (such as from udev),
the suspend (preload) and resume stages can reach conflicting decisions
about whether or not to proceed.

Try to make the logic more robust by checking the inactive or live
table during resume.  (This is still not perfect.)
2016-04-15 02:33:38 +01:00
Alasdair G Kergon
150cff9cce activation: Log when pending snap merge postponed. 2016-04-14 23:42:56 +01:00
Alasdair G Kergon
ff09bda7d5 activation: Add LV name to a debug message. 2016-04-14 22:41:25 +01:00
David Teigland
579bd92009 lvmetad: add FIXME to comment 2016-04-13 14:08:29 -05:00
David Teigland
56c68b3476 lvmetad: preemptively check and rescan in commands
Move checking the lvmetad state, and the possible rescan,
out of lvmetad_send() to the start of the command.

Previously, the token mismatch and rescan would occur
within lvmetad_send() for some other request.  Now,
the token mismatch is detected earlier, so the
rescan can be done before the main command is in
progress.  Rescanning deep within the processing of
another command will disturb the lvmcache state of
that other command.

A rescan already exists at the start of the command
for the case where foreign VGs are going to be read.
This same rescan is now also performed when there is
an lvmetad token mismatch (from a changed global_filter).

The commands pvscan/vgscan/lvscan/vgimport are excluded
from this preemptive checking/rescanning for lvmetad
because they want to do rescanning themselves explicitly.

If rescanning devices fails, then lvmetad has not been
correctly repopulated and should not be used, so make
the command revert to not using lvmetad.
2016-04-13 14:05:42 -05:00
Zdenek Kabelac
a28c81cbae debug: unify some tracing messages
Introduce  FMTVGID - although it might be possibly better to ensure
vgid is always \0 ended string.

Unify some lvmcache reported messages.
2016-04-12 13:06:16 +02:00
Zdenek Kabelac
1be74cfd7f cleanup: gcc warn about comparing int with uint 2016-04-12 11:47:51 +02:00
Zdenek Kabelac
0f7975cb35 cleanup: avoid declaring var in the middle of code
Easier to read code.
2016-04-12 11:47:51 +02:00
David Teigland
147c9c01a2 rename function read_vgname to read_vgsummary
The name did not clearly represent what it does.
2016-04-11 13:07:48 -05:00
Zdenek Kabelac
fe65a86cbc devcache: do not insert devices without device node
When not obtaining device from udev, we are doing deep devdir scan,
and at the same time we try to insert everything what /sys/dev/block
knows about. However in case  lvm2 is configured to use nonstardard
devdir this way it will see (and scan) devices from a real system.

lvm2 test suite is using its own test devdir with its
own device nodes. To avoid touching real /dev  devices, validate
the device node exist in give dir and do not insert such device
into a cache.

With obtain list from udev this patch has no effect
(the normal user path).
2016-04-11 10:33:14 +02:00
Zdenek Kabelac
07a60b59f7 devcache: index devices also without udev
We have _insert_dirs() for  udev and non-udev compilation.
Compiling without udev missed to call dev_cache_index_devs().
Move the call after _insert_dirs() call so both compilation
gets it.
2016-04-11 10:32:19 +02:00
Zdenek Kabelac
af148a9d77 cleanup: avoid gcc warns
Some older systems may had global declaration to cause gcc warning.
Rename for cases we don't care...
2016-04-08 20:20:16 +02:00
Zdenek Kabelac
5cfa6cb347 cleanup: simplier to read condition
Make more readable what we are looking for and just test for
KERNEL version at one place.
2016-04-08 20:20:16 +02:00
Zdenek Kabelac
74e704bb44 cleanup: reuse _setup_task
Shorten code and use common code from _setup_task.
Reorder naming of major:minor sscanf (as later it's been
also used swapped there was no real bug).
2016-04-08 20:20:16 +02:00
Zdenek Kabelac
a09d65891f dev_manager: device_is_usable does not flush
When scanning if device is being usable as PV,
we call STATUS - but this status should not cause
any flushing.
Skip also open_count information as it's not needed.
2016-04-08 20:20:04 +02:00
Alasdair G Kergon
f40dfb48ad activation: Skip another non-prefixed info ioctl.
_percent() also does a lookup by dm uuid.
Also get kernel version from cmd->kernel_vsn.
2016-04-08 16:27:12 +01:00
Peter Rajnoha
ed0c779bd1 report: remove superfluous SEGSSTATUS report type
We don't have any report field of this type yet. Return this patch into
the play if we really need that. Currenly we always report status
(result of "status" dm ioctl) for an LV as a whole where we choose
segment which represents the LV, not calling status for each possible
segment it contains - we don't need this now so I'm removing it to
not make the code more complex uselessly.
2016-04-08 14:21:47 +02:00
Zdenek Kabelac
8b2108e6b1 activation: do not check for devs without LVM-
Devices without "LVM-" uuid prefix have been generated by very old
version of lvm2 2.00 and 2.01.
Since version 2.02 all lvm2 devices are using prefix "LVM-".

However checking for present of ancient non prefixed devices does
take extra IOCTL per every call and for majority of todays user
it will not find anything new.

So use the assumption that users with kernel 3.X and newer are not
really using such old versions of lvm2 (year <2005) and with their
new kernel they are also using new version of lvm2 and skip
checking for them.

This change also makes trace logs more readable.
2016-04-07 22:32:08 +02:00
Zdenek Kabelac
9be7bca4be cleanup: indent 2016-04-06 11:31:02 +02:00
Zdenek Kabelac
5b2227c2c1 preload: preserve flushing state
When leaving preload routine it should not altet state of flush required
when it's been already set to 1 and drop it to 0.

The API here is unclean, but current usage expects the same
variable pointer is for all preload calls and combines 'flush_required'
across all of them.
2016-04-06 11:31:02 +02:00
Zdenek Kabelac
7c1937f8df suspend: fix suspend with noflush limitation
Commit 844b009584 tried to move
limit for usage of noflush to 'preload' however this was not
correctly processed.

Intead explicitly check for which types we do not want noflush
and also add debug message in this case.
2016-04-06 11:31:02 +02:00
Zdenek Kabelac
d4c03cf7b2 mirror: fix flushing for mirror target
Fix regression caused by commit ba41ee1dc9.
The idea was to use no_flush for changed device only for thin volumes
and thin pools but also to merge this with change made in commit
844b009584.

However the resulting condition has caused misbehavior for the mirror
suspend - as that has been before the ONLY allowed target type
that could have been suspended with noflush.

Result was badly working repair for --type mirror that has been
passing 'flush' to the repaired mirror target whenever preload
wrongly set flush_required.

The origin code has required the flush_required to be set whenever
deivce size is changed.

Now it first detects if device size got smaller
'dm_tree_node_size_changed(root) < 0' - this requires flush.
Otherwise it checks device is not thin volume nor thin pool and its
size has changed (got bigger) and requires flush.

This mean upsize of thin-pool or thin volume will not require flush.
2016-04-06 11:31:02 +02:00
Alasdair G Kergon
60befab773 Revert "thin: display highest mapped sector"
This reverts commit fc7dacaa4c.

Let's put this information into a separate field.  It doesn't meet the
definition of the existing field.
2016-04-01 20:09:38 +01:00
Peter Rajnoha
42f04a0f77 dev-cache: skip VGID/LVID indexing if /sys/dev/block is not present
/sys/dev/block is available since kernel version 2.2.26 (~ 2008):
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-dev

The VGID/LVID indexing code relies on this feature so skip indexing
if it's not available to avoid error messages about inability to open
/sys/dev/block directory.

We're not going to provide fallback code to read the /sys/block/
instead in this case as that's not that efficient - it needs extra
reads for getting major:minor and reading partitions would also
pose further reads and that's not worth it.
2016-04-01 17:09:15 +02:00
Peter Rajnoha
9f28eb4c20 fix: make udev_get_library_context available also for non-udev compilations
If compiling without udev_sync support, udev_get_library_context simply
returns NULL so we don't need to remember putting ifdef UDEV_SYNC_SUPPORT
in the code all the time we just need to check whether there's any udev
context initialized or not.
2016-04-01 15:35:22 +02:00
Peter Rajnoha
15d1824fac dev-cache: iterate devices in sysfs for VGID/LVID index if obtain_device_list_from_udev=0
If obtain_device_list_from_udev=0, LVM can make use of persistent .cache
file. This cache file contains only devices which underwent filters in
previous LVM command run. But we need to iterate over all block devices
to create the VGID/LVID index completely for the device mismatch check
to be complete as well.

This patch iterates over block devices found in sysfs to generate the
VGID/LVID index in dev cache if obtain_device_list_from_udev=0
(if obtain_device_list_from_udev=1, we always read complete list of
block devices from udev and we ignore .cache file so we don't need
to look in sysfs for the complete list).
2016-04-01 14:49:39 +02:00
Peter Rajnoha
7ed5a65ee5 dev-cache: also add dev name for device found in sysfs only
For the case when we print device name associated with struct device
that was not found in /dev, but in sysfs, for example when printing
devices where LV device mismatch is found.
2016-04-01 14:48:56 +02:00
Peter Rajnoha
91d32f9d1b refactor: dev-cache: move code adding sysfs-only device into separate fn 2016-04-01 11:47:06 +02:00
Peter Rajnoha
0e774d5ae7 refactor: dev-cache: use btree instead of hash table for sysfs-only devices
major:minor btree is more convenient and more suitable than dev name
hash table here.
2016-04-01 11:42:25 +02:00
Zdenek Kabelac
5034bb8d18 cleanup: use local var to read struct 2016-03-31 12:21:40 +02:00
Zdenek Kabelac
b10253ab4d cleanup: use TARGET define 2016-03-31 12:21:40 +02:00
Zdenek Kabelac
86db143307 cleanup: debug message fix
Reported-by: Ming-Hung Tsai <mingnus gmail com>
2016-03-31 12:21:25 +02:00
Zdenek Kabelac
fc7dacaa4c thin: display highest mapped sector
Use  meta%  to expose highest mapped sector in thinLV.
so showing there 100.00% means thinLV maps latest sector.

Currently using a 'trick' with total_numerator to pass-in
device size when  'seg==NULL'

TODO: Improve device status API per target - current 'percentage'
is not really extensible.
2016-03-31 12:20:43 +02:00
Zdenek Kabelac
8bbec41bd4 thin: no thin-pool flush when reading metadata status
Previous fix missed the fact the we do query for 'percent' with
seg value either set or unset (API overload...)
When 'seg' was unset, we still issue flush with status.
Fix it by cheking segtype by target_type.

As we check for segtype - we could also skip whole percentage
if the 'segtype' is unknown by code directly.

Reported-by: Ming-Hung Tsai <mingnus gmail com
2016-03-31 12:15:47 +02:00
Peter Rajnoha
9a086a6607 dev-cache: fix check for already indexed dev in _index_dev_by_vgid_and_lvid 2016-03-30 15:57:57 +02:00
Peter Rajnoha
06ef7ba876 doc: describe lvmlockd/lvmpolld features as available if LVM compiled with lockd/polld support 2016-03-30 14:10:56 +02:00
Peter Rajnoha
8b258a005b dev-cache: dev_cache_index_devs fn is available unconditionally
The new dev_cache_index_devs fn was under ifdef UDEV_SYNC_SUPPORT by mistake,
move it out of this ifdef.
2016-03-30 13:06:20 +02:00
Peter Rajnoha
52e0d0db44 dev-cache: remove spurious error msg if no value found in /sys/dev/block/<major>:<minor>/dm/uuid during dev scan
It's correct to have a DM device that has no DM UUID assigned
so no need to issue error message in this case. Also, if the
device doesn't have DM UUID, it's also clear it's not an LVM LV
(...when looking for VGID/LVID while creating VGID/LVID indices
in dev cache).

For example:

$ dmsetup create test --table "0 1 linear /dev/sda 0"
And there's no PV in the system.

Before this patch (spurious error message issued):
$ pvs
  _get_sysfs_value: /sys/dev/block/253:2/dm/uuid: no value

With this patch applied (no spurious error message):
$ pvs
2016-03-30 11:30:09 +02:00
Peter Rajnoha
8c27c52749 dev-cache: also index VGIDs and LVIDs if using persistent .cache file
If we're using persistent .cache file, we're reading this file instead
of traversing the /dev content. Fix missing indexing by VGID and LVID
here - hook this into persistent_filter_load where we populate device
cache from persistent .cache file instead of scanning /dev.

For example, inducing situation in which we warn about different device
actually used than what LVM thinks should be used based on metadata:

$ lsblk -s /dev/vg/lvol0
NAME     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vg-lvol0 253:4    0  124M  0 lvm
`-loop1    7:1    0  128M  0 loop

$ lvmconfig --type diff

global {
	use_lvmetad=0
}
devices {
	obtain_device_list_from_udev=0
}

(obtain_device_list_from_udev=0 also means the persistent .cache file is used)

Before this patch - pvs is fine as it does the dev scan, but lvs relies
on persistent .cache file and it misses the VGID/LVID indices to check
and warn about incorrect devices used:

$ pvs
  Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1
  Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1
  WARNING: Device mismatch detected for vg/lvol0 which is accessing /dev/loop1 instead of /dev/loop0.
  PV          VG Fmt  Attr PSize   PFree
  /dev/loop0 vg lvm2 a--  124.00m    0

$ lvs
  Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1
  Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1
  LV    VG Attr       LSize
  lvol0 vg -wi-a----- 124.00m

With this patch applied - both pvs and lvs is fine - the indices are
always created correctly (lvs just an example here, other LVM commands
that rely on persistent .cache file are fixed with this patch too):

$ pvs
  Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1
  Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1
  WARNING: Device mismatch detected for vg/lvol0 which is accessing /dev/loop1 instead of /dev/loop0.
  PV          VG Fmt  Attr PSize   PFree
  /dev/loop0 vg lvm2 a--  124.00m    0

$ lvs
  Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1
  Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1
  WARNING: Device mismatch detected for vg/lvol0 which is accessing /dev/loop1 instead of /dev/loop0.
  LV    VG Attr       LSize
  lvol0 vg -wi-a----- 124.00m
2016-03-30 11:00:01 +02:00
Peter Rajnoha
91bb202ded dev-cache: handle situation where device is referenced in sysfs, but the node is not yet in dev dir
It's possible that while a device is already referenced in sysfs, the node
is not yet in /dev directory.

This may happen in some rare cases right after LVs get created - we sync
with udev (or alternatively we create /dev content ourselves) while VG
lock is held. However, dev scan is done without VG lock so devices may
already be in sysfs, but /dev may not be updated yet if we call LVM command
right after LV creation (so the fact that fs_unlock is done within VG
lock is not usable here much). This is not a problem with devtmpfs as
there's at least kernel name for device in /dev as soon as the sysfs
item exists, but we still support environments without devtmpfs or
where different directory for dev nodes is used (e.g. our test suite).

This patch covers these situations by tracking such devices in
_cache.sysfs_only_names helper hash for the vgid/lvid check to work still.

This also resolves commit 6129d2e64d
which was then reverted by commit 109b7e2095
due to performance issues it may have brought (...and it didn't resolve
the problem fully anyway).
2016-03-30 10:56:46 +02:00
Peter Rajnoha
109b7e2095 revert: 6129d2e64d
Unfortunately, commit 6129d2e64d may
cause performance issue. There's going to be a better fix...
2016-03-24 14:06:12 +01:00