public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/mm/memlock.c
@ 2012-01-12 18:29 agk
  0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2012-01-12 18:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2012-01-12 18:29:08

Modified files:
	.              : WHATS_NEW 
	lib/mm         : memlock.c 

Log message:
	Make error message hit when preallocated memlock memory exceeded clearer.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2221&r2=1.2222
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48

--- LVM2/WHATS_NEW	2012/01/12 16:58:43	1.2221
+++ LVM2/WHATS_NEW	2012/01/12 18:29:07	1.2222
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Make error message hit when preallocated memlock memory exceeded clearer.
   Use R lv_attr to indicate read-only activation of non-read-only device in lvs.
   Show read-only activation override in lvdisplay & add 4 to perms in -c.
   Add activation/read_only_volume_list to override LV permission in metadata.
--- LVM2/lib/mm/memlock.c	2011/12/08 21:24:09	1.47
+++ LVM2/lib/mm/memlock.c	2012/01/12 18:29:08	1.48
@@ -147,7 +147,7 @@
  * format described in kernel/Documentation/filesystem/proc.txt
  */
 static int _maps_line(const struct dm_config_node *cn, lvmlock_t lock,
-		      const char* line, size_t* mstats)
+		      const char *line, size_t *mstats)
 {
 	const struct dm_config_value *cv;
 	long from, to;
@@ -357,7 +357,7 @@
 		if (_mstats < unlock_mstats) {
 			if ((_mstats + lvm_getpagesize()) < unlock_mstats)
 				log_error(INTERNAL_ERROR
-					  "Maps lock %ld < unlock %ld",
+					  "Reserved memory (%ld) not enough: used %ld. Increase activation/reserved_memory?",
 					  (long)_mstats, (long)unlock_mstats);
 			else
 				/* FIXME Believed due to incorrect use of yes_no_prompt while locks held */


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

* LVM2 ./WHATS_NEW lib/mm/memlock.c
@ 2011-06-12  0:23 agk
  0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2011-06-12  0:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-06-12 00:23:50

Modified files:
	.              : WHATS_NEW 
	lib/mm         : memlock.c 

Log message:
	Disable critical section internal errors until this can be fixed properly
	in libdevmapper.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2011&r2=1.2012
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44

--- LVM2/WHATS_NEW	2011/06/11 00:03:06	1.2011
+++ LVM2/WHATS_NEW	2011/06/12 00:23:50	1.2012
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Downgrade critical_section errors to debug level until it is moved to libdm.
   Fix ignored background polling default in vgchange -ay.
   Fix pvmove activation sequences to avoid trapped I/O with multiple LVs.
   Annotate critical section debug messages.
--- LVM2/lib/mm/memlock.c	2011/06/11 00:03:07	1.43
+++ LVM2/lib/mm/memlock.c	2011/06/12 00:23:50	1.44
@@ -405,8 +405,9 @@
 
 void critical_section_dec(struct cmd_context *cmd, const char *reason)
 {
+	/* FIXME Maintain accurate suspended device counter in libdevmapper */
 	if (!_critical_section_count)
-		log_error(INTERNAL_ERROR "_critical_section has dropped below 0.");
+		log_debug("_critical_section has dropped below 0.");
 	--_critical_section_count;
 	log_debug("critical_section_dec to %d (%s).", _critical_section_count,
 		  reason);


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

* LVM2 ./WHATS_NEW lib/mm/memlock.c
@ 2011-03-30 13:06 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2011-03-30 13:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-30 13:06:13

Modified files:
	.              : WHATS_NEW 
	lib/mm         : memlock.c 

Log message:
	Few more files filtered from memory locking
	
	Code located in these files should not be used in critical section.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1965&r2=1.1966
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39

--- LVM2/WHATS_NEW	2011/03/30 12:43:32	1.1965
+++ LVM2/WHATS_NEW	2011/03/30 13:06:13	1.1966
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Extend the set of memory regions, that are not locked to memory.
   Enhance usability with the valgrind memcheck tool.
   Support regular quit of the lvm_thread_fn function in clvmd.
   Fix reading of unallocated memory in lvm1 format import function.
--- LVM2/lib/mm/memlock.c	2011/03/30 12:43:32	1.38
+++ LVM2/lib/mm/memlock.c	2011/03/30 13:06:13	1.39
@@ -89,9 +89,11 @@
 /* default blacklist for maps */
 static const char * const _blacklist_maps[] = {
     "locale/locale-archive",
+    "/LC_MESSAGES/",
     "gconv/gconv-modules.cache",
     "/libreadline.so.",	/* not using readline during mlock */
     "/libncurses.so.",	/* not using readline during mlock */
+    "/libtinfo.so.",	/* not using readline during mlock */
     "/libdl-",		/* not using dlopen,dlsym during mlock */
     /* "/libdevmapper-event.so" */
 };


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

* LVM2 ./WHATS_NEW lib/mm/memlock.c
@ 2011-03-06 16:47 mbroz
  0 siblings, 0 replies; 6+ messages in thread
From: mbroz @ 2011-03-06 16:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-03-06 16:47:43

Modified files:
	.              : WHATS_NEW 
	lib/mm         : memlock.c 

Log message:
	Fix hardcoded page size, fixing test fails with 8k page and new kernel.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1935&r2=1.1936
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36

--- LVM2/WHATS_NEW	2011/03/05 12:14:00	1.1935
+++ LVM2/WHATS_NEW	2011/03/06 16:47:43	1.1936
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Use system page size and not hardcoded value in locking code check.
   Fix reading of released memory for printing segment type.
   Fix syslog initialisation in clvmd to respect lvm.conf setting.
   Fix possible overflow in maximum stripe size and physical extent size.
--- LVM2/lib/mm/memlock.c	2011/02/18 14:51:04	1.35
+++ LVM2/lib/mm/memlock.c	2011/03/06 16:47:43	1.36
@@ -344,7 +344,7 @@
 		dm_free(_maps_buffer);
 		_maps_buffer = NULL;
 		if (_mstats < unlock_mstats) {
-			if ((_mstats + 4096) < unlock_mstats)
+			if ((_mstats + getpagesize()) < unlock_mstats)
 				log_error(INTERNAL_ERROR
 					  "Maps lock %ld < unlock %ld",
 					  (long)_mstats, (long)unlock_mstats);


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

* LVM2 ./WHATS_NEW lib/mm/memlock.c
@ 2010-09-30 11:32 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2010-09-30 11:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-09-30 11:32:41

Modified files:
	.              : WHATS_NEW 
	lib/mm         : memlock.c 

Log message:
	Maps fix
	
	Read complete content of /proc/self/maps into one buffer without
	realocation in the middle of reading and before doing any m/unlock
	operation with these lines - as some of them gets change.
	With previous implementation we've read some mappings twice ([stack])

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1738&r2=1.1739
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30

--- LVM2/WHATS_NEW	2010/09/28 01:29:06	1.1738
+++ LVM2/WHATS_NEW	2010/09/30 11:32:40	1.1739
@@ -1,5 +1,6 @@
 Version 2.02.75 - 
 =====================================
+  Read whole /proc/self/maps file before working with maps entries.
   Speed up unquoting of quoted double quotes and backslashes.
   Speed up CRC32 calculations by using a larger lookup table.
 
--- LVM2/lib/mm/memlock.c	2010/07/08 14:47:46	1.29
+++ LVM2/lib/mm/memlock.c	2010/09/30 11:32:41	1.30
@@ -76,7 +76,9 @@
 typedef enum { LVM_MLOCK, LVM_MUNLOCK } lvmlock_t;
 
 static unsigned _use_mlockall;
-static FILE *_mapsh;
+static int _maps_fd;
+static size_t _maps_len = 8192; /* Initial buffer size for reading /proc/self/maps */
+static char *_maps_buffer;
 static char _procselfmaps[PATH_MAX] = "";
 #define SELF_MAPS "/self/maps"
 
@@ -193,7 +195,7 @@
 
 static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats)
 {
-	char *line = NULL;
+	char *line, *line_end;
 	size_t len;
 	ssize_t n;
 	int ret = 1;
@@ -222,15 +224,39 @@
 		(void)strerror(0);
 	/* Reset statistic counters */
 	*mstats = 0;
-	rewind(_mapsh);
 
-	while ((n = getline(&line, &len, _mapsh)) != -1) {
-		line[n > 0 ? n - 1 : 0] = '\0'; /* remove \n */
-		if (!_maps_line(cmd, lock, line, mstats))
-                        ret = 0;
+	/* read mapping into a single memory chunk without reallocation
+	 * in the middle of reading maps file */
+	for (len = 0;;) {
+		if (!_maps_buffer || len >= _maps_len) {
+			if (_maps_buffer)
+				_maps_len *= 2;
+			if (!(_maps_buffer = dm_realloc(_maps_buffer, _maps_len))) {
+				log_error("Allocation of maps buffer failed");
+				return 0;
+			}
+		}
+		lseek(_maps_fd, 0, SEEK_SET);
+		for (len = 0 ; len < _maps_len; len += n) {
+			if (!(n = read(_maps_fd, _maps_buffer + len, _maps_len - len))) {
+				_maps_buffer[len] = '\0';
+				break; /* EOF */
+			}
+			if (n == -1)
+				return_0;
+		}
+		if (len < _maps_len)  /* fits in buffer */
+			break;
 	}
 
-	free(line);
+	line = _maps_buffer;
+
+	while ((line_end = strchr(line, '\n'))) {
+		*line_end = '\0'; /* remove \n */
+		if (!_maps_line(cmd, lock, line, mstats))
+			ret = 0;
+		line = line_end + 1;
+	}
 
 	log_debug("%socked %ld bytes",
 		  (lock == LVM_MLOCK) ? "L" : "Unl", (long)*mstats);
@@ -260,8 +286,8 @@
 			return;
 		}
 
-		if (!(_mapsh = fopen(_procselfmaps, "r"))) {
-			log_sys_error("fopen", _procselfmaps);
+		if (!(_maps_fd = open(_procselfmaps, O_RDONLY))) {
+			log_sys_error("open", _procselfmaps);
 			return;
 		}
 	}
@@ -289,9 +315,10 @@
 		stack;
 
 	if (!_use_mlockall) {
-		if (fclose(_mapsh))
-			log_sys_error("fclose", _procselfmaps);
-
+		if (close(_maps_fd))
+			log_sys_error("close", _procselfmaps);
+		dm_free(_maps_buffer);
+		_maps_buffer = NULL;
 		if (_mstats < unlock_mstats)
 			log_error(INTERNAL_ERROR "Maps lock %ld < unlock %ld",
 				  (long)_mstats, (long)unlock_mstats);


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

* LVM2 ./WHATS_NEW lib/mm/memlock.c
@ 2010-06-24  8:29 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2010-06-24  8:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-06-24 08:29:31

Modified files:
	.              : WHATS_NEW 
	lib/mm         : memlock.c 

Log message:
	Preload libc locale messages.
	
	Preload libc.mo file for localized lvm before taking memory lock - this way
	we prevent disk access for some error paths in libdm, that prints localized
	errno messages while they are still in memory locked state.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1634&r2=1.1635
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27

--- LVM2/WHATS_NEW	2010/06/23 21:01:42	1.1634
+++ LVM2/WHATS_NEW	2010/06/24 08:29:30	1.1635
@@ -1,5 +1,6 @@
 Version 2.02.69 - 
 ================================
+  Preload libc locale messages to prevent reading it in memory locked state.
   Fix handling of simultaneous mirror image and mirrored log image failure.
 
 Version 2.02.68 - 23rd June 2010
--- LVM2/lib/mm/memlock.c	2010/04/01 14:53:47	1.26
+++ LVM2/lib/mm/memlock.c	2010/06/24 08:29:31	1.27
@@ -216,6 +216,9 @@
 #endif
 	}
 
+	/* Force libc.mo load */
+	if (lock == LVM_MLOCK)
+		(void)strerror(0);
 	/* Reset statistic counters */
 	*mstats = 0;
 	rewind(_mapsh);


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

end of thread, other threads:[~2012-01-12 18:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-12 18:29 LVM2 ./WHATS_NEW lib/mm/memlock.c agk
  -- strict thread matches above, loose matches on Subject: below --
2011-06-12  0:23 agk
2011-03-30 13:06 zkabelac
2011-03-06 16:47 mbroz
2010-09-30 11:32 zkabelac
2010-06-24  8:29 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).