From owner-svn-src-head@freebsd.org Fri Aug 5 07:01:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92026BAFAB0; Fri, 5 Aug 2016 07:01:23 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 8C8261D07; Fri, 5 Aug 2016 07:01:22 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id KAA23356; Fri, 05 Aug 2016 10:01:20 +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 1bVZ8C-000PR0-IP; Fri, 05 Aug 2016 10:01:20 +0300 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 To: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201608050623.u756N695018889@repo.freebsd.org> From: Andriy Gapon Message-ID: <6f147caa-a270-6f00-d41f-815c76bc5a7a@FreeBSD.org> Date: Fri, 5 Aug 2016 10:00:02 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <201608050623.u756N695018889@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2016 07:01:23 -0000 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