[rhel6-branch] Let tmp use more than 250M when there is more RAM (#1123791)
Martin Kolman
mkolman at redhat.com
Wed Aug 20 10:40:11 UTC 2014
On Tue, 2014-08-19 at 17:12 -0700, Brian C. Lane wrote:
> There are 2 potential problems related to tmpfs size on /tmp. bug 540146
> addressed part of it, making sure /tmp is at least 250M.
>
> 1. On small systems it may be < 250M if there is less than 500M of RAM.
> This can cause a crash because there isn't enough space for install.img
>
> 2. On large systems with lots of RAM it doesn't take advantage of the
> extra RAM and may run out of /tmp space when using large numbers of
> disks and/or driver disks.
>
> This patch checks the total memory available and sets the /tmp size to
> 250M if the available RAM is < 512M. Otherwise it will let it use 50%
> of the available RAM.
>
> Resolves: rhbz#1123791
> ---
> loader/Makefile.am | 3 ++-
> loader/init.c | 16 ++++++++++++++--
> loader/init.h | 3 +++
> 3 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/loader/Makefile.am b/loader/Makefile.am
> index 9a2352c..9a080fc 100644
> --- a/loader/Makefile.am
> +++ b/loader/Makefile.am
> @@ -56,7 +56,8 @@ loader_SOURCES = loader.c copy.c log.c moduleinfo.c loadermisc.c \
>
> init_CFLAGS = $(COMMON_CFLAGS) $(GLIB_CFLAGS)
> init_LDADD = $(GLIB_LIBS)
> -init_SOURCES = init.c undomounts.c shutdown.c copy.c modules.c log.c
> +init_SOURCES = init.c undomounts.c shutdown.c copy.c modules.c log.c \
> + totalmemory.c
>
> shutdown_CFLAGS = $(COMMON_CFLAGS) -DAS_SHUTDOWN=1
> shutdown_SOURCES = shutdown.c undomounts.c
> diff --git a/loader/init.c b/loader/init.c
> index 53b7a15..f54023d 100644
> --- a/loader/init.c
> +++ b/loader/init.c
> @@ -64,6 +64,7 @@
> #include "devices.h"
> #include "modules.h"
> #include "log.h"
> +#include "totalmemory.h"
>
> #endif
>
> @@ -759,8 +760,19 @@ int main(int argc, char **argv) {
>
> printf("mounting /tmp as tmpfs... ");
> fflush(stdout);
> - if (mount("none", "/tmp", "tmpfs", 0, "size=250m"))
> - fatal_error(1);
> +
> + /* On systems with small memory tmpfs needs to be at least 250M so that
> + * there is space for install.img and the logs.
> + * On larger systems it should be 50% of available RAM so that there is
> + * room for more logs, driver disks, etc.
> + */
> + if (totalMemory() < MIN_TMPFS_RAM) {
> + if (mount("none", "/tmp", "tmpfs", 0, "size=250m"))
> + fatal_error(1);
> + } else {
> + if (mount("none", "/tmp", "tmpfs", 0, "size=50%"))
> + fatal_error(1);
> + }
> printf("done\n");
>
> copyDirectory("/oldtmp", "/tmp", copyErrorFn, copyErrorFn);
> diff --git a/loader/init.h b/loader/init.h
> index e1e5b70..9e8e9de 100644
> --- a/loader/init.h
> +++ b/loader/init.h
> @@ -28,4 +28,7 @@ typedef enum {
> DELAYED_REBOOT
> } reboot_action;
>
> +/* When there is less than this amount of ram, set the tmpfs size to 250M */
> +#define MIN_TMPFS_RAM 524288
> +
> #endif /* INIT_H */
Looks good to me, ACK!
More information about the anaconda-patches
mailing list