Blame SOURCES/0249-RHBZ-1610263-mpathpersist-max-fds.patch

6add9d
---
6add9d
 libmpathpersist/mpath_persist.c  |    4 +++-
6add9d
 libmpathpersist/mpath_pr_ioctl.c |    4 +++-
6add9d
 libmpathpersist/mpathpr.h        |    1 -
6add9d
 libmultipath/configure.c         |   29 +++++++++++++++++++++++++++++
6add9d
 libmultipath/configure.h         |    1 +
6add9d
 mpathpersist/main.c              |    8 +++++++-
6add9d
 multipath/main.c                 |   13 +------------
6add9d
 multipathd/main.c                |   28 +---------------------------
6add9d
 8 files changed, 45 insertions(+), 43 deletions(-)
6add9d
6add9d
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
6add9d
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
6add9d
@@ -19,6 +19,7 @@
6add9d
 #include <dmparser.h>
6add9d
 #include <ctype.h>
6add9d
 #include <propsel.h>
6add9d
+#include <util.h>
6add9d
 
6add9d
 #include "mpath_persist.h"
6add9d
 #include "mpathpr.h"
6add9d
@@ -71,7 +72,8 @@ updatepaths (struct multipath * mpp)
6add9d
 
6add9d
 		vector_foreach_slot (pgp->paths, pp, j){
6add9d
 			if (!strlen(pp->dev)){
6add9d
-				if (devt2devname(pp->dev, pp->dev_t)){
6add9d
+				if (devt2devname(pp->dev, sizeof(pp->dev),
6add9d
+				    pp->dev_t)){
6add9d
 					/*
6add9d
 					 * path is not in sysfs anymore
6add9d
 					 */
6add9d
Index: multipath-tools-130222/libmpathpersist/mpath_pr_ioctl.c
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/libmpathpersist/mpath_pr_ioctl.c
6add9d
+++ multipath-tools-130222/libmpathpersist/mpath_pr_ioctl.c
6add9d
@@ -1,5 +1,6 @@
6add9d
 #include <stdio.h>
6add9d
 #include <stdlib.h>
6add9d
+#include <errno.h>
6add9d
 
6add9d
 #include <sys/types.h>
6add9d
 #include <sys/stat.h>
6add9d
@@ -306,7 +307,8 @@ int prin_do_scsi_ioctl(char * dev, int r
6add9d
 	snprintf(devname, FILE_NAME_SIZE, "/dev/%s",dev);
6add9d
         fd = open(devname, O_WRONLY);
6add9d
         if(fd < 0){
6add9d
-        	condlog(0, "%s: Unable to open device ", dev);
6add9d
+        	condlog(0, "%s: Unable to open device: %s", devname,
6add9d
+			strerror(errno));
6add9d
 		return MPATH_PR_FILE_ERROR;
6add9d
          }
6add9d
 
6add9d
Index: multipath-tools-130222/libmpathpersist/mpathpr.h
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/libmpathpersist/mpathpr.h
6add9d
+++ multipath-tools-130222/libmpathpersist/mpathpr.h
6add9d
@@ -54,6 +54,5 @@ int update_prkey_flags(char *mapname, ui
6add9d
 #define update_prkey(mapname, prkey) update_prkey_flags(mapname, prkey, 0)
6add9d
 void * mpath_alloc_prin_response(int prin_sa);
6add9d
 int update_map_pr(struct multipath *mpp);
6add9d
-int devt2devname (char *devname, char *devt);
6add9d
 
6add9d
 #endif  
6add9d
Index: multipath-tools-130222/mpathpersist/main.c
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/mpathpersist/main.c
6add9d
+++ multipath-tools-130222/mpathpersist/main.c
6add9d
@@ -5,6 +5,10 @@
6add9d
 #include <fcntl.h>
6add9d
 #include <checkers.h>
6add9d
 #include <vector.h>
6add9d
+#include <config.h>
6add9d
+#include <structs.h>
6add9d
+#include <structs_vec.h>
6add9d
+#include <configure.h>
6add9d
 #include <util.h>
6add9d
 #include <structs.h>
6add9d
 #include <getopt.h>
6add9d
@@ -264,7 +268,7 @@ int main (int argc, char * argv[])
6add9d
 
6add9d
 	/* set verbosity */
6add9d
 	noisy = (loglevel >= 3) ? 1 : hex;
6add9d
-	verbose	= (loglevel >= 3)? 3: loglevel;
6add9d
+	verbose	= (loglevel >= 4)? 4 : loglevel;
6add9d
 
6add9d
 	if ((prout_flag + prin_flag) == 0)
6add9d
 	{
6add9d
@@ -356,6 +360,8 @@ int main (int argc, char * argv[])
6add9d
 		goto out;
6add9d
 	}
6add9d
 
6add9d
+	set_max_fds(conf->max_fds);
6add9d
+
6add9d
 	/* open device */
6add9d
 	if ((fd = open (device_name, O_WRONLY)) < 0)
6add9d
 	{
6add9d
Index: multipath-tools-130222/libmultipath/configure.c
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/libmultipath/configure.c
6add9d
+++ multipath-tools-130222/libmultipath/configure.c
6add9d
@@ -15,6 +15,8 @@
6add9d
 #include <libdevmapper.h>
6add9d
 #include <libudev.h>
6add9d
 #include <mpath_cmd.h>
6add9d
+#include <sys/time.h>
6add9d
+#include <sys/resource.h>
6add9d
 
6add9d
 #include "checkers.h"
6add9d
 #include "vector.h"
6add9d
@@ -1143,3 +1145,30 @@ extern int reload_map(struct vectors *ve
6add9d
 
6add9d
 	return 0;
6add9d
 }
6add9d
+
6add9d
+void set_max_fds(int max_fds)
6add9d
+{
6add9d
+	struct rlimit fd_limit;
6add9d
+
6add9d
+	if (!max_fds)
6add9d
+		return;
6add9d
+
6add9d
+	if (getrlimit(RLIMIT_NOFILE, &fd_limit) < 0) {
6add9d
+		condlog(0, "can't get open fds limit: %s",
6add9d
+			strerror(errno));
6add9d
+		fd_limit.rlim_cur = 0;
6add9d
+		fd_limit.rlim_max = 0;
6add9d
+	}
6add9d
+	 if (fd_limit.rlim_cur < conf->max_fds) {
6add9d
+		fd_limit.rlim_cur = conf->max_fds;
6add9d
+		if (fd_limit.rlim_max < conf->max_fds)
6add9d
+			fd_limit.rlim_max = conf->max_fds;
6add9d
+		if (setrlimit(RLIMIT_NOFILE, &fd_limit) < 0)
6add9d
+			condlog(0, "can't set open fds limit to %lu/%lu : %s",
6add9d
+				fd_limit.rlim_cur, fd_limit.rlim_max,
6add9d
+				strerror(errno));
6add9d
+		else
6add9d
+			condlog(3, "set open fds limit to %lu/%lu",
6add9d
+				fd_limit.rlim_cur, fd_limit.rlim_max);
6add9d
+	}
6add9d
+}
6add9d
Index: multipath-tools-130222/libmultipath/configure.h
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/libmultipath/configure.h
6add9d
+++ multipath-tools-130222/libmultipath/configure.h
6add9d
@@ -33,3 +33,4 @@ int get_refwwid (char * dev, enum devtyp
6add9d
 int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh);
6add9d
 int sysfs_get_host_adapter_name(struct path *pp, char *adapter_name);
6add9d
 void trigger_uevents (struct multipath *mpp);
6add9d
+void set_max_fds(int max_fds);
6add9d
Index: multipath-tools-130222/multipath/main.c
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/multipath/main.c
6add9d
+++ multipath-tools-130222/multipath/main.c
6add9d
@@ -52,8 +52,6 @@
6add9d
 #include <pgpolicies.h>
6add9d
 #include <version.h>
6add9d
 #include <errno.h>
6add9d
-#include <sys/time.h>
6add9d
-#include <sys/resource.h>
6add9d
 #include <wwids.h>
6add9d
 #include <file.h>
6add9d
 #include "dev_t.h"
6add9d
@@ -638,16 +636,7 @@ main (int argc, char *argv[])
6add9d
 		}
6add9d
 	}
6add9d
 	conf->daemon = 0;
6add9d
-
6add9d
-	if (conf->max_fds) {
6add9d
-		struct rlimit fd_limit;
6add9d
-
6add9d
-		fd_limit.rlim_cur = conf->max_fds;
6add9d
-		fd_limit.rlim_max = conf->max_fds;
6add9d
-		if (setrlimit(RLIMIT_NOFILE, &fd_limit) < 0)
6add9d
-			condlog(0, "can't set open fds limit to %d : %s",
6add9d
-				conf->max_fds, strerror(errno));
6add9d
-	}
6add9d
+	set_max_fds(conf->max_fds);
6add9d
 
6add9d
 	if (init_checkers()) {
6add9d
 		condlog(0, "failed to initialize checkers");
6add9d
Index: multipath-tools-130222/multipathd/main.c
6add9d
===================================================================
6add9d
--- multipath-tools-130222.orig/multipathd/main.c
6add9d
+++ multipath-tools-130222/multipathd/main.c
6add9d
@@ -12,8 +12,6 @@
6add9d
 #include <sys/types.h>
6add9d
 #include <fcntl.h>
6add9d
 #include <errno.h>
6add9d
-#include <sys/time.h>
6add9d
-#include <sys/resource.h>
6add9d
 #include <limits.h>
6add9d
 #include <linux/oom.h>
6add9d
 #include <libudev.h>
6add9d
@@ -1946,31 +1944,7 @@ child (void * param)
6add9d
 
6add9d
 	setlogmask(LOG_UPTO(conf->verbosity + 3));
6add9d
 
6add9d
-	if (conf->max_fds) {
6add9d
-		struct rlimit fd_limit;
6add9d
-
6add9d
-		if (getrlimit(RLIMIT_NOFILE, &fd_limit) < 0) {
6add9d
-			condlog(0, "can't get open fds limit: %s",
6add9d
-				strerror(errno));
6add9d
-			fd_limit.rlim_cur = 0;
6add9d
-			fd_limit.rlim_max = 0;
6add9d
-		}
6add9d
-		if (fd_limit.rlim_cur < conf->max_fds) {
6add9d
-			fd_limit.rlim_cur = conf->max_fds;
6add9d
-			if (fd_limit.rlim_max < conf->max_fds)
6add9d
-				fd_limit.rlim_max = conf->max_fds;
6add9d
-			if (setrlimit(RLIMIT_NOFILE, &fd_limit) < 0) {
6add9d
-				condlog(0, "can't set open fds limit to "
6add9d
-					"%lu/%lu : %s",
6add9d
-					fd_limit.rlim_cur, fd_limit.rlim_max,
6add9d
-					strerror(errno));
6add9d
-			} else {
6add9d
-				condlog(3, "set open fds limit to %lu/%lu",
6add9d
-					fd_limit.rlim_cur, fd_limit.rlim_max);
6add9d
-			}
6add9d
-		}
6add9d
-
6add9d
-	}
6add9d
+	set_max_fds(conf->max_fds);
6add9d
 
6add9d
 	vecs = gvecs = init_vecs();
6add9d
 	if (!vecs) {