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

1851 Commits

Author SHA1 Message Date
Zdenek Kabelac
1bb03cff66 lvmdbusd: its fine if dir already exists
With previous patch, we now need to handle the case
when dir already exists.
2024-04-29 00:13:43 +02:00
Zdenek Kabelac
7c4be946cb dmeventd: use standard reopening mechanism
Apply same code for reopening /dev/null for 0,1,2 when daemonizing.
2024-04-27 00:36:24 +02:00
Kai Kang
b3189d9b15 lvmdbusd: create dirs for lock file
Create leading dirs for lvmdbusd lock file, otherwise it fails to start:

| systemd[1]: Starting LVM2 D-Bus service...
| lvmdbusd[1602]: [1602]: Error during creation of lock file(/var/lock/lvm/lvmdbusd): errno(2), exiting!

Signed-off-by: Kai Kang <kai.kang@windriver.com>
2024-04-26 23:17:56 +02:00
Zdenek Kabelac
d0cfe73326 cov: unused headers 2024-04-26 00:13:34 +02:00
Zdenek Kabelac
078445658c configure.ac: update ldflags args
Attach -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
to LDFLAGS, but only if LDFLAGS already doesn't contain 'relro'
(so it's not given repeatedly).

Also start to use -z,now linkage also when building libraries
with default compilation - this avoid calling symbol resolver
while library function are using function needing resolving.

Note: Fedora or RHEL rpm building is using:
CFLAGS=$(rpm --eval %{build_cflags})
LDFLAGS=$(rpm --eval %{build_ldflags})

Also split -DUSE_SD_NOTIFY into DEFS from CFLAGS.
2024-04-24 00:31:26 +02:00
Zdenek Kabelac
79bb9e3172 libdevmapper: _do_event waits for working dmeventd
Refactor _start_daemon and add synchronization delay waiting
untill new forked dmeventd actually open fifos and is ready
to process messages.

This closes some race window in testing.
2024-04-19 23:56:16 +02:00
David Teigland
85b711caae lvmlockd: check for multiple lock managers running
When no lock manager for the global lock had been set yet,
and the first global lock request was received, and both
dlm and sanlock were running, lvmlockd would assume it
should use the dlm for the global lock, and would start
the "lvm_global" dlm lockspace automatically.  That's
not always correct, so don't assume the dlm should be used,
fail the lock request, and wait until a VG with a specific
lock type is started to determine the lock manager to use.
2024-04-19 10:53:37 -05:00
Zdenek Kabelac
716fc27fdd dmeventd: use daemon_close_stray_fds
Use common code for close stray descriptors.
2024-04-15 13:38:44 +02:00
Zdenek Kabelac
2ea8afba93 dmeventd: typo fix
Fix typo and minor reorder of struct member for better alignment.
2024-04-15 12:58:27 +02:00
Zdenek Kabelac
d6b15e755e dmeventd: reduce some static variable usage
Move static to main() local vars.

Initilize libdm logging also before starting _restart_dmeventd()
so function there can be also logged.

Move call of _info_dmevent() out of option processing - so some
options like -V are processed with higher priority.
2024-04-12 00:20:43 +02:00
Zdenek Kabelac
5e3224c57d dmeventd: no log when after unlink file is gone
Check for errno ENOENT.

TODO: there should be global wrapper for this...
2024-04-12 00:14:03 +02:00
Zdenek Kabelac
54840d867e devmapper-event: add unlock into init_fifo error path
Unlock server path if there is open failure for client_path
and whole init_fifos() function is returning failure.
2024-04-12 00:14:02 +02:00
Zdenek Kabelac
3a433b14f2 dmeventd: rework _restart_dmeventd
Use _restart_dmeventd() with return values 0,1,2.
Also let's use already created fifos struct.

Make sure the _systemd_activation variable is properly initialized
from _systemd_handover before calling _restart_dmeventd() as
this variable is used there to decide where   1 or 2 should
be returned - aka either letting systemd to initilize
or restart dmeventd itself.
2024-04-12 00:14:01 +02:00
David Teigland
449af6c335 lvmlockd: use sanlock.h for defines 2024-04-11 10:50:06 -05:00
Zdenek Kabelac
2b9c3f8dc9 cov: pass buffer size 2024-04-10 00:03:09 +02:00
Zdenek Kabelac
82f50dc800 gcc: remove warning about inlining failure
Persuade gcc we want this function to be inline and avoid:
  warning: inlining failed in call to ‘lvmlockd_open.constprop.0’:
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
2b802ab413 cov: use check of snprintf result
Do validation in one go with snprintf() result,
so there is no extra strlen() and uncheck possibly truncating snprintf()
visible to coverity.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
22a0cfdc05 cov: use memccpy
When we want to copy string which may not be null terminated,
replace strncpy with more correct memccpy.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
f27273e1f0 dmeventd: restart checks for running daemon
Check whether the pid file is associated with running daemon.
If not there is not much point to wait many seconds in loop.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
092951f634 dmeventd: check for running dmeventd for status
Before initiation fifo communication, check whether there is
running dmeventd - in case there is no running instance, this
would be just blocked for 5 seconds trying to open fifo.
2024-04-08 22:24:18 +02:00
Zdenek Kabelac
88ad83e3d6 makefiles: use SHOW 2024-04-08 14:52:23 +02:00
Zdenek Kabelac
d490572410 gcc: clear some complains
Use dm_strncpy() were possible to get rid of gcc compile warnings.
2024-04-08 14:52:23 +02:00
Zdenek Kabelac
5dec664ccf lvmlocks: rework dm_strncpy
Fix cutting away 1 character via incorrect usage of dm_strncpy
introduced in last batch of commits and use sizeof(buffer) to
get proper sizes.

In case of use strcpy_name_len() the replacement was invalid,
so we need to restore this case since sanlock uses buffer without
nul ending, so we would strip one more character from the buffer.

Also start to use dm_strncpy() without (void) for unchecked usage.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
f9fefaaabe refactor: update dm_strncpy to _dm_strncpy
For checked versions of dm_strncpy use inline wrapper _dm_strncpy.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
995ff58903 refactor: remove (void) from dm_strncpy usage
Start to use dm_strncpy() as unchecked version within source tree.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
5c0ade35e2 util: swap header file load order
Ensure libdevmapper is included before util.h since
we are going to add function that is using it.
TODO: maybe add include directly here...
2024-04-04 19:33:58 +02:00
Zdenek Kabelac
eba277bca8 cov: cast to uint32 2024-03-29 01:36:48 +01:00
Zdenek Kabelac
fe2294769c cov: use dm_strncpy
Use better variant.
2024-03-28 22:19:45 +01:00
Zdenek Kabelac
2b7d0db7f1 cov: no overwrite of const qualified fields 2024-03-28 22:19:14 +01:00
Tony Asleson
3430395c85 lvmdbusd: Exit faster
Add a global timeout value to be used for the threads to end waiting for
whatever it is they are blocked on.  The values varied from 2-5 seconds,
which is way longer than needed.  Value of 0.5 shows no CPU load when
service is running and is idle.
2024-03-28 18:18:37 +01:00
Zdenek Kabelac
1d150d63c7 cov: ensure nul ends string 2024-03-28 18:18:37 +01:00
Zdenek Kabelac
8716d8c188 cov: check for to_dlm_mode return value
Avoid processing invalid to_dlm_mode in lm_convert_dlm.
2024-03-25 14:45:09 +01:00
Zdenek Kabelac
bca6f58848 cov: ensure string ends with \0
Use dm_strncpy() that ensures \0 termination.
2024-03-25 11:18:29 +01:00
Zdenek Kabelac
df9e5f39a7 debug: correct check for failing close 2023-10-02 14:13:12 +02:00
Zdenek Kabelac
e930ee93f7 debug: correct level
No error for just tracing message.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
a9d7a9d128 dmeventd: implement exit_on file check
When exit on file is present in a system and term/break signal is
catched, them dmeventd is no longger refusing to exit.

For the correct shutdown, there should be ideally unmonitoring call,
however in some case it's very hard to implement this correct procedure.

With this 'exit on' file dmeventd at least avoid 'blocking' shutdown,
before systemd kills use with -9 anyway possibly even in some unwanted
stated of internal dmeventd processing (i.e. in the middle of some lvm
command processing).
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
80d34abf49 dmeventd: info status report
To quickly get info about some internal dmeventd status,
implment   'dmeventd -i' support.

Reported messages are some 'raw' internal informations mainly
useful to developers.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
637d812df5 dmeventd: unregister all devices on restart
Instead of just exiting in the middle of monitoring,
unregisted all monitored devices first and then exit.

To speedup this path, all send internal SIGINT when thread
unregiters itself, to wakup-up main sleeping loop.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
c31dcf3632 dmeventd: use return
Use 'return' instead of calling exit() when possible.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
396024713f dm-event: reset descriptors
Reset descriptors after closing them to -1.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
a203499ba3 dm-event: release buffer on dm_event_get_version
Avoid memory leak in this function.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
90713c84f3 dm-event: enhance timestamp for debugging
Add microseconds for timestamps in dm-event trace messages.
Also collect timestamps only when debugging when they are used.
2023-09-26 01:23:00 +02:00
Zdenek Kabelac
a8fd6de907 lvmdbusd: fix syntax warning
python3.12 reported SyntaxWarning: invalid escape sequence '\/'
2023-09-20 15:55:28 +02:00
Zdenek Kabelac
984c024ef2 typos: misc 2023-09-19 14:54:51 +02:00
Zdenek Kabelac
97770d5aeb debug: check for syscalls
Add some debug checks for possibly failing syscalls.
2023-09-03 22:03:33 +02:00
Zdenek Kabelac
29630b2d7f dmeventd: move var set to locked section
It should not change the actual code flow, however make the
set of the current_event variable inside locked section.
2023-09-03 22:03:33 +02:00
David Teigland
c37416b6aa lvmlockd: client mutex ordering
Avoid deadlock between threads on mutexes (in theory.)
2023-08-31 13:15:07 -05:00
Zdenek Kabelac
728617d25d gcc: cleanup warnings
Correcting signess comparation.
Also use standalone /* fall through */ comment as that's
the only one supported by gcc to quiet warning.
2023-08-16 15:13:25 +02:00
Zdenek Kabelac
7171260b94 makefiles: install lvmdbusd executable
Use a different mechanism to ensure, lvmdbudd is executable at
install destination.
2023-07-13 21:31:18 +02:00
Zdenek Kabelac
5ce236a691 gcc: correct signess comparation
Compare int to int and unsigned to unsigned...
2023-07-13 21:31:18 +02:00