Date: Fri, 2 Apr 2010 12:04:01 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Mikolaj Golub <to.my.trociny@gmail.com> Cc: freebsd-fs@freebsd.org Subject: Re: Lock leakage on rename if vop->vop_rename is NULL (kern/107439) Message-ID: <20100402090401.GG2415@deviant.kiev.zoral.com.ua> In-Reply-To: <86sk7e1gad.fsf@zhuzha.ua1> References: <86sk7e1gad.fsf@zhuzha.ua1>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <vm/vnode_pager.h>
=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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100402090401.GG2415>
