Browse Source

revert this commit, as it breaks with uClibc-ng

https://www.redhat.com/archives/lvm-devel/2014-November/msg00132.html
uClibc-ng uses simpler malloc as default.
Waldemar Brodkorb 10 years ago
parent
commit
a9c484fd58

+ 3 - 1
package/lvm/Makefile

@@ -39,7 +39,9 @@ CONFIGURE_ARGS+=	--with-user="" --with-group="" \
 			--with-optimisation="" \
 			--disable-testing \
 			--with-lvm1=none
-CONFIGURE_ENV+=		ac_cv_flag_HAVE_PIE=no
+CONFIGURE_ENV+=		ac_cv_flag_HAVE_PIE=no \
+			ac_cv_func_malloc_0_nonnull=yes \
+			ac_cv_func_realloc_0_nonnull=yes
 
 lvm-install:
 	${INSTALL_DIR} ${IDIR_LVM}/usr/sbin

+ 8 - 8
package/lvm/patches/patch-lib_commands_toolcontext_c

@@ -1,6 +1,6 @@
---- LVM2.2.02.106.orig/lib/commands/toolcontext.c	2014-04-10 17:38:44.000000000 +0200
-+++ LVM2.2.02.106/lib/commands/toolcontext.c	2014-05-29 17:55:05.101305501 +0200
-@@ -1334,6 +1334,8 @@ struct cmd_context *create_toolcontext(u
+--- LVM2.2.02.114.orig/lib/commands/toolcontext.c	2014-11-29 00:07:42.000000000 +0100
++++ LVM2.2.02.114/lib/commands/toolcontext.c	2015-02-28 09:27:09.000000000 +0100
+@@ -1433,6 +1433,8 @@ struct cmd_context *create_toolcontext(u
  {
  	struct cmd_context *cmd;
  	FILE *new_stream;
@@ -9,7 +9,7 @@
  	int flags;
  
  #ifdef M_MMAP_MAX
-@@ -1383,10 +1385,10 @@ struct cmd_context *create_toolcontext(u
+@@ -1482,10 +1484,10 @@ struct cmd_context *create_toolcontext(u
  		if (is_valid_fd(STDIN_FILENO) &&
  		    ((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
  		    (flags & O_ACCMODE) != O_WRONLY) {
@@ -23,7 +23,7 @@
  				log_sys_error("setvbuf", "");
  				goto out;
  			}
-@@ -1395,10 +1397,10 @@ struct cmd_context *create_toolcontext(u
+@@ -1494,10 +1496,10 @@ struct cmd_context *create_toolcontext(u
  		if (is_valid_fd(STDOUT_FILENO) &&
  		    ((flags = fcntl(STDOUT_FILENO, F_GETFL)) > 0) &&
  		    (flags & O_ACCMODE) != O_RDONLY) {
@@ -37,7 +37,7 @@
  				     _IOLBF, linebuffer_size)) {
  				log_sys_error("setvbuf", "");
  				goto out;
-@@ -1681,6 +1683,8 @@ void destroy_toolcontext(struct cmd_cont
+@@ -1805,6 +1807,8 @@ void destroy_toolcontext(struct cmd_cont
  {
  	struct dm_config_tree *cft_cmdline;
  	FILE *new_stream;
@@ -46,7 +46,7 @@
  	int flags;
  
  	if (cmd->dump_filter && cmd->filter && cmd->filter->dump &&
-@@ -1717,9 +1721,9 @@ void destroy_toolcontext(struct cmd_cont
+@@ -1840,9 +1844,9 @@ void destroy_toolcontext(struct cmd_cont
  		if (is_valid_fd(STDIN_FILENO) &&
  		    ((flags = fcntl(STDIN_FILENO, F_GETFL)) > 0) &&
  		    (flags & O_ACCMODE) != O_WRONLY) {
@@ -59,7 +59,7 @@
  			} else
  				cmd->linebuffer = NULL;	/* Leave buffer in place (deliberate leak) */
  		}
-@@ -1727,9 +1731,9 @@ void destroy_toolcontext(struct cmd_cont
+@@ -1850,9 +1854,9 @@ void destroy_toolcontext(struct cmd_cont
  		if (is_valid_fd(STDOUT_FILENO) &&
  		    ((flags = fcntl(STDOUT_FILENO, F_GETFL)) > 0) &&
  		    (flags & O_ACCMODE) != O_RDONLY) {

+ 76 - 0
package/lvm/patches/patch-lib_mm_memlock_c

@@ -0,0 +1,76 @@
+--- LVM2.2.02.114.orig/lib/mm/memlock.c	2014-11-29 00:07:42.000000000 +0100
++++ LVM2.2.02.114/lib/mm/memlock.c	2015-02-28 09:44:51.000000000 +0100
+@@ -25,7 +25,6 @@
+ #include <sys/mman.h>
+ #include <sys/time.h>
+ #include <sys/resource.h>
+-#include <malloc.h>
+ 
+ #ifndef DEVMAPPER_SUPPORT
+ 
+@@ -134,10 +133,8 @@ static void _touch_memory(void *mem, siz
+ static void _allocate_memory(void)
+ {
+ #ifndef VALGRIND_POOL
+-	void *stack_mem;
++	void *stack_mem, *temp_malloc_mem;
+ 	struct rlimit limit;
+-	int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;
+-	char *areas[max_areas];
+ 
+ 	/* Check if we could preallocate requested stack */
+ 	if ((getrlimit (RLIMIT_STACK, &limit) == 0) &&
+@@ -146,50 +143,13 @@ static void _allocate_memory(void)
+ 		_touch_memory(stack_mem, _size_stack);
+ 	/* FIXME else warn user setting got ignored */
+ 
+-        /*
+-         *  When a brk() fails due to fragmented address space (which sometimes
+-         *  happens when we try to grab 8M or so), glibc will make a new
+-         *  arena. In this arena, the rules for using “direct” mmap are relaxed,
+-         *  circumventing the MAX_MMAPs and MMAP_THRESHOLD settings. We can,
+-         *  however, detect when this happens with mallinfo() and try to co-opt
+-         *  malloc into using MMAP as a MORECORE substitute instead of returning
+-         *  MMAP'd memory directly. Since MMAP-as-MORECORE does not munmap the
+-         *  memory on free(), this is good enough for our purposes.
+-         */
+-	while (missing > 0) {
+-		struct mallinfo inf = mallinfo();
+-		hblks = inf.hblks;
+-
+-		if ((areas[area] = malloc(_size_malloc_tmp)))
+-			_touch_memory(areas[area], _size_malloc_tmp);
+-
+-		inf = mallinfo();
+-
+-		if (hblks < inf.hblks) {
+-			/* malloc cheated and used mmap, even though we told it
+-			   not to; we try with twice as many areas, each half
+-			   the size, to circumvent the faulty logic in glibc */
+-			free(areas[area]);
+-			_size_malloc_tmp /= 2;
+-		} else {
+-			++ area;
+-			missing -= _size_malloc_tmp;
+-		}
+-
+-		if (area == max_areas && missing > 0) {
+-			/* Too bad. Warn the user and proceed, as things are
+-			 * most likely going to work out anyway. */
+-			log_warn("WARNING: Failed to reserve memory, %d bytes missing.", missing);
+-			break;
+-		}
+-	}
++	if ((temp_malloc_mem = malloc(_size_malloc_tmp)))
++		_touch_memory(temp_malloc_mem, _size_malloc_tmp);
+ 
+ 	if ((_malloc_mem = malloc(_size_malloc)))
+ 		_touch_memory(_malloc_mem, _size_malloc);
+ 
+-	/* free up the reserves so subsequent malloc's can use that memory */
+-	for (i = 0; i < area; ++i)
+-		free(areas[i]);
++	free(temp_malloc_mem);
+ #endif
+ }
+ 

+ 5 - 5
package/lvm/patches/patch-tools_lvmcmdline_c

@@ -1,6 +1,6 @@
---- LVM2.2.02.106.orig/tools/lvmcmdline.c	2014-04-10 17:38:46.000000000 +0200
-+++ LVM2.2.02.106/tools/lvmcmdline.c	2014-05-29 16:57:14.221581766 +0200
-@@ -1252,9 +1252,12 @@ int lvm_split(char *str, int *argc, char
+--- LVM2.2.02.114.orig/tools/lvmcmdline.c	2014-11-29 00:07:43.000000000 +0100
++++ LVM2.2.02.114/tools/lvmcmdline.c	2015-02-28 09:27:09.000000000 +0100
+@@ -1536,9 +1536,12 @@ int lvm_split(char *str, int *argc, char
  static int _check_standard_fds(void)
  {
  	int err = is_valid_fd(STDERR_FILENO);
@@ -14,7 +14,7 @@
  		if (err)
  			perror("stdin stream open");
  		else
-@@ -1264,7 +1267,7 @@ static int _check_standard_fds(void)
+@@ -1548,7 +1551,7 @@ static int _check_standard_fds(void)
  	}
  
  	if (!is_valid_fd(STDOUT_FILENO) &&
@@ -23,7 +23,7 @@
  		if (err)
  			perror("stdout stream open");
  		/* else no stdout */
-@@ -1272,7 +1275,7 @@ static int _check_standard_fds(void)
+@@ -1556,7 +1559,7 @@ static int _check_standard_fds(void)
  	}
  
  	if (!is_valid_fd(STDERR_FILENO) &&