diff --git a/autofs-5.1.8-fix-set-open-file-limit.patch b/autofs-5.1.8-fix-set-open-file-limit.patch new file mode 100644 index 0000000..c213c00 --- /dev/null +++ b/autofs-5.1.8-fix-set-open-file-limit.patch @@ -0,0 +1,57 @@ +autofs-5.1.8 - fix set open file limit + +From: Ian Kent + +The check of whether the open file limit needs to be changed is not +right, it checks the hard open file limit against what autofs wants +to set it to which is always less than this value. Consequently the +open file limit isn't changed. + +autofs should be changing only the soft open file limit but it is +setting both the hard and soft limits. The system hard limit is much +higer than the autofs maximum open files so the hard limit should be +left alone. + +While we are here increase the requested maximum soft open file limit +to 20k. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 7 ++++--- + 2 files changed, 5 insertions(+), 3 deletions(-) + +--- autofs-5.1.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -82,6 +82,7 @@ + - use default stack size for threads. + - fix kernel mount status notification. + - fix fedfs build flags. ++- fix set open file limit. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/daemon/automount.c ++++ autofs-5.1.7/daemon/automount.c +@@ -94,7 +94,7 @@ struct startup_cond suc = { + pthread_key_t key_thread_stdenv_vars; + pthread_key_t key_thread_attempt_id = (pthread_key_t) 0L; + +-#define MAX_OPEN_FILES 10240 ++#define MAX_OPEN_FILES 20480 + + int aquire_flag_file(void); + void release_flag_file(void); +@@ -2483,9 +2483,10 @@ int main(int argc, char *argv[]) + } + + res = getrlimit(RLIMIT_NOFILE, &rlim); +- if (res == -1 || rlim.rlim_max <= MAX_OPEN_FILES) { ++ if (res == -1 || rlim.rlim_cur <= MAX_OPEN_FILES) { + rlim.rlim_cur = MAX_OPEN_FILES; +- rlim.rlim_max = MAX_OPEN_FILES; ++ if (rlim.rlim_max < MAX_OPEN_FILES) ++ rlim.rlim_max = MAX_OPEN_FILES; + } + res = setrlimit(RLIMIT_NOFILE, &rlim); + if (res) diff --git a/autofs-5.1.8-improve-descriptor-open-error-reporting.patch b/autofs-5.1.8-improve-descriptor-open-error-reporting.patch new file mode 100644 index 0000000..6bb7f2a --- /dev/null +++ b/autofs-5.1.8-improve-descriptor-open-error-reporting.patch @@ -0,0 +1,165 @@ +autofs-5.1.8 - improve descriptor open error reporting + +From: Ian Kent + +Add error message reporting to the descriptor open functions. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 3 --- + daemon/spawn.c | 29 +++++++++++++++++++++++++++++ + lib/mounts.c | 10 ++-------- + modules/lookup_program.c | 5 +---- + 5 files changed, 33 insertions(+), 15 deletions(-) + +--- autofs-5.1.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -83,6 +83,7 @@ + - fix kernel mount status notification. + - fix fedfs build flags. + - fix set open file limit. ++- improve descriptor open error reporting. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/daemon/automount.c ++++ autofs-5.1.7/daemon/automount.c +@@ -864,9 +864,6 @@ static int create_logpri_fifo(struct aut + + fd = open_fd(fifo_name, O_RDWR|O_NONBLOCK); + if (fd < 0) { +- char *estr = strerror_r(errno, buf, MAX_ERR_BUF); +- crit(ap->logopt, +- "Failed to open %s: %s", fifo_name, estr); + unlink(fifo_name); + ret = -1; + goto out_free; +--- autofs-5.1.7.orig/daemon/spawn.c ++++ autofs-5.1.7/daemon/spawn.c +@@ -94,7 +94,12 @@ int open_fd(const char *path, int flags) + #endif + fd = open(path, flags); + if (fd == -1) { ++ char buf[MAX_ERR_BUF]; ++ char *estr; ++ + open_mutex_unlock(); ++ estr = strerror_r(errno, buf, sizeof(buf)); ++ logerr("failed to open file: %s", estr); + return -1; + } + check_cloexec(fd); +@@ -113,7 +118,12 @@ int open_fd_mode(const char *path, int f + #endif + fd = open(path, flags, mode); + if (fd == -1) { ++ char buf[MAX_ERR_BUF]; ++ char *estr; ++ + open_mutex_unlock(); ++ estr = strerror_r(errno, buf, sizeof(buf)); ++ logerr("failed to open file: %s", estr); + return -1; + } + check_cloexec(fd); +@@ -123,6 +133,8 @@ int open_fd_mode(const char *path, int f + + int open_pipe(int pipefd[2]) + { ++ char buf[MAX_ERR_BUF]; ++ char *estr; + int ret; + + open_mutex_lock(); +@@ -145,6 +157,8 @@ done: + return 0; + err: + open_mutex_unlock(); ++ estr = strerror_r(errno, buf, sizeof(buf)); ++ logerr("failed to open pipe: %s", estr); + return -1; + } + +@@ -159,7 +173,12 @@ int open_sock(int domain, int type, int + #endif + fd = socket(domain, type, protocol); + if (fd == -1) { ++ char buf[MAX_ERR_BUF]; ++ char *estr; ++ + open_mutex_unlock(); ++ estr = strerror_r(errno, buf, sizeof(buf)); ++ logerr("failed to open socket: %s", estr); + return -1; + } + check_cloexec(fd); +@@ -184,7 +203,12 @@ FILE *open_fopen_r(const char *path) + #endif + f = fopen(path, "r"); + if (f == NULL) { ++ char buf[MAX_ERR_BUF]; ++ char *estr; ++ + open_mutex_unlock(); ++ estr = strerror_r(errno, buf, sizeof(buf)); ++ logerr("failed to open file: %s", estr); + return NULL; + } + check_cloexec(fileno(f)); +@@ -209,7 +233,12 @@ FILE *open_setmntent_r(const char *table + #endif + tab = fopen(table, "r"); + if (tab == NULL) { ++ char buf[MAX_ERR_BUF]; ++ char *estr; ++ + open_mutex_unlock(); ++ estr = strerror_r(errno, buf, sizeof(buf)); ++ logerr("failed to open mount table: %s", estr); + return NULL; + } + check_cloexec(fileno(tab)); +--- autofs-5.1.7.orig/lib/mounts.c ++++ autofs-5.1.7/lib/mounts.c +@@ -2169,11 +2169,8 @@ struct mnt_list *get_mnt_list(const char + return NULL; + + tab = open_fopen_r(_PROC_MOUNTS); +- if (!tab) { +- char *estr = strerror_r(errno, buf, PATH_MAX - 1); +- logerr("fopen: %s", estr); ++ if (!tab) + return NULL; +- } + + while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + len = strlen(mnt->mnt_dir); +@@ -2280,11 +2277,8 @@ static int table_is_mounted(const char * + return 0; + + tab = open_fopen_r(_PROC_MOUNTS); +- if (!tab) { +- char *estr = strerror_r(errno, buf, PATH_MAX - 1); +- logerr("fopen: %s", estr); ++ if (!tab) + return 0; +- } + + while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + size_t len = strlen(mnt->mnt_dir); +--- autofs-5.1.7.orig/modules/lookup_program.c ++++ autofs-5.1.7/modules/lookup_program.c +@@ -214,11 +214,8 @@ static char *lookup_one(struct autofs_po + * want to send stderr to the syslog, and we don't use spawnl() + * because we need the pipe hooks + */ +- if (open_pipe(pipefd)) { +- char *estr = strerror_r(errno, buf, MAX_ERR_BUF); +- logerr(MODPREFIX "pipe: %s", estr); ++ if (open_pipe(pipefd)) + goto out_error; +- } + if (open_pipe(epipefd)) { + close(pipefd[0]); + close(pipefd[1]); diff --git a/autofs.spec b/autofs.spec index 315e745..b3bc052 100644 --- a/autofs.spec +++ b/autofs.spec @@ -12,7 +12,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.1.7 -Release: 26%{?dist} +Release: 27%{?dist} Epoch: 1 License: GPLv2+ Source: https://www.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}-2.tar.gz @@ -104,6 +104,8 @@ Patch81: autofs-5.1.7-use-default-stack-size-for-threads.patch Patch82: autofs-5.1.8-fix-kernel-mount-status-notification.patch Patch83: autofs-5.1.8-fix-fedfs-build-flags.patch +Patch84: autofs-5.1.8-fix-set-open-file-limit.patch +Patch85: autofs-5.1.8-improve-descriptor-open-error-reporting.patch %if %{with_systemd} BuildRequires: systemd-units @@ -254,6 +256,8 @@ echo %{version}-%{release} > .version %patch82 -p1 %patch83 -p1 +%patch84 -p1 +%patch85 -p1 %build LDFLAGS=-Wl,-z,now @@ -362,6 +366,13 @@ fi %dir /etc/auto.master.d %changelog +* Sun Jan 09 2022 Ian Kent - 1:5.1.7-27 +- bz2028746 - autofs service has not proper limits set to be able to handle + many mounts + - fix set open file limit. + - improve descriptor open error reporting. +- Resolves: rhbz#2028746 + * Tue Dec 21 2021 Ian Kent - 1:5.1.7-26 - bz2028301 - autofs: send FAIL cmd/ioctl mess when encountering problems with mount trigger