From owner-freebsd-fs@FreeBSD.ORG Mon Jul 19 02:22:34 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F1F9B106564A for ; Mon, 19 Jul 2010 02:22:34 +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 A9CB48FC12 for ; Mon, 19 Jul 2010 02:22:34 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnoGAGpTQ0yDaFvK/2dsb2JhbACTMQEBjDlxvgGFJQQ X-IronPort-AV: E=Sophos;i="4.55,224,1278302400"; d="scan'208";a="86212153" Received: from fraser.cs.uoguelph.ca ([131.104.91.202]) by esa-jnhn-pri.mail.uoguelph.ca with ESMTP; 18 Jul 2010 22:22:31 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by fraser.cs.uoguelph.ca (Postfix) with ESMTP id A96CBC399; Sun, 18 Jul 2010 22:22:33 -0400 (EDT) X-Virus-Scanned: amavisd-new at fraser.cs.uoguelph.ca Received: from fraser.cs.uoguelph.ca ([127.0.0.1]) by localhost (fraser.cs.uoguelph.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UthMehLtREH6; Sun, 18 Jul 2010 22:22:33 -0400 (EDT) Received: from muncher.cs.uoguelph.ca (muncher.cs.uoguelph.ca [131.104.91.102]) by fraser.cs.uoguelph.ca (Postfix) with ESMTP id 40AE4C388; Sun, 18 Jul 2010 22:22:33 -0400 (EDT) Received: from localhost (rmacklem@localhost) by muncher.cs.uoguelph.ca (8.11.7p3+Sun/8.11.6) with ESMTP id o6J2eGb22442; Sun, 18 Jul 2010 22:40:16 -0400 (EDT) X-Authentication-Warning: muncher.cs.uoguelph.ca: rmacklem owned process doing -bs Date: Sun, 18 Jul 2010 22:40:16 -0400 (EDT) From: Rick Macklem X-X-Sender: rmacklem@muncher.cs.uoguelph.ca To: freebsd-fs@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: fix for remove for NFS through nullfs 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: Mon, 19 Jul 2010 02:22:35 -0000 Mikolaj Golub submitted the attached patch that fixes a problem w.r.t. a nullfs mounted NFS mount point for remove. The problem is that, without this patch, NFS does not see that a file is still open (v_usecount > 1) when removed and removes it instead of silly renaming it. This patch increments the v_usecount of the lower level vnode during the remove call, so that silly rename works. kib@ has noted that this may be "racy" and result in silly rename happening when it isn't required but, imho, that is less of a problem than it never working. (I have tested it a bit for NFS and UFS and it seems to work for those file systems under a nullfs mount.) Why I am posting is that I am wondering if anyone knows of a file system type where this extra v_usecount on the vnode at the time of remove will/might cause problems? Thanks in advance for looking at this, rick --- submitted patch for nullfs --- --- fs/nullfs/null_vnops.c.sav 2010-07-18 19:33:00.000000000 -0400 +++ fs/nullfs/null_vnops.c 2010-07-18 19:35:25.000000000 -0400 @@ -499,6 +499,29 @@ } /* + * Increasing refcount of lower vnode is needed at least for the case + * when lower FS is NFS to do sillyrename if the file is in use. + */ +static int +null_remove(struct vop_remove_args *ap) +{ + int retval; + struct vnode *lvp; + boolean_t vreleit; + + if (ap->a_vp->v_usecount > 1) { + lvp = NULLVPTOLOWERVP(ap->a_vp); + VREF(lvp); + vreleit = TRUE; + } else + vreleit = FALSE; + retval = null_bypass(&ap->a_gen); + if (vreleit) + vrele(lvp); + return (retval); +} + +/* * We handle this to eliminate null FS to lower FS * file moving. Don't know why we don't allow this, * possibly we should. @@ -809,6 +832,7 @@ .vop_open = null_open, .vop_print = null_print, .vop_reclaim = null_reclaim, + .vop_remove = null_remove, .vop_rename = null_rename, .vop_setattr = null_setattr, .vop_strategy = VOP_EOPNOTSUPP,