Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jul 2013 16:40:42 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>, Adrian Chadd <adrian@FreeBSD.org>
Cc:        freebsd-fs@FreeBSD.org
Subject:   Re: Deadlock in nullfs/zfs somewhere
Message-ID:  <51E7F05A.5020609@FreeBSD.org>
In-Reply-To: <20130718112814.GA5991@kib.kiev.ua>
References:  <CAJ-Vmomy3MrkSwJLQUGnDuD3EC3HzrudEghSDMeDwzVdaFNpLg@mail.gmail.com> <51DCFEDA.1090901@FreeBSD.org> <CAJ-VmokctCmV4%2By17uvqO9wXEyh0s%2BaXZ9nggvoAgP5%2BZHSgFA@mail.gmail.com> <51E59FD9.4020103@FreeBSD.org> <CAJ-VmokR8jJpdRc_kBJzhW4_R1pJnj3UPfsG5ANpq-kEGwCP9g@mail.gmail.com> <51E67F54.9080800@FreeBSD.org> <CAJ-Vmonk2HAzX38-mbL8hwxiUfL6JyJrMTq0dTBctW=P4dfyEQ@mail.gmail.com> <51E7B686.4090509@FreeBSD.org> <20130718112814.GA5991@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
on 18/07/2013 14:28 Konstantin Belousov said the following:
> Well, I have no opinion.  Making the fs suspended, in other words, preventing
> writers from entering the filesystem code, is probably good.  I do not
> know zfs code to usefully comment on the approach.

OK, fair.

> Note that you must drain existing writers, i.e. call vfs_write_suspend(),
> to set MNTK_SUSPEND.

Here is my take on it, not tested at all.

diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
index 0fc59cc..59c8cbd 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
@@ -2263,8 +2263,12 @@ zfs_suspend_fs(zfsvfs_t *zfsvfs)
 {
 	int error;

-	if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0)
+	if ((error = vfs_write_suspend(zfsvfs->z_vfs)) != 0)
 		return (error);
+	if ((error = zfsvfs_teardown(zfsvfs, B_FALSE)) != 0) {
+		vfs_write_resume(mp, 0);
+		return (error);
+	}
 	dmu_objset_disown(zfsvfs->z_os, zfsvfs);

 	return (0);
@@ -2339,5 +2343,6 @@ bail:
 	rrw_exit(&zfsvfs->z_teardown_lock, FTAG);

+	vfs_write_resume(mp, 0);
 	if (err) {
 		/*
 		 * Since we couldn't reopen zfsvfs::z_os, or

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51E7F05A.5020609>