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

1288 Commits

Author SHA1 Message Date
Zdenek Kabelac
adc1fe4b3f dmeventd: improved logged messages from thin plugin
Show better names in logged messages.
2016-07-04 17:40:24 +02:00
Zdenek Kabelac
b9d3e8c8a8 cleanup: drop unused assignments
In all code paths we set a value for these variables, so drop
their initial unused assign.
2016-07-01 00:44:48 +02:00
Zdenek Kabelac
1e3411aa37 cleanup: add extra test for argc==0
Cleaup some compiler warning about posibility to allocate 0 size.
2016-07-01 00:44:48 +02:00
Zdenek Kabelac
2f638e07e8 dmeventd: thin plugin umount over 95%
Run umount code only when either thin data or metadata are
above 95% - so if there are resize failures with 60%.
system fill keep running.

Also umount will only be tried with lvm2 LVs.
Foreign users are ATM unsuppored.
2016-07-01 00:43:45 +02:00
Tony Asleson
1d3532d0a7 lvmdbusd: Add --nojson command line option
Add ability to not use the JSON output even if available.
2016-06-28 13:32:39 -05:00
Tony Asleson
e6e5c3d3ec lvmdbusd: Remove WARNING for 'lvm help'
We call 'lvm help' to find out if fullreport is supported.  Lvm
dumps help to stderr.  Common code prints a warning if we exit
with 0, but have something in stderr so we are skipping the warning
message.
2016-06-28 12:54:48 -05:00
Tony Asleson
7c5a08521b lvmdbusd: Remove unneeded comment 2016-06-28 12:45:55 -05:00
Tony Asleson
9e3ad37828 lvmdbusd: Clean up ws 2016-06-28 12:45:28 -05:00
Tony Asleson
c11003c860 lvmdbusd: Remove unused imports and function parameter 2016-06-28 12:44:45 -05:00
Tony Asleson
dd5d865020 lvmdbusd: Fix hang when lvm compiled with 'enable-notify-dbus'
The following operations would hang if lvm was compiled with
'enable-notify-dbus' and the client specified -1 for the timeout:

* LV snapshot merge
* VG move
* LV move

This was caused because the implementation of these three dbus methods is
different.  Most of the dbus method calls are executed by gathering information
needed to fulfill it, placing that information on a thread safe queue and
returning.  The results later to be returned to the client with callbacks.
With this approach we can process an arbitrary number of commands without any
of them blocking other dbus commands.  However, the 3 dbus methods listed
above did not utilize this functionality because they were implemented with a
separate thread that handles the fork & exec of lvm.  This is done because these
operations can be very slow to complete.  However, because of this the lvm
command that we were waiting on is trying to call back into the dbus service to
notify it that something changed.  Because the code was blocking the process
that handles the incoming dbus activity the lvm command blocked.  We were stuck
until the client timed-out the connection, which then causes the service to
unblock and continue.  If the client did not have a timeout, we would have been
hung indefinitely.

The fix is to always utilize the worker queue on all dbus methods.  We need to
ensure that lvm is tested with 'enable-notify-dbus' enabled and disabled.
2016-06-28 12:09:28 -05:00
Tony Asleson
5274c2f11b lvmdbusd: request.py, initialize _job to None
_job is a job object, not a boolean so initialize it to None instead.
2016-06-28 12:09:28 -05:00
Tony Asleson
4f26eae40f lvmdbusd: Correct pv_seg_start -> pvseg_start
Code was using the incorrect column names for pvseg_start which only
became apparent when utilizing the JSON.
2016-06-28 12:09:28 -05:00
Tony Asleson
0aadd6b0fb lvmdbusd: Correct command line args for JSON
Use the updated syntax.
2016-06-28 12:09:28 -05:00
Tony Asleson
4b337b20d4 lvmdbusd: Remove sorting in db layer
When using the JSON this does not yield a totally sorted list as we don't
have a complete set of LVs, so remove this sort.
2016-06-28 12:09:28 -05:00
Tony Asleson
e514284c65 lvmdbusd: Add hidden in for json too 2016-06-28 12:09:28 -05:00
Tony Asleson
ec45be9976 lvmdbusd: Initial support for json output 2016-06-28 12:09:28 -05:00
David Teigland
a7c45ddc59 lvmetad: two phase vg_update
Previously, a command sent lvmetad new VG metadata in vg_commit().
In vg_commit(), devices are suspended, so any memory allocation
done by the command while sending to lvmetad, or by lvmetad while
updating its cache could deadlock if memory reclaim was triggered.

Now lvmetad is updated in unlock_vg(), after devices are resumed.
The new method for updating VG metadata in lvmetad is in two phases:

1. In vg_write(), before devices are suspended, the command sends
   lvmetad a short message ("set_vg_info") telling it what the new
   VG seqno will be.  lvmetad sees that the seqno is newer than
   the seqno of its cached VG, so it sets the INVALID flag for the
   cached VG.  If sending the message to lvmetad fails, the command
   fails before the metadata is committed and the change is not made.
   If sending the message succeeds, vg_commit() is called.

2. In unlock_vg(), after devices are resumed, the command sends
   lvmetad the standard vg_update message with the new metadata.
   lvmetad sees that the seqno in the new metadata matches the
   seqno it saved from set_vg_info, and knows it has the latest
   copy, so it clears the INVALID flag for the cached VG.

If a command fails between 1 and 2 (after committing the VG on disk,
but before sending lvmetad the new metadata), the cached VG retains
the INVALID flag in lvmetad.  A subsequent command will read the
cached VG from lvmetad, see the INVALID flag, ignore the cached
copy, read the VG from disk instead, update the lvmetad copy
with the latest copy from disk, (this clears the INVALID flag
in lvmetad), and use the correct VG metadata for the command.

(This INVALID mechanism already existed for use by lvmlockd.)
2016-06-28 02:30:31 +01:00
David Teigland
17ad29ebba lvmlockd: fix coverity report 2016-06-28 02:28:49 +01:00
David Teigland
47a29f6b2e lvmlockd: always try to connect to lvmetad
Reconnect to lvmetad if either the send fails (e.g. lvmetad
was restarted since lvmlockd last connected), or if no
lvmetad connection exists (e.g. lvmetad was started after
lvmlockd so no previous connection existed.)
2016-06-20 14:01:46 -05:00
David Teigland
6ae22125c6 vgcfgrestore: use lvmetad disabled state
Previously, vgcfgrestore would attempt to vg_remove the
existing VG from lvmetad and then vg_update to add the
restored VG.  But, if there was a failure in the command
or with vg_update, the lvmetad cache would be left incorrect.
Now, disable lvmetad before the restore begins, and then
rescan to populate lvmetad from disk after restore has
written the new VG to disk.
2016-06-20 11:19:49 -05:00
Tony Asleson
cdf06044e1 lvmdbusd: Create correct LV object type
We were initially looking to see if an LV was hidden and if it was we were
creating an instance of a LvCommon object to represent it.  Thus if we
had a hidden cache pool for example we were missing the methods and
properties for the cache pool.  However, when we create the object path,
any hidden LVs, regardless of type/functionality will be placed in the
hidden path.
2016-06-10 16:05:03 -05:00
Tony Asleson
b81186e535 lvmdbusd: Add method get_object_path_by_lvm_id
The object manager method get_object_by_lvm_id was used in many cases for
the sole reason of getting the object path for the object.  Instead of
retrieving the object and then calling 'dbus_object_path' on the object, we
are adding a method which returns the object path.
2016-06-10 16:04:43 -05:00
Tony Asleson
b717e8fe1d lvmdbusd: Rename get_object_path_by_lvm_id
Renaming to get_object_path_by_uuid_lvm_id, to clarify that both the uuid
and the lvm id are required.
2016-06-10 15:28:42 -05:00
Tony Asleson
41ebed7077 lvmdbusd: Change print statement to py3 syntax 2016-06-10 15:28:42 -05:00
Tony Asleson
b717c5efae lvmdbusd: Bug fix for missing LV properties
When we are processing the LVs we need to build up dbus objects from least
dependent to most dependent, so that we have information available when
constructing.
2016-06-10 15:28:42 -05:00
Tony Asleson
e04705b305 lvmdbusd: Add data_lv and metadata_lv to cache pool interface
See: https://bugzilla.redhat.com/show_bug.cgi?id=1342558
2016-06-10 15:28:42 -05:00
Tony Asleson
3bf43a65fe lvmdbusd: Add roles property to LV common interface
See: https://bugzilla.redhat.com/show_bug.cgi?id=1342559
2016-06-10 15:28:42 -05:00
David Teigland
ed6ffc7a34 lvmetad: handle update failures
If a command gets stuck during an lvmetad update, lvmetad
will cancel that update after the timeout.  The next command
to check the lvmetad will see that lvmetad needs to be
populated because lvmetad will return token of "none" after
a timed out update (same as when lvmetad is not populated
at all after starting.)

If a command gets an error during an lvmetad update, it
will now just quit and leave its updating token in place.
That update will be cancelled after the timeout.
2016-06-07 10:17:00 -05:00
David Teigland
851ccfccaf lvmetad: remove disabled case for "scan error"
Failures while populating lvmetad will be handling
differently in a subsequent commit.
2016-06-07 10:17:00 -05:00
David Teigland
0e7f352c70 lvmetad: define special update in progress string 2016-06-07 10:17:00 -05:00
Peter Rajnoha
fc37ee63c0 make: add generated parts of lvmdbusd to DISTCLEAN_TARGETS for make distclean 2016-06-02 11:58:54 +02:00
Peter Rajnoha
3d333e5a29 coverity: fix warnings about missing return value check for sscanf
All the variables for sscanf in lvmlockctl.c and lvmlockd-sanlock.c are
zeroed before sscanf call so the failure is detected by seeing the zero
value instead of proper one in subsequent code - so use (void) for
sscanf calls to ignore return value here.
2016-05-31 10:06:25 +02:00
Peter Rajnoha
48877e215d coverity: missing check for id_write_format return value 2016-05-31 09:56:10 +02:00
David Teigland
e0c22df5c4 lvmetad: remove old thread locking
The old thread locking is very fine grained and complex,
and appears to have no concurrency advantage.
2016-05-16 14:38:25 -05:00
David Teigland
9f72a52302 lvmetad: add request level thread locking
Use an rwlock for requests that read/write cache state.
Use a mutex for requests that read/write global info.
2016-05-16 14:38:04 -05:00
David Teigland
b1ea27b1e2 lvmetad: disable if device scan fails
If a command begins repopulating the lvmetad cache,
and fails part way through, it should set the disabled
state in lvmetad so other commands don't use bad data.
If a subsequent scan succeeds, the disabled state is
cleared.
2016-05-06 09:00:00 -05:00
David Teigland
3d2fbfe243 lvmetad: set disabled flag when duplicate PVs are seen
When duplicate PVs are detected, set the disabled
flag so that commands will disable use of lvmetad.

This duplicate detection is done by lvmetad itself
when it's told about a single new PV with a PVID
that matches an existing PV on another device.
(This is different from the case where the command
is scanning all devices and detects the duplicate.)

Remove the "altdev" logic that attempted to keep
track of multiple devices for a single PV.  It
is no longer used since lvmetad is disabled in
this case.
2016-05-06 08:59:59 -05:00
Zdenek Kabelac
a88828c845 coverity: check for sys error in clock call 2016-04-22 14:15:36 +02:00
Zdenek Kabelac
d12ba022c8 coverity: keep expression using 64bit
Use 64bit input to remain with whole evaluation in 64bit.
2016-04-22 14:15:36 +02:00
David Teigland
593900b795 lvmetad: use defines for disabled reason strings 2016-04-19 11:45:24 -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
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
1be74cfd7f cleanup: gcc warn about comparing int with uint 2016-04-12 11:47:51 +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
Tony Asleson
d243db5466 lvmdbusd: Add '-' to allowable PV device path chars 2016-03-24 12:27:02 -05:00
Alasdair G Kergon
1216efdf15 activate: Use macros for target and module names. 2016-03-22 17:46:15 +00:00
Tony Asleson
16b1272597 lvmdbusd: Change print statements to log_error
Should not be using print() in the service code.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2016-03-21 17:28:51 -05:00
Tony Asleson
ca28ea88be lvmdbusd: Add lvm flight recorder
To help out with debug, when an exception is thrown in the dbus service we
will dump all the information we have on the last 16 commands that were
executed along with the stack strace.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2016-03-21 17:28:51 -05:00
Tony Asleson
a0c7875c54 lvmdbusd: Allow PV devices to be referenced by symlink(s)
See: https://bugzilla.redhat.com/show_bug.cgi?id=1318754

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2016-03-21 17:28:51 -05:00
Tony Asleson
6d19c14c28 lvmdbus: Fix deprecated warnings for GObject use
While running on F24 a number of warnings were being emitted from using the
deprecated GObject instead of GLib.  Tested on python 3.4 and 3.5.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2016-03-08 16:07:35 -06:00