From owner-freebsd-fs@FreeBSD.ORG Mon Jul 19 07:43:33 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 81AAA1065672 for ; Mon, 19 Jul 2010 07:43:33 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 1A5068FC17 for ; Mon, 19 Jul 2010 07:43:32 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o6J7hRDv006437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 Jul 2010 10:43:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o6J7hRWG033120; Mon, 19 Jul 2010 10:43:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o6J7hR4H033119; Mon, 19 Jul 2010 10:43:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 19 Jul 2010 10:43:27 +0300 From: Kostik Belousov To: Rick Macklem Message-ID: <20100719074327.GV2381@deviant.kiev.zoral.com.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1lE8Wy7Exphh2Vpg" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.2 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-fs@freebsd.org Subject: Re: 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 07:43:33 -0000 --1lE8Wy7Exphh2Vpg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 18, 2010 at 10:40:16PM -0400, Rick Macklem wrote: > 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.) Rather, I said "please commit, but note (in commit message or better in comment) that ..." >=20 > 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? >=20 > 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 @@ > } >=20 > /* > + * 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 =3D NULLVPTOLOWERVP(ap->a_vp); > + VREF(lvp); > + vreleit =3D TRUE; > + } else > + vreleit =3D FALSE; > + retval =3D 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 =3D null_open, > .vop_print =3D null_print, > .vop_reclaim =3D null_reclaim, > + .vop_remove =3D null_remove, > .vop_rename =3D null_rename, > .vop_setattr =3D null_setattr, > .vop_strategy =3D VOP_EOPNOTSUPP, > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org" --1lE8Wy7Exphh2Vpg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkxEAh4ACgkQC3+MBN1Mb4gkpwCg2Z5SusfxE9TDvg2sZ8urYpVI gEwAoIMKZyKEmMEHUZRJYeYuFE6cPMKt =+JA4 -----END PGP SIGNATURE----- --1lE8Wy7Exphh2Vpg--