From owner-freebsd-fs@FreeBSD.ORG Thu Sep 6 12:23:04 2012 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 60117106564A; Thu, 6 Sep 2012 12:23:04 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from esa-jnhn.mail.uoguelph.ca (esa-jnhn.mail.uoguelph.ca [131.104.91.44]) by mx1.freebsd.org (Postfix) with ESMTP id 08D1E8FC12; Thu, 6 Sep 2012 12:23:03 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EAE+USFCDaFvO/2dsb2JhbAA9CBaFcLYfgiABAQUjVhsOCgICDRkCWQYtAYdyC6dmkwOBIYoGEYUMgRIDlVmBFI8Ggn+BPAIh X-IronPort-AV: E=Sophos;i="4.80,380,1344225600"; d="scan'208";a="177907467" Received: from erie.cs.uoguelph.ca (HELO zcs3.mail.uoguelph.ca) ([131.104.91.206]) by esa-jnhn-pri.mail.uoguelph.ca with ESMTP; 06 Sep 2012 08:22:57 -0400 Received: from zcs3.mail.uoguelph.ca (localhost.localdomain [127.0.0.1]) by zcs3.mail.uoguelph.ca (Postfix) with ESMTP id 0C04DB4032; Thu, 6 Sep 2012 08:22:57 -0400 (EDT) Date: Thu, 6 Sep 2012 08:22:57 -0400 (EDT) From: Rick Macklem To: Konstantin Belousov Message-ID: <178291859.130610.1346934177033.JavaMail.root@erie.cs.uoguelph.ca> In-Reply-To: <20120905091854.GD33100@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [172.17.91.201] X-Mailer: Zimbra 6.0.10_GA_2692 (ZimbraWebClient - FF3.0 (Win)/6.0.10_GA_2692) Cc: pho@freebsd.org, fs@freebsd.org Subject: Re: Nullfs shared lookup X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2012 12:23:04 -0000 Konstantin Belousov wrote: > I, together with Peter Holm, developed a patch to enable shared > lookups > on nullfs mounts when lower filesystem allows the shared lookups. The > lack > of shared lookup support for nullfs is quite visible on any > VFS-intensive > workloads which utilize path translations. In particular, it was a > complain > on $dayjob which started me thinking about this issue. > > There are two problems which prevent direct translation of shared > lookup bit into nullfs upper mount bit: > > 1. When vfs_lookup() calls VOP_LOOKUP() for nullfs, which passes > lookup > operation to lower fs, resulting vnode is often only shared-locked. > Then > null_nodeget() cannot instantiate covering vnode for lower vnode, > since > insmntque1() and null_hashins() require exclusive lock on the lower. > > The solution is straightforward, if null hash failed to find > pre-existing > nullfs vnode for lower vnode, the lower vnode lock is upgraded. > > 2. (More serious). Nullfs reclaims its vnodes on deactivation. The > cause > is due to nullfs inability to detect reclamation of the lower vnode. > Reclamation of a nullfs vnode at deactivation time prevents a > reference > to the lower vnode to become stale. > > Unfortunately, this means that all lookups on nullfs need exclusive > lock > to instantiate upper vnode, which is never cached. > > Solution which we propose is to add VFS notification to the upper > filesystem about reclamation of the vnode in the lower filesystem. > Now, > vgone() calls new VFS op vfs_reclaim_lowervp() with an argument > lowervp > which is reclaimed. It is possible to register several reclamation > event > listeners, to correctly handle the case of several nullfs mounts over > the same directory. > > For the filesystem not having nullfs mounts over it, the overhead > added is > a single mount interlock lock/unlock in the vnode reclamation path. > > Benchmarks consisting of up 1K threads doing parallel stat(2) on the > same file demonstate almost constant execution time, not depending of > number of running threads. While without the patch, exec time between > single-threaded run and run with 1024 threads performing the same > total > count of stat(2), differ in 6 times. > > Somewhat problematic detail, IMO, is that nullfs reclamation procedure > calls vput() on the lowervp vnode, temporary unlocking the vnode being > reclaimed. This seems to be fine for MPSAFE filesystems, but > not-MPSAFE > code often put partially initialized vnode on some globally visible > list, and later can decide that half-constructed vnode is not needed. > If nullfs mount is created above such filesystem, then other threads > might catch such not properly initialized vnode. Instead of trying > to overcome this case, e.g. by recursing the lower vnode lock in > null_reclaim_lowervp(), I decided to rely on nearby extermination of > non-MPSAFE filesystems support. > > I think that unionfs can also benefit from this mechanism, but I did > not > even looked at unionfs. > > Patch is available at > http://people.freebsd.org/~kib/misc/nullfs_shared_lookup.1.patch > It survived stress2 torturing. > > Comments ? It all sounds reasonable to me. (Not much of a comment, but since I didn't see anyone else commenting, I figured I would:-) No news is good news, I'd guess? rick