[sheepdog] [PATCH v6] try to set RLIMIT_NOFILE to recommended value
Liu Yuan
namei.unix at gmail.com
Wed Apr 8 08:18:41 CEST 2015
On Wed, Apr 08, 2015 at 09:14:29AM +0300, Vasiliy Tolstov wrote:
> Signed-off-by: Vasiliy Tolstov <v.tolstov at selfip.ru>
> ---
> sheep/sheep.c | 26 +++++++++++++++--------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/sheep/sheep.c b/sheep/sheep.c
> index 86444b0..38ffed0 100644
> --- a/sheep/sheep.c
> +++ b/sheep/sheep.c
> @@ -526,22 +526,24 @@ static void check_host_env(void)
> struct rlimit r;
>
> if (getrlimit(RLIMIT_NOFILE, &r) < 0)
> - sd_err("failed to get nofile %m");
> - /*
> - * 1024 is default for NOFILE on most distributions, which is very
> - * dangerous to run Sheepdog cluster.
> - */
> - else if (r.rlim_cur == 1024)
> - sd_warn("Allowed open files 1024 too small, suggested %u",
> - SD_RLIM_NOFILE);
> - else if (r.rlim_cur < SD_RLIM_NOFILE)
> - sd_info("Allowed open files %lu, suggested %u", r.rlim_cur,
> - SD_RLIM_NOFILE);
> + sd_err("failed to getrlimit");
> + else if (r.rlim_cur < SD_RLIM_NOFILE) {
> + r.rlim_cur = SD_RLIM_NOFILE;
> + r.rlim_max = SD_RLIM_NOFILE;
> + if (setrlimit(RLIMIT_NOFILE, &r) != 0) {
> + sd_warn("failed to set nofile to suggested %lu",
> + r.rlim_cur);
%m should be appended to show string of errno.
> + sd_warn("increase nofile via sysctl fs.nr_open");
And I'd suggest s/sd_warn/sd_err as mentioned before.
Thanks,
Yuan
More information about the sheepdog
mailing list