Deadlock in nullfs/zfs somewhere

Konstantin Belousov kostikbel at gmail.com
Thu Jul 18 18:52:20 UTC 2013


On Thu, Jul 18, 2013 at 04:40:42PM +0300, Andriy Gapon wrote:
> 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

There is VFS method VFS_SUSP_CLEAN, called when the suspension is
lifted.  UFS uses it to clean the back-queue of work which were
not performed during the suspend, mostly inactivate the postponed
inactive vnodes.  ZFS probably does not need it, since it does
not check for MNTK_SUSPEND, but if it starts care, there is a place
to put the code.

On the other hand, I believe that your patch is notoriously incomplete,
because there should be a lot of threads which mutate ZFS mounts state
and which do not call vn_start_write() around the mutations.  I.e.
all ZFS top-level code which calls into ZFS ops and which is not
coming from VFS.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20130718/faa787dc/attachment.sig>


More information about the freebsd-fs mailing list