patch-dounmount.txt
| 1 | diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c |
|---|---|
| 2 | index 53cf1bf..eec6025 100644 |
| 3 | --- a/sys/kern/vfs_syscalls.c |
| 4 | +++ b/sys/kern/vfs_syscalls.c |
| 5 | @@ -663,11 +663,12 @@ dounmount(struct mount *mp, int flags) |
| 6 | int lflags; |
| 7 | int freeok = 1; |
| 8 | |
| 9 | + lwkt_gettoken(&mntvnode_token); |
| 10 | /* |
| 11 | * Exclusive access for unmounting purposes |
| 12 | */ |
| 13 | if ((error = mountlist_interlock(dounmount_interlock, mp)) != 0) |
| 14 | - return (error); |
| 15 | + goto out; |
| 16 | |
| 17 | /* |
| 18 | * Allow filesystems to detect that a forced unmount is in progress. |
| 19 | @@ -680,7 +681,7 @@ dounmount(struct mount *mp, int flags) |
| 20 | mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF); |
| 21 | if (mp->mnt_kern_flag & MNTK_MWAIT) |
| 22 | wakeup(mp); |
| 23 | - return (error); |
| 24 | + goto out; |
| 25 | } |
| 26 | |
| 27 | if (mp->mnt_flag & MNT_EXPUBLIC) |
| 28 | @@ -768,7 +769,7 @@ dounmount(struct mount *mp, int flags) |
| 29 | lockmgr(&mp->mnt_lock, LK_RELEASE); |
| 30 | if (mp->mnt_kern_flag & MNTK_MWAIT) |
| 31 | wakeup(mp); |
| 32 | - return (error); |
| 33 | + goto out; |
| 34 | } |
| 35 | /* |
| 36 | * Clean up any journals still associated with the mount after |
| 37 | @@ -810,7 +811,10 @@ dounmount(struct mount *mp, int flags) |
| 38 | wakeup(mp); |
| 39 | if (freeok) |
| 40 | kfree(mp, M_MOUNT); |
| 41 | - return (0); |
| 42 | + error = 0; |
| 43 | +out: |
| 44 | + lwkt_reltoken(&mntvnode_token); |
| 45 | + return (error); |
| 46 | } |
| 47 | |
| 48 | static |