]> granicus.if.org Git - zfs/commitdiff
Add MS_MANDLOCK mount failure message
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 7 Jun 2017 17:59:44 +0000 (10:59 -0700)
committerGitHub <noreply@github.com>
Wed, 7 Jun 2017 17:59:44 +0000 (10:59 -0700)
Commit torvalds/linux@9e8925b6 allowed for kernels to be built
without support for mandatory locking (MS_MANDLOCK).  This will
result in 'zfs mount' failing when the nbmand=on property is set
if the kernel is built without CONFIG_MANDATORY_FILE_LOCKING.

Unfortunately we can not reliably detect prior to the mount(2) system
call if the kernel was built with this support.  The best we can do
is check if the mount failed with EPERM and if we passed 'mand'
as a mount option and then print a more useful error message. e.g.

  filesystem 'tank/fs' has the 'nbmand=on' property set, this mount
  option may be disabled in your kernel.  Use 'zfs set nbmand=off'
  to disable this option and try to mount the filesystem again.

Additionally, switch the default error message case to use
strerror() to produce a more human readable message.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4729
Closes #6199

cmd/mount_zfs/mount_zfs.c

index 7928ff117d41f3577bfea8c73992e209bb1f3e81..47f2a9ed9e1c06866b25eafc2418ae89271e74e6 100644 (file)
@@ -607,10 +607,23 @@ main(int argc, char **argv)
                                    "failed for unknown reason.\n"), dataset);
                        }
                        return (MOUNT_SYSERR);
+#ifdef MS_MANDLOCK
+               case EPERM:
+                       if (mntflags & MS_MANDLOCK) {
+                               (void) fprintf(stderr, gettext("filesystem "
+                                   "'%s' has the 'nbmand=on' property set, "
+                                   "this mount\noption may be disabled in "
+                                   "your kernel.  Use 'zfs set nbmand=off'\n"
+                                   "to disable this option and try to "
+                                   "mount the filesystem again.\n"), dataset);
+                               return (MOUNT_SYSERR);
+                       }
+                       /* fallthru */
+#endif
                default:
                        (void) fprintf(stderr, gettext("filesystem "
-                           "'%s' can not be mounted due to error "
-                           "%d\n"), dataset, errno);
+                           "'%s' can not be mounted: %s\n"), dataset,
+                           strerror(errno));
                        return (MOUNT_USAGE);
                }
        }