public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: zkabelac@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ...
Date: Mon, 03 Oct 2011 18:37:00 -0000	[thread overview]
Message-ID: <20111003183748.17207.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-03 18:37:48

Modified files:
	.              : WHATS_NEW 
	lib/activate   : activate.c activate.h dev_manager.c 
	                 dev_manager.h 

Log message:
	Add lvm functions for sending messages.
	
	Functions are currently only needed for thin provissioning.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2143&r2=1.2144
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.215&r2=1.216
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.235&r2=1.236
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.38&r2=1.39

--- LVM2/WHATS_NEW	2011/09/27 22:43:40	1.2143
+++ LVM2/WHATS_NEW	2011/10/03 18:37:47	1.2144
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Introduce lv_send_message and dev_manager_send_message.
   Introduce revert_lv for better pvmove cleanup.
   Replace incomplete pvmove activation failure recovery code with a message.
   Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely.
--- LVM2/lib/activate/activate.c	2011/09/27 22:43:40	1.215
+++ LVM2/lib/activate/activate.c	2011/10/03 18:37:47	1.216
@@ -215,6 +215,10 @@
 {
 	return 1;
 }
+int lv_send_message(const struct logical_volume *lv, const char *message)
+{
+	return 0;
+}
 int pv_uses_vg(struct physical_volume *pv,
 	       struct volume_group *vg)
 {
@@ -1643,6 +1647,55 @@
 	return r;
 }
 
+#if 0
+// FIXME: Remove this - example of supported messages thin pool
+"create_thin %u", dev_id
+"create_snap %u", dev_id
+"delete %u", dev_id
+"trim %u %" PRIu64, dev_id, new_size_sec
+"set_transaction_id %" PRIu64 " %" PRIu64, cur_id, new_id
+#endif
+
+int lv_send_message(const struct logical_volume *lv, const char *msg_format, ...)
+{
+	va_list ap;
+	struct dev_manager *dm;
+	const size_t buf_size = 128;
+	char *buf = NULL;
+	int r = 0, pr;
+
+	if (!activation())
+		return 0;
+
+	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
+		return_0;
+
+	if (!(buf = dm_malloc(buf_size))) {
+		log_error("Failed to allocate message buffer.");
+		goto out;
+	}
+
+	va_start(ap, msg_format);
+	pr = vsnprintf(buf, buf_size, msg_format, ap);
+	va_end(ap);
+
+	if (pr < 0 || pr >= buf_size) {
+		log_error("Failed to create message in reserved buffer size "
+			  "%" PRIsize_t, buf_size);
+		goto out;
+	}
+
+	log_debug("Sending message '%s' to LV %s/%s", buf, lv->vg->name, lv->name);
+
+	if (!(r = dev_manager_send_message(dm, lv, buf)))
+		stack;
+out:
+	dm_free(buf);
+	dev_manager_destroy(dm);
+
+	return r;
+}
+
 /*
  * Does PV use VG somewhere in its construction?
  * Returns 1 on failure.
--- LVM2/lib/activate/activate.h	2011/09/27 22:43:40	1.81
+++ LVM2/lib/activate/activate.h	2011/10/03 18:37:47	1.82
@@ -71,6 +71,8 @@
 int lv_deactivate(struct cmd_context *cmd, const char *lvid_s);
 
 int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
+__attribute__ ((format(printf, 2, 3)))
+int lv_send_message(const struct logical_volume *lv, const char *msg_format, ...);
 
 /*
  * Returns 1 if info structure has been populated, else 0.
--- LVM2/lib/activate/dev_manager.c	2011/10/03 18:24:47	1.235
+++ LVM2/lib/activate/dev_manager.c	2011/10/03 18:37:47	1.236
@@ -876,6 +876,34 @@
 	return r;
 }
 
+/*
+ * Send message
+ */
+int dev_manager_send_message(struct dev_manager *dm, const struct logical_volume *lv, const char *message)
+{
+	const char *name;
+	struct dm_task *dmt;
+	int r = 0;
+
+	if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, NULL)))
+		return_0;
+
+	if (!(dmt = _setup_task(name, NULL, NULL, DM_DEVICE_TARGET_MSG, 0, 0)))
+		return_0;
+
+	if (!dm_task_set_message(dmt, message))
+		goto_out;
+
+	if (!dm_task_run(dmt))
+		goto_out;
+
+	r = 1;
+out:
+	dm_task_destroy(dmt);
+
+	return r;
+}
+
 static uint16_t _get_udev_flags(struct dev_manager *dm, struct logical_volume *lv,
 				const char *layer)
 {
--- LVM2/lib/activate/dev_manager.h	2011/06/17 14:14:19	1.38
+++ LVM2/lib/activate/dev_manager.h	2011/10/03 18:37:48	1.39
@@ -62,6 +62,7 @@
 int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv) __attribute__((nonnull(1, 2)));
 
 int dev_manager_mknodes(const struct logical_volume *lv);
+int dev_manager_send_message(struct dev_manager *dm, const struct logical_volume *lv, const char *message);
 
 /*
  * Put the desired changes into effect.


             reply	other threads:[~2011-10-03 18:37 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 18:37 zkabelac [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-03-23  9:58 zkabelac
2012-02-23 22:42 zkabelac
2012-01-25 13:10 zkabelac
2012-01-25  8:48 zkabelac
2011-11-18 19:31 zkabelac
2011-10-06 14:55 jbrassow
2011-09-22 17:33 prajnoha
2011-06-30 18:25 agk
2011-06-22 21:31 jbrassow
2011-06-17 14:22 zkabelac
2011-06-17 14:14 zkabelac
2011-02-04 19:14 zkabelac
2011-02-03  1:24 zkabelac
2010-08-17  1:16 agk
2010-02-24 20:01 mbroz
2010-02-24 20:00 mbroz
2009-10-01  0:35 agk
2009-06-01 12:43 mbroz
2009-05-20 11:09 mbroz
2009-05-20  9:52 mbroz
2009-02-28  0:54 agk
2008-12-19 14:22 prajnoha
2008-04-07 10:23 mbroz
2008-01-30 14:00 agk
2007-11-12 20:51 agk
2007-07-02 11:17 wysochanski
2007-03-08 21:08 agk
2006-10-03 17:55 agk
2006-08-21 12:55 agk
2006-08-08 21:20 agk
2005-12-19 21:01 agk
2005-10-25 19:08 agk
2005-10-19 13:59 agk
2005-06-01 16:51 agk
2005-01-12 22:58 agk

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=20111003183748.17207.qmail@sourceware.org \
    --to=zkabelac@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).