LVM2/lib/metadata metadata-exported.h metadata.c
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2010-05-19 11:52:38
Modified files:
lib/metadata : metadata-exported.h metadata.c
Log message:
Add find_vgname_from_{pvname|pvid} functions.
Some commands start with a pvname, but we'd like to force users to start with a vg handle to obtain a pv handle. Our best option seems to be providing a way to look up the vgname from the pvname, and then require them to use vg_read/vg_open.
In addition to the pvname lookup function, this patch also provides a lookup by pvid. The lookup by pvid can be used in conjunction with lvmcache_get_pvids to process all pvs in the system.
The pvid find function first calls lvmcache_vgname_from_pvid, which may cause the label to be read if it is not in the cache. If the vgname is returned is an orphan, we then check to see if there are metadata areas, and if not, we scan every PV on the system by calling scan_vgs_for_pvs(). In most cases we should not need to do this, and by using the info->mdas count, we avoid calling pv_read() as prior code did. So this patch is a bit cleaner and should allow us to refactor more of the pv code.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.145&r2=1.146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.342&r2=1.343
lib/metadata/metadata-exported.h +4 -0
@@ -625,6 +625,10 @@struct physical_volume *find_pv_by_name (struct cmd_context *cmd,const char *pv_name); +const char *find_vgname_from_pvname (struct cmd_context *cmd, +const char *pvname); +const char *find_vgname_from_pvid (struct cmd_context *cmd, +const char *pvid);/* Find LV segment containing given LE */ struct lv_segment *first_seg (const struct logical_volume *lv);
lib/metadata/metadata.c +46 -0
52 lines not on this page · raw message