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

1314 Commits

Author SHA1 Message Date
Heinz Mauelshagen
5d455b28fc lvconvert: fix (automatic) raid repair regression
The dm-raid target now rejects device rebuild requests during ongoing
resynchronization thus causing 'lvconvert --repair ...' to fail with
a kernel error message. This regresses with respect to failing automatic
repair via the dmeventd RAID plugin in case raid_fault_policy="allocate"
is configured in lvm.conf as well.

Previously allowing such repair request required cancelling the
resynchronization of any still accessible DataLVs, hence reasoning
potential data loss.

Patch allows the resynchronization of still accessible DataLVs to
finish up by rejecting any 'lvconvert --repair ...'.

It enhances the dmeventd RAID plugin to be able to automatically repair
by postponing the repair after synchronization ended.

More tests are added to lvconvert-rebuild-raid.sh to cover single
and multiple DataLV failure cases for the different RAID levels.

- resolves: rhbz1371717
2016-09-21 00:39:29 +02:00
Tony Asleson
ed37b4a626 lvmdbusd: Assign percentage on set 2016-09-19 15:32:47 -05:00
Tony Asleson
ec821d37a8 lvmdbusd: Correct imports
Place the imports in the files where they are directly needed.
2016-09-19 15:32:47 -05:00
Tony Asleson
9cb8865511 lvmdbusd: Fix dbus object with only properties and no method
Gris debugged that when we don't have a method the introspection
data is missing the interface itself eg.

<interface name="<your_obj_iface_name>" />

When adding the properties to the dbus object introspection we will
add the interface too if it's missing.  This now allows us the
ability to have a dbus object with only properties.
2016-09-19 15:32:47 -05:00
Tony Asleson
5366e87574 lvmdbusd: Set value to non none on error
When we register a failure we need to use a valid value which will be
returned with the object manager.  Otherwise we will raise an Exception
because we are trying to construct an object path from None.
2016-09-19 15:31:04 -05:00
Tony Asleson
ac2fc7a366 lvmdbusd: Vg.LvCreate* methods, correct return type
The methods were returning an instance of the object instead of the
object path which was causing an exception when the result was returned
with the job object as we are explicity trying to return an object path.

Unit test added which re-creates the issue and verifies the fix.
2016-09-19 15:31:04 -05:00
Zdenek Kabelac
6064a5084e cleanup: clean gcc6 minor/major types warnings
Put sys/sysmacros.h in front of sys/types.h header file as requested
by gcc6 part II.
2016-09-07 16:42:34 +02:00
Zdenek Kabelac
b26604c8d8 dmeventd: typo and debug name fix
Fix 'raw' -> 'row' fix.
Consitently use thin pool as a type of monitored device in info message.
2016-08-31 11:13:59 +02:00
Tony Asleson
7412690dd2 lvmdbusd: Prefix tag string with '@' 2016-08-29 18:00:21 -05:00
Tony Asleson
5392a612dc lvmdbusd: WS/pep8 corrections 2016-08-29 15:28:06 -05:00
Tony Asleson
1870b3293a lvmdbusd/lvmdb.py: Make stand alone execution work
This was broken when the args were moved to cfg
2016-08-29 15:26:56 -05:00
Tony Asleson
96a0604bd0 lvmdbusd: Correct imports 2016-08-29 15:26:56 -05:00
Tony Asleson
70d4e2e8d5 lvmdbusd: Handle different daemon options
- Prevent --lvmshell with --nojson, not a valid combination
- If user is preventing json, then no lvmshell usage
- Return boolean on Manager.UseLvmShell
2016-08-29 15:26:56 -05:00
Tony Asleson
9241dbdf57 lvmdbusd: Correct return type for empty PeSegments 2016-08-29 15:26:56 -05:00
Tony Asleson
20318e4c6c lvmdbusd: Be more specific on return types for Lv 2016-08-29 15:26:56 -05:00
Tony Asleson
0985b2d0d4 lvmdbusd: Make job.Percent a double 2016-08-29 15:26:55 -05:00
Tony Asleson
2bb09b4015 lvmdbusd: Be more explicit on return values
The python dbus library tries to make best on what the dbus type is based on
python data type.  Some times it gets this wrong, so we will be explicit.
2016-08-29 15:26:55 -05:00
Tony Asleson
4902034c89 lvmdbusd: Use udev until ExternalEvent occurs
The normal mode of operation will be to monitor for udev events until an
ExternalEvent occurs.  In that case the service will disable monitoring
for udev events and use ExternalEvent exclusively.

Note: User specifies --udev the service will always monitor udev regardless
if ExternalEvent is being called too.
2016-08-29 15:26:55 -05:00
Tony Asleson
2352ff24a5 lvmdbusd: Add support for using lvm shell
With the addition of JSON and the ability to get output which is known to
not contain any extraneous text we can now leverage lvm shell, so that we
don't fork and exec lvm command line repeatedly.
2016-08-29 15:26:55 -05:00
Tony Asleson
a0a2c84a26 lvmdbusd: Add date & ts if running in a terminal
When we are running in a terminal it's useful to have a date & ts on log
output like you get when output goes to the journal.  Check if we are
running on a tty and if we are, add it in.
2016-08-29 15:26:55 -05:00
Tony Asleson
7e37e7fde4 lvmdbusd: Always fork & exec background commands
Our background job support requires a separate instance of lvm.  Use the
full lvm command to do so.
2016-08-29 15:26:55 -05:00
Tony Asleson
4bc351d658 lvmdbusd: Add '-y' to lvconvert for lv cache create
When converting to a cache lv, tests were hanging with a prompt for
"Do you want wipe existing metadata of cache pool volume
To preserve cache metadata add option "--zero n".
WARNING: Reusing mismatched cache pool metadata MAY DESTROY YOUR DATA!"

This is new.
2016-07-28 11:13:29 -05:00
Tony Asleson
20b21f4fd8 lvmdbusd: Fix hang for Job.Wait(n)
When a client is doing a wait on a job, any other clients will hang
when trying to do anything with the service.  This is caused by
the wait code which  was placing the thread that handles
incoming dbus requests to sleep until either the timeout expired or
the job operation completed.

This change creates a thread for the wait request, so that the thread
processing incoming requests can continue to run.
2016-07-28 11:13:29 -05:00
David Teigland
d0e15b86b5 lvmlockd: improve error message about missing global lock
If the VG holding the global lock is removed, we can indicate
that as the reason for not being able to acquire the global
lock in subsequent error messages, and can suggest enabling
the global lock in another VG.  (This helpful error message
will go away if the global lock is enabled in another VG,
or if lvmlockd is restarted.)
2016-07-25 14:49:01 -05:00
David Teigland
4b4d467004 lvmetad: free memory on exit
This is unnecessary but it quiets complaints (valgrind).
2016-07-18 11:31:00 -05:00
Zdenek Kabelac
4e1bf7acd3 coverity: add some tests for function results
Even though they cannot normally happen...
2016-07-13 21:52:14 +02:00
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