[dm-devel] libmpathpersist: Set open fds limit in mpath_lib_init as mpathpersist called

Xieyingtai xieyingtai at huawei.com
Wed Oct 14 03:32:10 UTC 2015


Mpath persistent reserve out may fail due to file open failed when too many devices

were discoveryed but fd numbers not enough. Set open fds limit just like multipath

in that scene.

libmpathpersist/mpath_persist.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 113cf7f..d032c04 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -29,6 +29,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/resource.h>
+#include <errno.h>
 #define __STDC_FORMAT_MACROS 1
@@ -40,6 +42,16 @@ mpath_lib_init (struct udev *udev)
                condlog(0, "Failed to initialize multipath config.");
                return 1;
       }
+
+       if (conf->max_fds) {
+                struct rlimit fd_limit;
+
+                fd_limit.rlim_cur = conf->max_fds;
+                fd_limit.rlim_max = conf->max_fds;
+                if (setrlimit(RLIMIT_NOFILE, &fd_limit) < 0)
+                          condlog(0, "can't set open fds limit to %d : %s",
+                                   conf->max_fds, strerror(errno));
+       }
        return 0;
}
--
1.8.3.4

--

dm-devel mailing list

dm-devel at redhat.com<mailto:dm-devel at redhat.com>

https://www.redhat.com/mailman/listinfo/dm-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20151014/09d7fc12/attachment.htm>


More information about the dm-devel mailing list