From owner-svn-src-stable-8@FreeBSD.ORG Tue Sep 14 01:28:06 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C7F81065673; Tue, 14 Sep 2010 01:28:06 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D45768FC19; Tue, 14 Sep 2010 01:28:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8E1S5SX051865; Tue, 14 Sep 2010 01:28:05 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8E1S5ZV051863; Tue, 14 Sep 2010 01:28:05 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201009140128.o8E1S5ZV051863@svn.freebsd.org> From: Rick Macklem Date: Tue, 14 Sep 2010 01:28:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212590 - stable/8/sys/fs/nullfs X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2010 01:28:06 -0000 Author: rmacklem Date: Tue Sep 14 01:28:05 2010 New Revision: 212590 URL: http://svn.freebsd.org/changeset/base/212590 Log: MFC: r212043 Add a null_remove() function to nullfs, so that the v_usecount of the lower level vnode is incremented to greater than 1 when the upper level vnode's v_usecount is greater than one. This is necessary for the NFS clients, so that they will do a silly rename of the file instead of actually removing it when the file is still in use. It is "racy", since the v_usecount is incremented in many places in the kernel with minimal synchronization, but an extraneous silly rename is preferred to not doing a silly rename when it is required. The only other file systems that currently check the value of v_usecount in their VOP_REMOVE() functions are nwfs and smbfs. These file systems choose to fail a remove when the v_usecount is greater than 1 and I believe will function more correctly with this patch, as well. Modified: stable/8/sys/fs/nullfs/null_vnops.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/fs/nullfs/null_vnops.c ============================================================================== --- stable/8/sys/fs/nullfs/null_vnops.c Tue Sep 14 01:27:53 2010 (r212589) +++ stable/8/sys/fs/nullfs/null_vnops.c Tue Sep 14 01:28:05 2010 (r212590) @@ -499,6 +499,32 @@ null_accessx(struct vop_accessx_args *ap } /* + * 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. + * Unfortunately v_usecount is incremented in many places in + * the kernel and, as such, there may be races that result in + * the NFS client doing an extraneous silly rename, but that seems + * preferable to not doing a silly rename when it is needed. + */ +static int +null_remove(struct vop_remove_args *ap) +{ + int retval, vreleit; + struct vnode *lvp; + + if (vrefcnt(ap->a_vp) > 1) { + lvp = NULLVPTOLOWERVP(ap->a_vp); + VREF(lvp); + vreleit = 1; + } else + vreleit = 0; + retval = null_bypass(&ap->a_gen); + if (vreleit != 0) + 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. @@ -808,6 +834,7 @@ struct vop_vector null_vnodeops = { .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,