public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: wysochanski@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 lib/metadata/metadata-exported.h lib/meta ...
Date: Tue, 28 Jul 2009 13:17:00 -0000	[thread overview]
Message-ID: <20090728131705.1453.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-28 13:17:04

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : .exported_symbols lvm.h lvm_vg.c 
	test/api       : test.c 

Log message:
	Add lvm_vg_get_seqno, updating lvm.h and unit test.
	
	Adding the ability to get the seqno is important for an application to
	determine if something has changed in a VG.  Otherwise, the only way to
	know is to open the VG with write permission and hold the handle.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.270&r2=1.271
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/test.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21

--- LVM2/lib/metadata/metadata-exported.h	2009/07/27 17:43:40	1.103
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/28 13:17:04	1.104
@@ -705,6 +705,7 @@
 uint64_t lv_size(const lv_t *lv);
 
 int vg_missing_pv_count(const vg_t *vg);
+uint32_t vg_seqno(const vg_t *vg);
 uint32_t vg_status(const vg_t *vg);
 uint64_t vg_size(const vg_t *vg);
 uint64_t vg_free(const vg_t *vg);
--- LVM2/lib/metadata/metadata.c	2009/07/27 17:43:40	1.270
+++ LVM2/lib/metadata/metadata.c	2009/07/28 13:17:04	1.271
@@ -3424,6 +3424,11 @@
 	return info ? dm_list_size(&info->mdas) : UINT64_C(0);
 }
 
+uint32_t vg_seqno(const vg_t *vg)
+{
+	return vg->seqno;
+}
+
 uint32_t vg_status(const vg_t *vg)
 {
 	return vg->status;
--- LVM2/liblvm/.exported_symbols	2009/07/28 11:03:28	1.21
+++ LVM2/liblvm/.exported_symbols	2009/07/28 13:17:04	1.22
@@ -6,6 +6,7 @@
 lvm_pv_get_name
 lvm_pv_get_uuid
 lvm_pv_get_mda_count
+lvm_vg_get_seqno
 lvm_vg_get_name
 lvm_vg_get_uuid
 lvm_vg_get_size
--- LVM2/liblvm/lvm.h	2009/07/28 13:16:40	1.39
+++ LVM2/liblvm/lvm.h	2009/07/28 13:17:04	1.40
@@ -49,6 +49,17 @@
  * A volume group handle may be obtained with read or write permission.
  * Any attempt to change a property of a pv_t, vg_t, or lv_t without
  * obtaining write permission on the vg_t will fail with EPERM.
+ *
+ * An application first opening a VG read-only, then later wanting to change
+ * a property of an object must first close the VG and re-open with write
+ * permission. Currently liblvm provides no mechanism to determine whether
+ * the VG has changed on-disk in between these operations - this is the
+ * application's responsiblity. One way the application can ensure the VG
+ * has not changed is to save the "vg_seqno" field after opening the VG with
+ * READ permission. If the application later needs to modify the VG, it can
+ * close the VG and re-open with WRITE permission. It should then check
+ * whether the original "vg_seqno" obtained with READ permission matches
+ * the new one obtained with WRITE permission.
  */
 
 /**
@@ -470,6 +481,21 @@
 int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size);
 
 /**
+ * Get the current metadata sequence number of a volume group.
+ *
+ * The metadata sequence number is incrented for each metadata change.
+ * Applications may use the sequence number to determine if any LVM objects
+ * have changed from a prior query.
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Metadata sequence number.
+ */
+uint64_t lvm_vg_get_seqno(const vg_t *vg);
+
+/**
  * Get the current name of a volume group.
  *
  * Memory is allocated using dm_malloc() and caller must free the memory
--- LVM2/liblvm/lvm_vg.c	2009/07/28 09:56:48	1.21
+++ LVM2/liblvm/lvm_vg.c	2009/07/28 13:17:04	1.22
@@ -223,6 +223,11 @@
 	return list;
 }
 
+uint64_t lvm_vg_get_seqno(const vg_t *vg)
+{
+	return vg_seqno(vg);
+}
+
 /* FIXME: invalid handle? return INTMAX? */
 uint64_t lvm_vg_get_size(const vg_t *vg)
 {
--- LVM2/test/api/test.c	2009/07/28 11:03:29	1.20
+++ LVM2/test/api/test.c	2009/07/28 13:17:04	1.21
@@ -345,10 +345,11 @@
 
 static void _show_one_vg(vg_t *vg)
 {
-	printf("%s (%s): size=%"PRIu64", free=%"PRIu64", #pv=%"PRIu64"\n",
+	printf("%s (%s): sz=%"PRIu64", free=%"PRIu64", #pv=%"PRIu64
+		", seq#=%"PRIu64"\n",
 		lvm_vg_get_name(vg), lvm_vg_get_uuid(vg),
 		lvm_vg_get_size(vg), lvm_vg_get_free_size(vg),
-		lvm_vg_get_pv_count(vg));
+		lvm_vg_get_pv_count(vg), lvm_vg_get_seqno(vg));
 }
 
 static void _list_open_vgs(void)


             reply	other threads:[~2009-07-28 13:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-28 13:17 wysochanski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-02-21 12:29 prajnoha
2010-10-12 16:41 mornfall
2010-06-30 20:03 agk
2010-06-30 18:03 wysochanski
2010-06-29 21:32 wysochanski
2010-06-28 20:40 wysochanski
2010-02-24 18:15 wysochanski
2010-02-24 18:15 wysochanski
2010-02-14  3:21 wysochanski
2010-02-14  3:21 wysochanski
2009-11-01 20:05 wysochanski
2009-11-01 19:51 wysochanski
2009-10-31 17:30 wysochanski
2009-10-05 20:03 wysochanski
2009-10-05 20:02 wysochanski
2009-10-01  1:04 agk
2009-09-14 15:45 wysochanski
2009-09-02 21:39 wysochanski
2009-09-02 21:39 wysochanski
2009-07-28 15:14 wysochanski
2009-07-26  2:34 wysochanski
2009-07-26  1:53 wysochanski
2009-07-15  5:50 mornfall
2009-07-14  2:15 wysochanski
2009-07-10 20:07 wysochanski
2009-07-10 20:05 wysochanski
2009-07-09 10:09 wysochanski
2009-07-09 10:08 wysochanski
2009-07-09 10:07 wysochanski
2009-07-09 10:06 wysochanski
2009-07-09 10:04 wysochanski
2009-07-09 10:03 wysochanski
2009-07-08 14:33 wysochanski
2009-07-01 17:01 wysochanski
2008-06-24 20:10 wysochanski
2008-01-16 19:54 wysochanski
2008-01-15 22:56 wysochanski
2007-12-22  2:13 agk
2007-11-15 22:11 agk
2007-07-23 21:03 wysochanski

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=20090728131705.1453.qmail@sourceware.org \
    --to=wysochanski@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).