diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2013-07-09 20:49:32 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2013-07-09 20:49:32 +0000 |
commit | cc3d8c35f5cf19be283352c5bed410be5d09de4f (patch) | |
tree | 163763327fb3a8dbae9807ce2cbea1c3bb9f69f6 /sys/ufs | |
parent | b71f5853033d9ac08c7e3f89de5c42b0e945e4b9 (diff) | |
download | src-cc3d8c35f5cf19be283352c5bed410be5d09de4f.tar.gz src-cc3d8c35f5cf19be283352c5bed410be5d09de4f.zip |
There are several code sequences like
vfs_busy(mp);
vfs_write_suspend(mp);
which are problematic if other thread starts unmount between two
calls. The unmount starts a write, while vfs_write_suspend() drain
writers. On the other hand, unmount drains busy references, causing
the deadlock.
Add a flag argument to vfs_write_suspend and require the callers of it
to specify VS_SKIP_UNMOUNT flag, when the call is performed not in the
mount path, i.e. the covered vnode is not locked. The suspension is
not attempted if VS_SKIP_UNMOUNT is specified and unmount is in
progress.
Reported and tested by: Andreas Longwitz <longwitz@incore.de>
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Notes
Notes:
svn path=/head/; revision=253106
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_snapshot.c | 2 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_suspend.c | 2 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 9a9c88ac7c23..ad157aa7bc1e 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -423,7 +423,7 @@ restart: */ for (;;) { vn_finished_write(wrtmp); - if ((error = vfs_write_suspend(vp->v_mount)) != 0) { + if ((error = vfs_write_suspend(vp->v_mount, 0)) != 0) { vn_start_write(NULL, &wrtmp, V_WAIT); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); goto out; diff --git a/sys/ufs/ffs/ffs_suspend.c b/sys/ufs/ffs/ffs_suspend.c index 3198c1a32f55..a8c4578c9178 100644 --- a/sys/ufs/ffs/ffs_suspend.c +++ b/sys/ufs/ffs/ffs_suspend.c @@ -206,7 +206,7 @@ ffs_susp_suspend(struct mount *mp) return (EPERM); #endif - if ((error = vfs_write_suspend(mp)) != 0) + if ((error = vfs_write_suspend(mp, VS_SKIP_UNMOUNT)) != 0) return (error); ump->um_writesuspended = 1; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 57f092c17f8f..a87fdfa2053a 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -257,7 +257,7 @@ ffs_mount(struct mount *mp) return (error); for (;;) { vn_finished_write(mp); - if ((error = vfs_write_suspend(mp)) != 0) + if ((error = vfs_write_suspend(mp, 0)) != 0) return (error); MNT_ILOCK(mp); if (mp->mnt_kern_flag & MNTK_SUSPENDED) { @@ -1255,7 +1255,7 @@ ffs_unmount(mp, mntflags) */ for (;;) { vn_finished_write(mp); - if ((error = vfs_write_suspend(mp)) != 0) + if ((error = vfs_write_suspend(mp, 0)) != 0) return (error); MNT_ILOCK(mp); if (mp->mnt_kern_flag & MNTK_SUSPENDED) { |