From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xieyingtai Subject: libmpathpersist: Set open fds limit in mpath_lib_init as mpathpersist called Date: Wed, 14 Oct 2015 03:32:10 +0000 Message-ID: Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6610984933453893758==" Return-path: Content-Language: zh-CN List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: "dm-devel@redhat.com" Cc: Christophe Varoqui List-Id: dm-devel.ids --===============6610984933453893758== Content-Language: zh-CN Content-Type: multipart/alternative; boundary="_000_AF7C226D2A4F8B4D913D33FF7150AE051D6B064Fszxeml556mbschi_" --_000_AF7C226D2A4F8B4D913D33FF7150AE051D6B064Fszxeml556mbschi_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 mu= ltipath in that scene. libmpathpersist/mpath_persist.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persis= t.c index 113cf7f..d032c04 100644 --- a/libmpathpersist/mpath_persist.c +++ b/libmpathpersist/mpath_persist.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #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 =3D conf->max_fds; + fd_limit.rlim_max =3D 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@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --_000_AF7C226D2A4F8B4D913D33FF7150AE051D6B064Fszxeml556mbschi_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Mpath persistent reserve out ma= y 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(&= #43;)

 

diff --git a/libmpathpersist/mp= ath_persist.c b/libmpathpersist/mpath_persist.c

index 113cf7f..d032c04 100644

--- a/libmpathpersist/mpath_per= sist.c

+++ b/libmpathpersi= st/mpath_persist.c

@@ -29,6 +29,8 @@

#include <stdio.h>

#include <stdlib.h><= /o:p>

#include <string.h><= /o:p>

+#include <sys/resource.= h>

+#include <errno.h>

 #define __STDC_FORMAT_MAC= ROS 1

@@ -40,6 +42,16 @@ mpath_li= b_init (struct udev *udev)

     &= nbsp;          condlog(0, &quo= t;Failed to initialize multipath config.");

     &= nbsp;          return 1;<= /o:p>

     &= nbsp; }

+    &n= bsp; 

+    &n= bsp;  if (conf->max_fds) {

+    &n= bsp;           struct rli= mit fd_limit;

+

+    &n= bsp;           fd_limit.r= lim_cur =3D conf->max_fds;

+    &n= bsp;           fd_limit.r= lim_max =3D conf->max_fds;

+    &n= bsp;           if (setrli= mit(RLIMIT_NOFILE, &fd_limit) < 0)

+    &n= bsp;            = ;         condlog(0, "can't se= t open fds limit to %d : %s",

+    &n= bsp;            = ;            &n= bsp;     conf->max_fds, strerror(errno));=

+    &n= bsp;  }

     &= nbsp;  return 0;

}

--

1.8.3.4

 

--

dm-devel mailing list

dm-devel@redhat.com

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

 

--_000_AF7C226D2A4F8B4D913D33FF7150AE051D6B064Fszxeml556mbschi_-- --===============6610984933453893758== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6610984933453893758==--