Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Aug 2016 10:00:02 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org
Subject:   Re: svn commit: r303763 - in head/sys/cddl: compat/opensolaris/sys contrib/opensolaris/uts/common/fs/zfs contrib/opensolaris/uts/common/fs/zfs/sys
Message-ID:  <6f147caa-a270-6f00-d41f-815c76bc5a7a@FreeBSD.org>
In-Reply-To: <201608050623.u756N695018889@repo.freebsd.org>
References:  <201608050623.u756N695018889@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 05/08/2016 09:23, Andriy Gapon wrote:
>   - replace ZFS_ENTER mechanism with VFS managed / visible mechanism
>   - replace zfs_zget with zfs_vget[f] as much as possible

I'd like to add a couple more words about these items.

At the moment the operation like rollback and (incremental) receive are
protected by z_teardown_lock that is acquired within ZPL and thus after
vnode locks acquired by VFS.

That has several consequences:

- we have to be very careful to not acquire any vnode locks within
ZFS_ENTER + ZFS_EXIT delimited blocks and that leads to more complex code

- as a consequence we can not lock ZFS vnodes right when we get them, so
we have to resort to some tricks

- zfs rollback, as an example, may cause trouble for operations like
zfs_remove, because the parent and child vnodes are looked up (and
locked) before calling zfs_remove and by the time it grabs
z_teardown_lock those vnodes may already point to arbitrary nodes as a
result of the rollback

- there is a LOR between the normal path (e.g. page in or page out)
where the vnode and page locks are acquired before z_teardown_lock and
the rollback path where ZPL calls vn_pages_remove() while holding the
tear-down lock.

So, logically we should acquire a lock that protects a filesystem from a
rollback (or other out-of-band modification) before acquiring any of its
vnode locks.  Currently we have a similar but rather FFS-specific
mechanism of vn_start_write and vfs_write_suspend.  The mechanism is
used for blocking writes when taking FFS snapshots, but it could be
extended to block reads for rollbacks.

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6f147caa-a270-6f00-d41f-815c76bc5a7a>