From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: stable-2.02 - pvscan: use orphans lock to fix parallel pvscan and vgcreate
Date: Fri, 20 Aug 2021 14:42:50 +0000 (GMT) [thread overview]
Message-ID: <20210820144250.EF5F5385DC15@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=90597a4b6e4fc471a8f14cf5ca30f54387a80f3d
Commit: 90597a4b6e4fc471a8f14cf5ca30f54387a80f3d
Parent: 1afa67f4b9bdeb1e0da1cda17695d0aa58f7c3e3
Author: Wu Guanghao <wuguanghao3@huawei.com>
AuthorDate: Thu Aug 19 09:30:08 2021 -0500
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Fri Aug 20 09:42:37 2021 -0500
pvscan: use orphans lock to fix parallel pvscan and vgcreate
start pvscan --cache /dev/sdb
(read metadata from disk, no vg info)
pvcreate /dev/sdb
vgcreate vg /dev/sdb
(write vg information to metadata, and update lvmetad)
finish pvscan --cache /dev/sdb
(No vg information in metadata from disk, overwrite lvmetad)
vgs
couldn't find vg
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
---
tools/pvscan.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 2e7a864de..51b5daa9a 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -491,6 +491,11 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_READ, NULL)) {
+ log_error("Can't get lock for orphan PVs.");
+ return ECMD_FAILED;
+ }
+
/*
* This a special case where use_lvmetad=1 in lvm.conf but pvscan
* cannot use lvmetad for some reason. In this case pvscan should
@@ -780,6 +785,7 @@ out:
if (!sync_local_dev_names(cmd))
stack;
+ unlock_vg(cmd, NULL, VG_ORPHANS);
unlock_vg(cmd, NULL, VG_GLOBAL);
return ret;
}
reply other threads:[~2021-08-20 14:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210820144250.EF5F5385DC15@sourceware.org \
--to=teigland@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.