public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib activate/activate.c activate/activate ...
@ 2011-11-11 16:41 mbroz
  0 siblings, 0 replies; 2+ messages in thread
From: mbroz @ 2011-11-11 16:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-11-11 16:41:37

Modified files:
	lib/activate   : activate.c activate.h 
	lib/filters    : filter-mpath.c 

Log message:
	Remove unneeded parameter.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.222&r2=1.223
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-mpath.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2

--- LVM2/lib/activate/activate.c	2011/11/11 15:14:05	1.222
+++ LVM2/lib/activate/activate.c	2011/11/11 16:41:37	1.223
@@ -443,7 +443,7 @@
 	return r;
 }
 
-int lvm_dm_prefix_check(const char *sysfs_dir, int major, int minor, const char *prefix)
+int lvm_dm_prefix_check(int major, int minor, const char *prefix)
 {
 	struct dm_task *dmt;
 	const char *uuid;
--- LVM2/lib/activate/activate.h	2011/11/11 15:14:05	1.87
+++ LVM2/lib/activate/activate.h	2011/11/11 16:41:37	1.88
@@ -53,7 +53,7 @@
 		   int use_modprobe);
 int target_version(const char *target_name, uint32_t *maj,
 		   uint32_t *min, uint32_t *patchlevel);
-int lvm_dm_prefix_check(const char *sysfs_dir, int major, int minor, const char *prefix);
+int lvm_dm_prefix_check(int major, int minor, const char *prefix);
 int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
 			 struct dm_list *modules);
 int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv,
--- LVM2/lib/filters/filter-mpath.c	2011/11/11 15:24:48	1.1
+++ LVM2/lib/filters/filter-mpath.c	2011/11/11 16:41:37	1.2
@@ -136,7 +136,7 @@
 	if (major != dm_major())
 		return 0;
 
-	return lvm_dm_prefix_check(sysfs_dir, major, minor, MPATH_PREFIX);
+	return lvm_dm_prefix_check(major, minor, MPATH_PREFIX);
 }
 
 static int _ignore_mpath(struct dev_filter *f, struct device *dev)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2/lib activate/activate.c activate/activate ...
@ 2012-01-19 15:27 zkabelac
  0 siblings, 0 replies; 2+ messages in thread
From: zkabelac @ 2012-01-19 15:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-19 15:27:54

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

Log message:
	Thin add function to read thin volume percent
	
	This value returns percentage of 'mapped' size compared with total LV size.
	(Without passed seg pointer it return highest mapped size - but it's
	not used yet.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.229&r2=1.230
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.92&r2=1.93
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.260&r2=1.261
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40

--- LVM2/lib/activate/activate.c	2012/01/19 15:25:37	1.229
+++ LVM2/lib/activate/activate.c	2012/01/19 15:27:54	1.230
@@ -736,6 +736,32 @@
 	return r;
 }
 
+/*
+ * Returns 1 if percent set, else 0 on failure.
+ */
+int lv_thin_percent(const struct logical_volume *lv,
+		    int mapped, percent_t *percent)
+{
+	int r;
+	struct dev_manager *dm;
+
+	if (!activation())
+		return 0;
+
+	log_debug("Checking thin percent for LV %s/%s",
+		  lv->vg->name, lv->name);
+
+	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
+		return_0;
+
+	if (!(r = dev_manager_thin_percent(dm, lv, mapped, percent)))
+		stack;
+
+	dev_manager_destroy(dm);
+
+	return r;
+}
+
 static int _lv_active(struct cmd_context *cmd, struct logical_volume *lv)
 {
 	struct lvinfo info;
--- LVM2/lib/activate/activate.h	2012/01/19 15:25:38	1.92
+++ LVM2/lib/activate/activate.h	2012/01/19 15:27:54	1.93
@@ -103,6 +103,8 @@
 int lv_raid_percent(const struct logical_volume *lv, percent_t *percent);
 int lv_thin_pool_percent(const struct logical_volume *lv, int metadata,
 			 percent_t *percent);
+int lv_thin_percent(const struct logical_volume *lv, int mapped,
+		    percent_t *percent);
 
 /*
  * Return number of LVs in the VG that are active.
--- LVM2/lib/activate/dev_manager.c	2012/01/19 15:25:38	1.260
+++ LVM2/lib/activate/dev_manager.c	2012/01/19 15:27:54	1.261
@@ -895,6 +895,28 @@
 	return 1;
 }
 
+int dev_manager_thin_percent(struct dev_manager *dm,
+			     const struct logical_volume *lv,
+			     int mapped, percent_t *percent)
+{
+	char *name;
+	const char *dlid;
+
+	/* Build a name for the top layer */
+	if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, NULL)))
+		return_0;
+
+	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, NULL)))
+		return_0;
+
+	log_debug("Getting device status percentage for %s", name);
+	if (!(_percent(dm, name, dlid, "thin", 0,
+		       (mapped) ? NULL : lv, percent, NULL, 1)))
+		return_0;
+
+	return 1;
+}
+
 /*************************/
 /*  NEW CODE STARTS HERE */
 /*************************/
--- LVM2/lib/activate/dev_manager.h	2012/01/19 15:25:38	1.43
+++ LVM2/lib/activate/dev_manager.h	2012/01/19 15:27:54	1.44
@@ -57,6 +57,9 @@
 int dev_manager_thin_pool_percent(struct dev_manager *dm,
 				  const struct logical_volume *lv,
 				  int metadata, percent_t *percent);
+int dev_manager_thin_percent(struct dev_manager *dm,
+			     const struct logical_volume *lv,
+			     int mapped, percent_t *percent);
 int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
 			struct lv_activate_opts *laopts, int lockfs, int flush_required);
 int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv,
--- LVM2/lib/thin/thin.c	2012/01/19 15:23:51	1.39
+++ LVM2/lib/thin/thin.c	2012/01/19 15:27:54	1.40
@@ -409,6 +409,36 @@
 	return 1;
 }
 
+static int _thin_target_percent(void **target_state __attribute__((unused)),
+				percent_t *percent,
+				struct dm_pool *mem,
+				struct cmd_context *cmd __attribute__((unused)),
+				struct lv_segment *seg,
+				char *params,
+				uint64_t *total_numerator,
+				uint64_t *total_denominator)
+{
+	struct dm_status_thin *s;
+
+	/* Status for thin device is in sectors */
+	if (!dm_get_status_thin(mem, params, &s))
+		return_0;
+
+	if (seg) {
+		*percent = make_percent(s->mapped_sectors, seg->lv->size);
+		*total_denominator += seg->lv->size;
+	} else {
+		/* No lv_segment info here */
+		*percent = PERCENT_INVALID;
+		/* FIXME: Using denominator to pass the mapped info upward? */
+		*total_denominator += s->highest_mapped_sector;
+	}
+
+	*total_numerator += s->mapped_sectors;
+
+	return 1;
+}
+
 static int _thin_target_present(struct cmd_context *cmd,
 				const struct lv_segment *seg,
 				unsigned *attributes __attribute__((unused)))
@@ -499,6 +529,7 @@
 	.text_export = _thin_text_export,
 #ifdef DEVMAPPER_SUPPORT
 	.add_target_line = _thin_add_target_line,
+	.target_percent = _thin_target_percent,
 	.target_present = _thin_target_present,
 #  ifdef DMEVENTD
 	.target_monitored = _target_registered,


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-19 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-11 16:41 LVM2/lib activate/activate.c activate/activate mbroz
2012-01-19 15:27 zkabelac

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).