From owner-freebsd-fs@FreeBSD.ORG Fri Apr 2 09:04:06 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 2FFE8106566B for ; Fri, 2 Apr 2010 09:04:06 +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 BC37F8FC1D for ; Fri, 2 Apr 2010 09:04:05 +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 o32942to037001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Apr 2010 12:04:02 +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 o32941tm086983; Fri, 2 Apr 2010 12:04:01 +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 o32941re086982; Fri, 2 Apr 2010 12:04:01 +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: Fri, 2 Apr 2010 12:04:01 +0300 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20100402090401.GG2415@deviant.kiev.zoral.com.ua> References: <86sk7e1gad.fsf@zhuzha.ua1> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wQFNOvpuONRGomCw" Content-Disposition: inline In-Reply-To: <86sk7e1gad.fsf@zhuzha.ua1> 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=-3.1 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_05, 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: Lock leakage on rename if vop->vop_rename is NULL (kern/107439) 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: Fri, 02 Apr 2010 09:04:06 -0000 --wQFNOvpuONRGomCw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [Do not want to get "YOU ARE NOT IN WHITELIST" garbage] On Fri, Apr 02, 2010 at 10:10:02AM +0300, Mikolaj Golub wrote: > Hi, >=20 > Could somebody look at kern/107439? Although the pr is closed the issue s= till > persists: if a file system does not provide vop_rename the vop_bypass() is > called and the vnods, which are expected to be unlocked in VOP_RENAME(), = are > left locked. >=20 > I have attached there the patch that solves the problem but I am not conf= ident > about the solution. Patch seems to be eaten by unnamed daemon, but survived in the PR log. I think that ap->ap_tvp should be handled too. Anyway, I assume that the proper solution there would be to implement default vop_rename that is in fact identical to deadfs_rename(). The later exists exactly to handle a very similar situation. Please test the patch below. If it works for you, I will combine deadfs_rename() and vop_norename(). Thanks for the report and patch. diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 50bf0d2..7e278a5 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include =20 static int vop_nolookup(struct vop_lookup_args *); +static int vop_norename(struct vop_rename_args *); static int vop_nostrategy(struct vop_strategy_args *); static int get_next_dirent(struct vnode *vp, struct dirent **dpp, char *dirbuf, int dirbuflen, off_t *off, @@ -113,6 +114,7 @@ struct vop_vector default_vnodeops =3D { .vop_poll =3D vop_nopoll, .vop_putpages =3D vop_stdputpages, .vop_readlink =3D VOP_EINVAL, + .vop_rename =3D vop_norename, .vop_revoke =3D VOP_PANIC, .vop_strategy =3D vop_nostrategy, .vop_unlock =3D vop_stdunlock, @@ -206,6 +208,27 @@ vop_nolookup(ap) } =20 /* + * vop_norename: + * + * Handle unlock and reference counting for arguments of vop_rename + * for filesystems that do not implement rename operation. + */ +static int +vop_norename(struct vop_rename_args *ap) +{ + + if (ap->a_tvp !=3D NULL) + vput(ap->a_tvp); + if (ap->a_tdvp =3D=3D ap->a_tvp) + vrele(ap->a_tdvp); + else + vput(ap->a_tdvp); + vrele(ap->a_fdvp); + vrele(ap->a_fvp); + return (EOPNOTSUPP); +} + +/* * vop_nostrategy: * * Strategy routine for VFS devices that have none. --wQFNOvpuONRGomCw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAku1swEACgkQC3+MBN1Mb4ir9gCfYzqnk4so9FZYi4MPTSW7DYt1 uXMAnjXJc7iewWVW7jrn8suOZ0HyMXGa =DdtH -----END PGP SIGNATURE----- --wQFNOvpuONRGomCw--