diff options
author | David Teigland <teigland@redhat.com> | 2022-08-30 14:40:48 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-08-30 14:52:00 -0500 |
commit | 0eebd9d7802c724ee71b6ebb80940ea6007f9c7a (patch) | |
tree | 13e5da72d7626b5b6366ea43b7fa418fc72703e6 /lib | |
parent | 3c49a2e43ccfbad720a3134484c7870a14b1135b (diff) | |
download | lvm2-0eebd9d7802c724ee71b6ebb80940ea6007f9c7a.tar.gz |
vgimportdevices: fix locking when creating devices file
Take the devices file lock before creating a new devices file.
(Was missed by the change to preemptively create the devices
file prior to setup_devices(), which was done to improve the
error path.)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/device/dev-cache.c | 7 | ||||
-rw-r--r-- | lib/device/device_id.c | 1 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 193eb7585..85f9b499a 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -1937,10 +1937,9 @@ int setup_devices(struct cmd_context *cmd) if (!file_exists) { /* - * pvcreate/vgcreate/vgimportdevices/lvmdevices-add create - * a new devices file here if it doesn't exist. - * They have the create_edit_devices_file flag set. - * First they create/lock-ex the devices file lockfile. + * pvcreate/vgcreate create a new devices file here if it + * doesn't exist. They have create_edit_devices_file=1. + * First create/lock-ex the devices file lockfile. * Other commands will not use a devices file if none exists. */ lock_mode = LOCK_EX; diff --git a/lib/device/device_id.c b/lib/device/device_id.c index 6c70f110c..a0a626533 100644 --- a/lib/device/device_id.c +++ b/lib/device/device_id.c @@ -2468,6 +2468,7 @@ static int _lock_devices_file(struct cmd_context *cmd, int mode, int nonblock, i if (_devices_file_locked == mode) { /* can happen when a command holds an ex lock and does an update in device_ids_validate */ + /* can happen when vgimportdevices calls this directly, followed later by setup_devices */ if (held) *held = 1; return 1; |