diff options
author | Alasdair Kergon <agk@redhat.com> | 2008-01-29 23:45:48 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2008-01-29 23:45:48 +0000 |
commit | 962b2a559dde931e5e519706b755bf2764b8338a (patch) | |
tree | 7dd18ea0e5679fe76316f95bb88c6d6ada1ebd32 /lib/label/label.c | |
parent | 8abe9ec33d3828756907f224ba8ebc20a9baba33 (diff) | |
download | lvm2-962b2a559dde931e5e519706b755bf2764b8338a.tar.gz lvm2-962b2a559dde931e5e519706b755bf2764b8338a.tar.xz lvm2-962b2a559dde931e5e519706b755bf2764b8338a.zip |
Rely upon internally-cached PV labels while corresponding VG lock is held.
Diffstat (limited to 'lib/label/label.c')
-rw-r--r-- | lib/label/label.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/label/label.c b/lib/label/label.c index f08dfe30..e0454d01 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -179,7 +179,7 @@ static struct labeller *_find_labeller(struct device *dev, char *buf, out: if (!found) { - if ((info = info_from_pvid(dev->pvid))) + if ((info = info_from_pvid(dev->pvid, 0))) lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN, 0, NULL); log_very_verbose("%s: No label detected", dev_name(dev)); @@ -260,7 +260,6 @@ int label_remove(struct device *dev) return r; } -/* FIXME Avoid repeated re-reading if cache lock held */ int label_read(struct device *dev, struct label **result, uint64_t scan_sector) { @@ -270,10 +269,16 @@ int label_read(struct device *dev, struct label **result, struct lvmcache_info *info; int r = 0; + if ((info = info_from_pvid(dev->pvid, 1))) { + log_debug("Using cached label for %s", dev_name(dev)); + *result = info->label; + return 1; + } + if (!dev_open(dev)) { stack; - if ((info = info_from_pvid(dev->pvid))) + if ((info = info_from_pvid(dev->pvid, 0))) lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN, 0, NULL); @@ -353,7 +358,7 @@ int label_verify(struct device *dev) int r = 0; if (!dev_open(dev)) { - if ((info = info_from_pvid(dev->pvid))) + if ((info = info_from_pvid(dev->pvid, 0))) lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN, 0, NULL); |