From: zkabelac@sourceware.org <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ...
Date: 21 May 2010 12:52:02 -0000 [thread overview]
Message-ID: <20100521125202.20649.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2010-05-21 12:52:01
Modified files:
. : WHATS_NEW
lib/metadata : metadata-exported.h replicator_manip.c
Log message:
Replicator: add sorted cmd_vg list
Introduce struct cmd_vg to store information about needed
volume group name, vgid, flags and the pointer to opened VG.
Keep VGs list in alphabetical order for locking order.
Introduce functions:
cmd_vg_add() add new cmd_vg entry.
cmd_vg_lookup() search cmd_vgs for vg_name.
cmd_vg_read() open VGs in cmd_vgs list.
cmd_vg_release() close VGs in reversed order.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1582&r2=1.1583
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.148&r2=1.149
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
--- LVM2/WHATS_NEW 2010/05/21 12:45:18 1.1582
+++ LVM2/WHATS_NEW 2010/05/21 12:52:01 1.1583
@@ -1,5 +1,6 @@
Version 2.02.67 -
===============================
+ Add functions for handling cmd_vg structure.
Extend _lv_each_dependency() with Replicator dependencies.
Add check_replicator_segment() for catching internal Replicator errors.
Initial lvm2 support for Replicator metadata handling.
--- LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:47:46 1.148
+++ LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:52:01 1.149
@@ -298,6 +298,15 @@
struct segment_type;
+/* List with vg_name, vgid and flags */
+struct cmd_vg {
+ struct dm_list list;
+ const char *vg_name;
+ const char *vgid;
+ uint32_t flags;
+ struct volume_group *vg;
+};
+
/* ++ Replicator datatypes */
typedef enum {
REPLICATOR_STATE_PASSIVE,
@@ -798,6 +807,13 @@
int lv_is_slog(const struct logical_volume *lv);
struct logical_volume *first_replicator_dev(const struct logical_volume *lv);
/* -- metadata/replicator_manip.c */
+struct cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs,
+ const char *vg_name, const char *vgid,
+ uint32_t flags);
+struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs,
+ const char *vg_name, const char *vgid);
+int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs);
+void cmd_vg_release(struct dm_list *cmd_vgs);
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
struct device *dev, uint32_t lv_type);
--- LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:43:02 1.2
+++ LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:52:01 1.3
@@ -13,6 +13,7 @@
*/
#include "lib.h"
+#include "locking.h"
#include "metadata.h"
#include "segtype.h"
@@ -477,3 +478,127 @@
return NULL;
}
+
+/**
+ * Add VG open parameters to sorted cmd_vg list.
+ *
+ * Maintain the alphabeticaly ordered list, avoid duplications.
+ *
+ * \return Returns newly created or already present cmd_vg entry,
+ * or NULL in error case.
+ */
+struct cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs,
+ const char *vg_name, const char *vgid,
+ uint32_t flags)
+{
+ struct cmd_vg *cvl, *ins;
+
+ if (!vg_name && !vgid) {
+ log_error("Either vg_name or vgid must be set.");
+ return NULL;
+ }
+
+ /* Is it already in the list ? */
+ if ((cvl = cmd_vg_lookup(cmd_vgs, vg_name, vgid)))
+ return cvl;
+
+ if (!(cvl = dm_pool_zalloc(mem, sizeof(*cvl)))) {
+ log_error("Allocation of cmd_vg failed.");
+ return NULL;
+ }
+
+ if (vg_name && !(cvl->vg_name = dm_pool_strdup(mem, vg_name))) {
+ dm_pool_free(mem, cvl);
+ log_error("Allocation of vg_name failed.");
+ return NULL;
+ }
+
+ if (vgid && !(cvl->vgid = dm_pool_strdup(mem, vgid))) {
+ dm_pool_free(mem, cvl);
+ log_error("Allocation of vgid failed.");
+ return NULL;
+ }
+
+ cvl->flags = flags;
+
+ if (vg_name)
+ dm_list_iterate_items(ins, cmd_vgs)
+ if (strcmp(vg_name, ins->vg_name) < 0) {
+ cmd_vgs = &ins->list; /* new position */
+ break;
+ }
+
+ dm_list_add(cmd_vgs, &cvl->list);
+
+ return cvl;
+}
+
+/**
+ * Find cmd_vg with given vg_name in cmd_vgs list.
+ *
+ * \param cmd_vgs List of cmd_vg entries.
+ *
+ * \param vg_name Name of VG to be found.
+
+ * \param vgid UUID of VG to be found.
+ *
+ * \return Returns cmd_vg entry if vg_name or vgid is found,
+ * NULL otherwise.
+ */
+struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs,
+ const char *vg_name, const char *vgid)
+{
+ struct cmd_vg *cvl;
+
+ dm_list_iterate_items(cvl, cmd_vgs)
+ if ((vgid && cvl->vgid && !strcmp(vgid, cvl->vgid)) ||
+ (vg_name && cvl->vg_name && !strcmp(vg_name, cvl->vg_name)))
+ return cvl;
+ return NULL;
+}
+
+/**
+ * Read and lock multiple VGs stored in cmd_vgs list alphabeticaly.
+ * On the success list head pointer is set to VGs' cmd_vgs.
+ * (supports FAILED_INCONSISTENT)
+ *
+ * \param cmd_vg Contains list of cmd_vg entries.
+ *
+ * \return Returns 1 if all VG in cmd_vgs list are correctly
+ * openned and locked, 0 otherwise.
+ */
+int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs)
+{
+ struct cmd_vg *cvl;
+
+ /* Iterate through alphabeticaly ordered cmd_vg list */
+ dm_list_iterate_items(cvl, cmd_vgs) {
+ cvl->vg = vg_read(cmd, cvl->vg_name, cvl->vgid, cvl->flags);
+ if (vg_read_error(cvl->vg)) {
+ log_debug("Failed to vg_read %s", cvl->vg_name);
+ return 0;
+ }
+ cvl->vg->cmd_vgs = cmd_vgs; /* Make it usable in VG */
+ }
+
+ return 1;
+}
+
+/**
+ * Release opened and locked VGs from list.
+ *
+ * \param cmd_vgs Contains list of cmd_vg entries.
+ */
+void cmd_vg_release(struct dm_list *cmd_vgs)
+{
+ struct cmd_vg *cvl;
+
+ /* Backward iterate cmd_vg list */
+ dm_list_iterate_back_items(cvl, cmd_vgs) {
+ if (vg_read_error(cvl->vg))
+ vg_release(cvl->vg);
+ else
+ unlock_and_release_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name);
+ cvl->vg = NULL;
+ }
+}
next reply other threads:[~2010-05-21 12:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-21 12:52 zkabelac [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-12-01 0:09 LVM2 ./WHATS_NEW lib/metadata/metadata-exporte jbrassow
2011-10-28 20:12 zkabelac
2011-10-07 14:56 jbrassow
2011-09-14 9:57 zkabelac
2011-09-07 8:34 zkabelac
2011-08-18 19:43 jbrassow
2011-08-18 19:34 jbrassow
2011-03-11 14:56 prajnoha
2011-03-02 20:00 mbroz
2011-02-25 14:02 prajnoha
2010-05-21 14:07 zkabelac
2010-05-21 12:55 zkabelac
2010-05-14 15:19 jbrassow
2010-03-16 15:30 agk
2010-03-16 14:37 agk
2009-07-14 2:19 wysochanski
2009-06-05 20:00 mbroz
2009-06-01 14:43 mbroz
2009-02-03 16:19 wysochanski
2009-02-03 16:58 ` Alasdair G Kergon
2008-04-23 14:33 wysochanski
2008-02-13 20:01 meyering
2008-01-18 22:02 agk
2008-01-16 18:15 agk
2008-01-07 20:42 mbroz
2007-11-15 2:20 agk
2007-10-12 14:08 wysochanski
2007-09-20 21:39 wysochanski
2007-08-30 20:30 wysochanski
2007-08-21 17:38 wysochanski
2007-07-23 17:27 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=20100521125202.20649.qmail@sourceware.org \
--to=zkabelac@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.