mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-09 01:18:39 +03:00
Move dev_open/dev_close outside vgname_from_mda().
Refactor vgname_from_mda() so caller must open/close the device. Should be no functional change. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
This commit is contained in:
parent
96597c2eab
commit
da0b4d8770
@ -1099,9 +1099,6 @@ const char *vgname_from_mda(const struct format_type *fmt,
|
|||||||
if (mda_free_sectors)
|
if (mda_free_sectors)
|
||||||
*mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
|
*mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
|
||||||
|
|
||||||
if (!dev_open(dev_area->dev))
|
|
||||||
return_NULL;
|
|
||||||
|
|
||||||
if (!(mdah = _raw_read_mda_header(fmt, dev_area)))
|
if (!(mdah = _raw_read_mda_header(fmt, dev_area)))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
@ -1179,9 +1176,6 @@ const char *vgname_from_mda(const struct format_type *fmt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!dev_close(dev_area->dev))
|
|
||||||
stack;
|
|
||||||
|
|
||||||
return vgname;
|
return vgname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,20 +1196,20 @@ static int _scan_raw(const struct format_type *fmt)
|
|||||||
|
|
||||||
dm_list_iterate_items(rl, raw_list) {
|
dm_list_iterate_items(rl, raw_list) {
|
||||||
/* FIXME We're reading mdah twice here... */
|
/* FIXME We're reading mdah twice here... */
|
||||||
|
if (!dev_open(rl->dev_area.dev)) {
|
||||||
|
stack;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((vgname = vgname_from_mda(fmt, &rl->dev_area, &vgid, &vgstatus,
|
if ((vgname = vgname_from_mda(fmt, &rl->dev_area, &vgid, &vgstatus,
|
||||||
NULL, NULL))) {
|
NULL, NULL))) {
|
||||||
if (!dev_open(rl->dev_area.dev)) {
|
|
||||||
stack;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vg = _vg_read_raw_area(&fid, vgname, &rl->dev_area, 0);
|
vg = _vg_read_raw_area(&fid, vgname, &rl->dev_area, 0);
|
||||||
if (vg)
|
if (vg)
|
||||||
lvmcache_update_vg(vg, 0);
|
lvmcache_update_vg(vg, 0);
|
||||||
|
|
||||||
if (!dev_close(rl->dev_area.dev))
|
|
||||||
stack;
|
|
||||||
}
|
}
|
||||||
|
if (!dev_close(rl->dev_area.dev))
|
||||||
|
stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -299,6 +299,10 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf,
|
|||||||
|
|
||||||
dm_list_iterate_items(mda, &info->mdas) {
|
dm_list_iterate_items(mda, &info->mdas) {
|
||||||
mdac = (struct mda_context *) mda->metadata_locn;
|
mdac = (struct mda_context *) mda->metadata_locn;
|
||||||
|
if (!dev_open(mdac->area.dev)) {
|
||||||
|
stack;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ((vgname = vgname_from_mda(info->fmt, &mdac->area,
|
if ((vgname = vgname_from_mda(info->fmt, &mdac->area,
|
||||||
&vgid, &vgstatus, &creation_host,
|
&vgid, &vgstatus, &creation_host,
|
||||||
&mdac->free_sectors)) &&
|
&mdac->free_sectors)) &&
|
||||||
@ -306,6 +310,8 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf,
|
|||||||
(char *) &vgid, vgstatus,
|
(char *) &vgid, vgstatus,
|
||||||
creation_host))
|
creation_host))
|
||||||
return_0;
|
return_0;
|
||||||
|
if (!dev_close(mdac->area.dev))
|
||||||
|
stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->status &= ~CACHE_INVALID;
|
info->status &= ~CACHE_INVALID;
|
||||||
|
Loading…
Reference in New Issue
Block a user