From 110773f6c934c37f058d273ee55cf2fd0010b329 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 11 Nov 2016 15:08:57 +0100 Subject: fstab-generator: add x-systemd.mount-timeout (#4603) This adds a new systemd fstab option x-systemd.mount-timeout. The option adds a timeout value that specifies how long systemd waits for the mount command to finish. It allows to mount huge btrfs volumes without issues. This is equivalent to adding option TimeoutSec= to [Mount] section in a mount unit file. fixes #4055 --- src/fstab-generator/fstab-generator.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/fstab-generator') diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 46507de937..f6a912ae06 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -141,13 +141,14 @@ static bool mount_in_initrd(struct mntent *me) { streq(me->mnt_dir, "/usr"); } -static int write_idle_timeout(FILE *f, const char *where, const char *opts) { +static int write_timeout(FILE *f, const char *where, const char *opts, + const char *filter, const char *variable) { _cleanup_free_ char *timeout = NULL; char timespan[FORMAT_TIMESPAN_MAX]; usec_t u; int r; - r = fstab_filter_options(opts, "x-systemd.idle-timeout\0", NULL, &timeout, NULL); + r = fstab_filter_options(opts, filter, NULL, &timeout, NULL); if (r < 0) return log_warning_errno(r, "Failed to parse options: %m"); if (r == 0) @@ -159,11 +160,21 @@ static int write_idle_timeout(FILE *f, const char *where, const char *opts) { return 0; } - fprintf(f, "TimeoutIdleSec=%s\n", format_timespan(timespan, sizeof(timespan), u, 0)); + fprintf(f, "%s=%s\n", variable, format_timespan(timespan, sizeof(timespan), u, 0)); return 0; } +static int write_idle_timeout(FILE *f, const char *where, const char *opts) { + return write_timeout(f, where, opts, + "x-systemd.idle-timeout\0", "TimeoutIdleSec"); +} + +static int write_mount_timeout(FILE *f, const char *where, const char *opts) { + return write_timeout(f, where, opts, + "x-systemd.mount-timeout\0", "TimeoutSec"); +} + static int write_requires_after(FILE *f, const char *opts) { _cleanup_strv_free_ char **names = NULL, **units = NULL; _cleanup_free_ char *res = NULL; @@ -327,6 +338,10 @@ static int add_mount( if (r < 0) return r; + r = write_mount_timeout(f, where, opts); + if (r < 0) + return r; + if (!isempty(filtered) && !streq(filtered, "defaults")) fprintf(f, "Options=%s\n", filtered); -- cgit v1.2.3-54-g00ecf