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

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