From dev@26th.net  Thu Mar  9 12:58:18 2006
Return-Path: <dev@26th.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1F32316A420
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  9 Mar 2006 12:58:18 +0000 (GMT)
	(envelope-from dev@26th.net)
Received: from 26th.net (26th.net [217.79.183.16])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5CA6D43D58
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  9 Mar 2006 12:58:17 +0000 (GMT)
	(envelope-from dev@26th.net)
Received: by 26th.net (Postfix, from userid 1001)
	id 59E3420C083; Thu,  9 Mar 2006 13:58:16 +0100 (CET)
Message-Id: <20060309125816.59E3420C083@26th.net>
Date: Thu,  9 Mar 2006 13:58:16 +0100 (CET)
From: Anatoli Klassen <dev@26th.net>
Reply-To: Anatoli Klassen <dev@26th.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: procfs shows wrong data if executable is running from nullfs
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         94269
>Category:       kern
>Synopsis:       [nullfs] procfs shows wrong data if executable is running from nullfs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kib
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 09 13:00:12 GMT 2006
>Closed-Date:    Sun May 31 15:04:54 UTC 2009
>Last-Modified:  Sun May 31 15:04:54 UTC 2009
>Originator:     Anatoli Klassen
>Release:        FreeBSD 6.1-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD pluto 6.1-PRERELEASE FreeBSD 6.1-PRERELEASE #0: Wed Mar  8 23:08:16 CET 2006     root@pluto:/usr/obj/usr/src/sys/PLUTO  i386


	
>Description:
I have a nullfs-mounted dir with some executables and a mounted procfs (under
/proc).  Now if one of the executables tries to read /proc/curproc/file it
got an error or sometimes wrong path.

>How-To-Repeat:
# mount -t procfs procfs /proc
# mount -t nullfs /bin /mnt
# /bin/ls -l /proc/curproc/file
lr--r--r--  1 root  wheel  0 Mar  9 13:53 /proc/curproc/file -> /bin/ls
# /mnt/ls -l /proc/curproc/file
lr--r--r--  1 root  wheel  0 Mar  9 13:53 /proc/curproc/file -> unknown

The second ls shows wrong info.

>Fix:

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: rwatson 
State-Changed-When: Sat Mar 8 20:59:03 UTC 2008 
State-Changed-Why:  
This is an accurate bug report -- procfs and other related tools rely on 
the name cache to generate names for file system objects on demand. 
However, nullfs doesn't use the name cache, as the underlying file system 
layer will already be performing its own caching on the name space. 

Transition this to suspended as it's not clear what the right fix for 
this is.  From a performance perspective, it doesn't make a lot of sense 
to use the name cache for nullfs, and there is otherwise no good source 
of name data with which to build a name for an arbitrary vnode.  There is 
also no cache invalidation of "higher layers" with file system stacking 
for the name cache, so quite a lot of work would have to be done in order 
to implement it with proper name cache invalidation. 

Thanks for the report; hopefully we can interest someone in further 
investigating this in the future. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=94269 
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 18 04:25:33 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94269 
State-Changed-From-To: suspended->open 
State-Changed-By: kib 
State-Changed-When: Mon May 18 14:20:53 UTC 2009 
State-Changed-Why:  
I have prototyped VOP_VPTOCNP bypass for CURRENT. 


Responsible-Changed-From-To: freebsd-fs->kib 
Responsible-Changed-By: kib 
Responsible-Changed-When: Mon May 18 14:20:53 UTC 2009 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94269 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/94269: commit references a PR
Date: Sun, 31 May 2009 14:58:58 +0000 (UTC)

 Author: kib
 Date: Sun May 31 14:58:43 2009
 New Revision: 193175
 URL: http://svn.freebsd.org/changeset/base/193175
 
 Log:
   Implement the bypass routine for VOP_VPTOCNP in nullfs.
   Among other things, this makes procfs <pid>/file working for executables
   started from nullfs mount.
   
   Tested by:	pho
   PR:	94269, 104938
 
 Modified:
   head/sys/fs/nullfs/null_vnops.c
 
 Modified: head/sys/fs/nullfs/null_vnops.c
 ==============================================================================
 --- head/sys/fs/nullfs/null_vnops.c	Sun May 31 14:57:43 2009	(r193174)
 +++ head/sys/fs/nullfs/null_vnops.c	Sun May 31 14:58:43 2009	(r193175)
 @@ -741,6 +741,55 @@ null_vptofh(struct vop_vptofh_args *ap)
  	return VOP_VPTOFH(lvp, ap->a_fhp);
  }
  
 +static int
 +null_vptocnp(struct vop_vptocnp_args *ap)
 +{
 +	struct vnode *vp = ap->a_vp;
 +	struct vnode **dvp = ap->a_vpp;
 +	struct vnode *lvp, *ldvp;
 +	int error, locked;
 +
 +	if (vp->v_type == VDIR)
 +		return (vop_stdvptocnp(ap));
 +
 +	locked = VOP_ISLOCKED(vp);
 +	lvp = NULLVPTOLOWERVP(vp);
 +	vhold(lvp);
 +	VOP_UNLOCK(vp, 0); /* vp is held by vn_vptocnp_locked that called us */
 +	ldvp = lvp;
 +	error = vn_vptocnp(&ldvp, ap->a_buf, ap->a_buflen);
 +	vdrop(lvp);
 +	if (error != 0) {
 +		vn_lock(vp, locked | LK_RETRY);
 +		return (ENOENT);
 +	}
 +
 +	/*
 +	 * Exclusive lock is required by insmntque1 call in
 +	 * null_nodeget()
 +	 */
 +	error = vn_lock(ldvp, LK_EXCLUSIVE);
 +	if (error != 0) {
 +		vn_lock(vp, locked | LK_RETRY);
 +		vdrop(ldvp);
 +		return (ENOENT);
 +	}
 +	vref(ldvp);
 +	vdrop(ldvp);
 +	error = null_nodeget(vp->v_mount, ldvp, dvp);
 +	if (error == 0) {
 +#ifdef DIAGNOSTIC
 +		NULLVPTOLOWERVP(*dvp);
 +#endif
 +		vhold(*dvp);
 +		vput(*dvp);
 +	} else
 +		vput(ldvp);
 +
 +	vn_lock(vp, locked | LK_RETRY);
 +	return (error);
 +}
 +
  /*
   * Global vfs data structures
   */
 @@ -762,6 +811,6 @@ struct vop_vector null_vnodeops = {
  	.vop_setattr =		null_setattr,
  	.vop_strategy =		VOP_EOPNOTSUPP,
  	.vop_unlock =		null_unlock,
 -	.vop_vptocnp =		vop_stdvptocnp,
 +	.vop_vptocnp =		null_vptocnp,
  	.vop_vptofh =		null_vptofh,
  };
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: kib 
State-Changed-When: Sun May 31 15:04:20 UTC 2009 
State-Changed-Why:  
Patch is in HEAD, no MFC planned. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94269 
>Unformatted:
