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

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