[systemd-devel] [PATCH] fstab-generator: do not check btrfs and xfs

Tom Gundersen teg at jklm.no
Sun Jun 29 11:43:43 PDT 2014


On Sat, Jun 28, 2014 at 7:49 PM, Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
> fsck.btrfs and fsck.xfs are documented to return immediately, so there is
> little sense in running them. Avoids some user confusion and a few lines
> in the logs.

Is this special-casing really worth it? In general we don't know what
filesystem type we have at this point as it may be set to "auto",
which I suppose is particularly common on the kernel commandline.

Maybe we could simply improve the log message instead?

Cheers,

Tom

> https://bugzilla.redhat.com/show_bug.cgi?id=1098799
> ---
>  man/systemd-fsck at .service.xml         | 15 ++++++++-------
>  src/fstab-generator/fstab-generator.c | 23 ++++++++++++++++++++++-
>  2 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/man/systemd-fsck at .service.xml b/man/systemd-fsck at .service.xml
> index ee66f3712d..1e9975f426 100644
> --- a/man/systemd-fsck at .service.xml
> +++ b/man/systemd-fsck at .service.xml
> @@ -69,14 +69,15 @@
>                  all other file systems and for the root file system in
>                  the initramfs.</para>
>
> -                <para>Those services are started at boot if
> -                <option>passno</option> in
> +                <para>Those services are started at boot for the root
> +                file system or when <option>passno</option> in
>                  <filename>/etc/fstab</filename> for the file system is
> -                set to a value greater than zero. The file system
> -                check for root is performed before the other file
> -                systems. Other file systems may be checked in
> -                parallel, except when they are one the same rotating
> -                disk.</para>
> +                set to a value greater than zero, except for file
> +                system types like btrfs and xfs which are checked by
> +                the kernel. The check for root is performed before the
> +                other file systems. Other file systems may be checked
> +                in parallel, except when they are one the same
> +                rotating disk.</para>
>
>                  <para><filename>systemd-fsck</filename> does not know
>                  any details about specific filesystems, and simply
> diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
> index 1256a1ce53..4dad82d425 100644
> --- a/src/fstab-generator/fstab-generator.c
> +++ b/src/fstab-generator/fstab-generator.c
> @@ -165,6 +165,14 @@ static bool mount_in_initrd(struct mntent *me) {
>                  streq(me->mnt_dir, "/usr");
>  }
>
> +static bool mount_skip_fsck(const char *fstype) {
> +        static const char table[] =
> +                "btrfs\0"
> +                "xfs\0";
> +
> +        return fstype && nulstr_contains(table, fstype);
> +}
> +
>  static int add_mount(
>                  const char *what,
>                  const char *where,
> @@ -377,6 +385,7 @@ static int parse_fstab(bool initrd) {
>                  else {
>                          bool noauto, nofail, automount;
>                          const char *post;
> +                        int check;
>
>                          noauto = !!hasmntopt(me, "noauto");
>                          nofail = !!hasmntopt(me, "nofail");
> @@ -393,6 +402,13 @@ static int parse_fstab(bool initrd) {
>                          else
>                                  post = SPECIAL_LOCAL_FS_TARGET;
>
> +                        check = me->mnt_passno;
> +                        if (check && mount_skip_fsck(me->mnt_type)) {
> +                                log_warning("No need to check %s, type %s. Ignoring fstab passno.",
> +                                            what, me->mnt_type);
> +                                check = 0;
> +                        }
> +
>                          k = add_mount(what,
>                                        where,
>                                        me->mnt_type,
> @@ -415,6 +431,7 @@ static int parse_fstab(bool initrd) {
>  static int add_root_mount(void) {
>          _cleanup_free_ char *what = NULL;
>          const char *opts;
> +        int check;
>
>          if (isempty(arg_root_what)) {
>                  log_debug("Could not find a root= entry on the kernel commandline.");
> @@ -436,12 +453,16 @@ static int add_root_mount(void) {
>          else
>                  opts = arg_root_options;
>
> +        check = mount_skip_fsck(arg_root_fstype);
> +        if (!check)
> +                log_debug("Skipping fsck for root.");
> +
>          log_debug("Found entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
>          return add_mount(what,
>                           "/sysroot",
>                           arg_root_fstype,
>                           opts,
> -                         1,
> +                         check,
>                           false,
>                           false,
>                           false,
> --
> 2.0.0
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list