Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Return ENOENT if trying to suspend an unmounted file sys...



details:   https://anonhg.NetBSD.org/src/rev/20c096bfad47
branches:  trunk
changeset: 353451:20c096bfad47
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun May 07 08:25:54 2017 +0000

description:
Return ENOENT if trying to suspend an unmounted file system.

diffstat:

 sys/kern/vfs_syscalls.c         |  10 ++--------
 sys/miscfs/genfs/genfs_vfsops.c |  24 ++++++++++++++++++------
 2 files changed, 20 insertions(+), 14 deletions(-)

diffs (91 lines):

diff -r 668069b7f3f0 -r 20c096bfad47 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Sun May 07 08:24:20 2017 +0000
+++ b/sys/kern/vfs_syscalls.c   Sun May 07 08:25:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.513 2017/04/26 03:02:49 riastradh Exp $     */
+/*     $NetBSD: vfs_syscalls.c,v 1.514 2017/05/07 08:25:54 hannken Exp $       */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.513 2017/04/26 03:02:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.514 2017/05/07 08:25:54 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -282,11 +282,6 @@
        if (error)
                goto out;
 
-       if (vfs_busy(mp)) {
-               error = EPERM;
-               goto out;
-       }
-
        error = vfs_suspend(mp, 0);
        if (error)
                goto out;
@@ -345,7 +340,6 @@
        }
        mutex_exit(&mp->mnt_updating);
        vfs_resume(mp);
-       vfs_unbusy(mp);
 
        if ((error == 0) && !(saved_flags & MNT_EXTATTR) && 
            (flags & MNT_EXTATTR)) {
diff -r 668069b7f3f0 -r 20c096bfad47 sys/miscfs/genfs/genfs_vfsops.c
--- a/sys/miscfs/genfs/genfs_vfsops.c   Sun May 07 08:24:20 2017 +0000
+++ b/sys/miscfs/genfs/genfs_vfsops.c   Sun May 07 08:25:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_vfsops.c,v 1.5 2017/03/30 09:12:21 hannken Exp $ */
+/*     $NetBSD: genfs_vfsops.c,v 1.6 2017/05/07 08:25:54 hannken Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.5 2017/03/30 09:12:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.6 2017/05/07 08:25:54 hannken Exp $");
 
 #include <sys/types.h>
 #include <sys/mount.h>
@@ -75,18 +75,30 @@
 int
 genfs_suspendctl(struct mount *mp, int cmd)
 {
-       int error __diagused;
+       int error;
+       int error2 __diagused;
 
        if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0)
                return EOPNOTSUPP;
 
        switch (cmd) {
        case SUSPEND_SUSPEND:
-               return fstrans_setstate(mp, FSTRANS_SUSPENDED);
+               error = fstrans_setstate(mp, FSTRANS_SUSPENDED);
+               if (error == 0) {
+                       mutex_enter(&mp->mnt_unmounting);
+                       if ((mp->mnt_iflag & IMNT_GONE) != 0)
+                               error = ENOENT;
+                       mutex_exit(&mp->mnt_unmounting);
+                       if (error) {
+                               error2 = fstrans_setstate(mp, FSTRANS_NORMAL);
+                               KASSERT(error2 == 0);
+                       }
+               }
+               return error;
 
        case SUSPEND_RESUME:
-               error = fstrans_setstate(mp, FSTRANS_NORMAL);
-               KASSERT(error == 0);
+               error2 = fstrans_setstate(mp, FSTRANS_NORMAL);
+               KASSERT(error2 == 0);
                return 0;
 
        default:



Home | Main Index | Thread Index | Old Index