From owner-freebsd-fs@FreeBSD.ORG Thu Jul 18 13:41:49 2013 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E90F79FC; Thu, 18 Jul 2013 13:41:49 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0878DEBE; Thu, 18 Jul 2013 13:41:48 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA22718; Thu, 18 Jul 2013 16:41:39 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1UzoSg-00057j-T6; Thu, 18 Jul 2013 16:41:38 +0300 Message-ID: <51E7F05A.5020609@FreeBSD.org> Date: Thu, 18 Jul 2013 16:40:42 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130708 Thunderbird/17.0.7 MIME-Version: 1.0 To: Konstantin Belousov , Adrian Chadd Subject: Re: Deadlock in nullfs/zfs somewhere References: <51DCFEDA.1090901@FreeBSD.org> <51E59FD9.4020103@FreeBSD.org> <51E67F54.9080800@FreeBSD.org> <51E7B686.4090509@FreeBSD.org> <20130718112814.GA5991@kib.kiev.ua> In-Reply-To: <20130718112814.GA5991@kib.kiev.ua> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-fs@FreeBSD.org X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 13:41:50 -0000 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