From: wysochanski@sourceware.org <wysochanski@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/lib/format_text format-text.c format-text ...
Date: 28 Jun 2010 20:31:02 -0000 [thread overview]
Message-ID: <20100628203102.13827.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2010-06-28 20:31:02
Modified files:
lib/format_text: format-text.c format-text.h layout.h
text_label.c
Log message:
Allow raw_read_mda_header to be called from text_label.c.
We'd like to pass in mda_header to vgname_from_mda(). In order to
do this, we need to call raw_read_mda_header() from text_label.c,
_text_read(), which gets called from the label_read() path, and
peers into the metadata and update vginfo cache. We should check
the disable bit here, and if set, not peer into the vg metadata,
thus reducing the I/O to disk.
In the process, move vgname_from_mda() to layout.h, since the fn
only gets called from format_text code, and we need the mda_header
definition from the private layout.h.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/layout.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
--- LVM2/lib/format_text/format-text.c 2010/06/28 20:30:46 1.126
+++ LVM2/lib/format_text/format-text.c 2010/06/28 20:31:01 1.127
@@ -37,9 +37,6 @@
#include <dirent.h>
#include <ctype.h>
-static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
- struct device_area *dev_area);
-
static struct format_instance *_text_create_text_instance(const struct format_type
*fmt, const char *vgname,
const char *vgid,
@@ -181,7 +178,7 @@
if (!dev_open(area->dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fmt, area)))
+ if (!(mdah = raw_read_mda_header(fmt, area)))
goto_out;
rlocn = mdah->raw_locns;
@@ -308,8 +305,8 @@
}
}
-static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
- struct device_area *dev_area)
+struct mda_header *raw_read_mda_header(const struct format_type *fmt,
+ struct device_area *dev_area)
{
struct mda_header *mdah;
@@ -459,7 +456,7 @@
if (!dev_open(dev_area->dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, dev_area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, dev_area)))
return_0;
if (_find_vg_rlocn(dev_area, mdah, vgname, &noprecommit))
@@ -483,7 +480,7 @@
char *desc;
uint32_t wrap = 0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, area)))
goto_out;
if (!(rlocn = _find_vg_rlocn(area, mdah, vgname, &precommitted))) {
@@ -583,7 +580,7 @@
if (!dev_open(mdac->area.dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area)))
goto_out;
rlocn = _find_vg_rlocn(&mdac->area, mdah,
@@ -689,7 +686,7 @@
if (!found)
return 1;
- if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area)))
goto_out;
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah,
@@ -800,7 +797,7 @@
if (!dev_open(mdac->area.dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area)))
goto_out;
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit))) {
@@ -1083,12 +1080,12 @@
}
const char *vgname_from_mda(const struct format_type *fmt,
+ struct mda_header *mdah,
struct device_area *dev_area, struct id *vgid,
uint64_t *vgstatus, char **creation_host,
uint64_t *mda_free_sectors)
{
struct raw_locn *rlocn;
- struct mda_header *mdah;
uint32_t wrap = 0;
const char *vgname = NULL;
unsigned int len = 0;
@@ -1099,8 +1096,10 @@
if (mda_free_sectors)
*mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
- if (!(mdah = _raw_read_mda_header(fmt, dev_area)))
+ if (!mdah) {
+ log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header");
goto_out;
+ }
/* FIXME Cope with returning a list */
rlocn = mdah->raw_locns;
@@ -1188,6 +1187,7 @@
struct format_instance fid;
struct id vgid;
uint64_t vgstatus;
+ struct mda_header *mdah;
raw_list = &((struct mda_lists *) fmt->private)->raws;
@@ -1201,13 +1201,20 @@
continue;
}
- if ((vgname = vgname_from_mda(fmt, &rl->dev_area, &vgid, &vgstatus,
+ if (!(mdah = raw_read_mda_header(fmt, &rl->dev_area))) {
+ stack;
+ goto close_dev;
+ }
+
+ if ((vgname = vgname_from_mda(fmt, mdah,
+ &rl->dev_area, &vgid, &vgstatus,
NULL, NULL))) {
vg = _vg_read_raw_area(&fid, vgname, &rl->dev_area, 0);
if (vg)
lvmcache_update_vg(vg, 0);
}
+ close_dev:
if (!dev_close(rl->dev_area.dev))
stack;
}
--- LVM2/lib/format_text/format-text.h 2009/11/24 22:55:56 1.26
+++ LVM2/lib/format_text/format-text.h 2010/06/28 20:31:01 1.27
@@ -59,9 +59,4 @@
struct device *dev, uint64_t start, uint64_t size);
void del_mdas(struct dm_list *mdas);
-const char *vgname_from_mda(const struct format_type *fmt,
- struct device_area *dev_area, struct id *vgid,
- uint64_t *vgstatus, char **creation_host,
- uint64_t *mda_free_sectors);
-
#endif
--- LVM2/lib/format_text/layout.h 2010/06/28 20:29:57 1.11
+++ LVM2/lib/format_text/layout.h 2010/06/28 20:31:01 1.12
@@ -76,6 +76,9 @@
struct raw_locn raw_locns[0]; /* NULL-terminated list */
} __attribute__ ((packed));
+struct mda_header *raw_read_mda_header(const struct format_type *fmt,
+ struct device_area *dev_area);
+
struct mda_lists {
struct dm_list dirs;
struct dm_list raws;
@@ -96,4 +99,11 @@
#define LVM2_LABEL "LVM2 001"
#define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize())
+
+const char *vgname_from_mda(const struct format_type *fmt,
+ struct mda_header *mdah,
+ struct device_area *dev_area, struct id *vgid,
+ uint64_t *vgstatus, char **creation_host,
+ uint64_t *mda_free_sectors);
+
#endif
--- LVM2/lib/format_text/text_label.c 2010/06/28 20:30:46 1.29
+++ LVM2/lib/format_text/text_label.c 2010/06/28 20:31:01 1.30
@@ -262,6 +262,7 @@
const char *vgname;
uint64_t vgstatus;
char *creation_host;
+ struct mda_header *mdah;
pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
@@ -303,13 +304,23 @@
stack;
continue;
}
- if ((vgname = vgname_from_mda(info->fmt, &mdac->area,
+ if (!(mdah = raw_read_mda_header(info->fmt, &mdac->area))) {
+ stack;
+ goto close_dev;
+ }
+
+ if ((vgname = vgname_from_mda(info->fmt, mdah,
+ &mdac->area,
&vgid, &vgstatus, &creation_host,
&mdac->free_sectors)) &&
!lvmcache_update_vgname_and_id(info, vgname,
(char *) &vgid, vgstatus,
- creation_host))
+ creation_host)) {
+ if (!dev_close(mdac->area.dev))
+ stack;
return_0;
+ }
+ close_dev:
if (!dev_close(mdac->area.dev))
stack;
}
reply other threads:[~2010-06-28 20:31 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=20100628203102.13827.qmail@sourceware.org \
--to=wysochanski@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.