Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Sep 2011 09:49:08 +0300
From:      Mikolaj Golub <trociny@freebsd.org>
To:        Robert Millan <rmh@freebsd.org>
Cc:        Josef Karthauser <joe@freebsd.org>, freebsd-fs@freebsd.org, freebsd-bugs@freebsd.org, Adrian Chadd <adrian@freebsd.org>, Mikolaj Golub <trociny@freebsd.org>, Kostik Belousov <kostikbel@gmail.com>, FreeBSD-gnats-submit@freebsd.org
Subject:   Re: kern/159663: sockets don't work though nullfs mounts
Message-ID:  <86litajx97.fsf@in138.ua3>
In-Reply-To: <CAOfDtXPjC2n4sKA%2BEHQV-V1QqgqGeShQQJ8Ertw5eP-pb2APLQ@mail.gmail.com> (Robert Millan's message of "Tue, 27 Sep 2011 07:36:28 %2B0200")
References:  <201108102152.p7ALqUl4075207@red.freebsd.org> <201108102200.p7AM0Nu9026320@freefall.freebsd.org> <CAOfDtXMa6r%2BK5ZmTfuKV5qXNOoqS7kJvRhy4W%2B0jwBhFqfk1PQ@mail.gmail.com> <CAOfDtXM45OT-aZ71-=JE7ZaG4%2B4Db1y4poO9L%2BePZW2%2BAMFXXg@mail.gmail.com> <CAOfDtXMtqd8WonbdwBWL1vaFNte47G-Qo4JAskgM0Y99Ru6U2g@mail.gmail.com> <86k48wz3mc.fsf@kopusha.home.net> <CAOfDtXPjC2n4sKA%2BEHQV-V1QqgqGeShQQJ8Ertw5eP-pb2APLQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=


On Tue, 27 Sep 2011 07:36:28 +0200 Robert Millan wrote:

 RM> 2011/9/25 Mikolaj Golub <trociny@freebsd.org>:
 >> As a proof of concept below is a patch that implements it.

 RM> This works very well, I'm currently using your patch to run X11 over a
 RM> nullfs-mounted /tmp.

 >> The issues with this approach I see so far:
 >>
 >> - we need an additional flag for namei;

 RM> What does this involve?

Well, adding yet another flag just to handle this one case might be not very
good idea :-)

But actually it is possible to do without the additional flag, with the only
hack in nullfs code: in lookup and create return lower vnode if it is a
socket, like in the patch below. It works for me but I have not tested much
and not checked yet if use cases are possible when this makes undesirable
effect.

-- 
Mikolaj Golub


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=nullfs.VSOCK.patch

Index: sys/fs/nullfs/null_vnops.c
===================================================================
--- sys/fs/nullfs/null_vnops.c	(revision 225757)
+++ sys/fs/nullfs/null_vnops.c	(working copy)
@@ -365,16 +365,38 @@ null_lookup(struct vop_lookup_args *ap)
 			vrele(lvp);
 		} else {
 			error = null_nodeget(dvp->v_mount, lvp, &vp);
-			if (error)
+			if (error) {
 				vput(lvp);
-			else
+			} else if (vp->v_type == VSOCK) {
+				vref(lvp);
+				vrele(vp);
+				*ap->a_vpp =  lvp;
+			} else {
 				*ap->a_vpp = vp;
+			}
 		}
 	}
 	return (error);
 }
 
 static int
+null_create(struct vop_create_args *ap)
+{
+	struct vnode *vp, *lvp;
+	int retval;
+
+	retval = null_bypass(&ap->a_gen);
+	vp = *ap->a_vpp;
+	if (retval == 0 && vp->v_type == VSOCK) {
+		lvp = NULLVPTOLOWERVP(vp);
+		vref(lvp);
+		vrele(vp);
+		*ap->a_vpp = lvp;
+	}
+	return (retval);
+}
+
+static int
 null_open(struct vop_open_args *ap)
 {
 	int retval;
@@ -826,6 +848,7 @@ struct vop_vector null_vnodeops = {
 	.vop_accessx =		null_accessx,
 	.vop_advlockpurge =	vop_stdadvlockpurge,
 	.vop_bmap =		VOP_EOPNOTSUPP,
+	.vop_create =           null_create,
 	.vop_getattr =		null_getattr,
 	.vop_getwritemount =	null_getwritemount,
 	.vop_inactive =		null_inactive,

--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86litajx97.fsf>