From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 19 07:27:07 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B0BB737B401 for ; Thu, 19 Jun 2003 07:27:07 -0700 (PDT) Received: from frontend1.aha.ru (fish.zenon.net [213.189.198.214]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD70D43FD7 for ; Thu, 19 Jun 2003 07:27:05 -0700 (PDT) (envelope-from uitm@blackflag.ru) Received: from [195.2.90.70] (HELO slt.oz) by frontend1.aha.ru (CommuniGate Pro SMTP 4.0.6) with ESMTP id 193157669 for freebsd-hackers@freebsd.org; Thu, 19 Jun 2003 18:27:03 +0400 Received: (from uitm@localhost) by slt.oz (8.8.8/8.8.8) id SAA00437 for freebsd-hackers@freebsd.org; Thu, 19 Jun 2003 18:28:47 +0400 (MSD) From: Andrey Alekseyev Message-Id: <200306191428.SAA00437@slt.oz> In-Reply-To: <200306190955.NAA00538@slt.oz> from Andrey Alekseyev at "Jun 19, 3 01:54:31 pm" To: freebsd-hackers@freebsd.org Date: Thu, 19 Jun 2003 18:28:45 +0400 (MSD) X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: open() and ESTALE error X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2003 14:27:08 -0000 Corrections: - the patch is against STABLE - I know the second lookup will fail if the *current* directory itself is stale :) > Could anyone please be so kind to comment this issue? In particular, I'd like to know if I need NDINIT before entering vn_open() again, as there are several comments throughout the code about "struct nd" not being safe after namei() and lookup(). However, the patch seems to work well without NDINIT. Another thing that interests me, is if any vnode leakage is possible with re-entering vn_open() for the second time. It seems to me that not (as the nd.ni_vp is vput()'d inside vn_open() in case of any error after a successful lookup with namei()). > --- kern/vfs_syscalls.c.orig Thu Jun 19 13:22:50 2003 > +++ kern/vfs_syscalls.c Thu Jun 19 13:29:11 2003 > @@ -1008,6 +1008,7 @@ > int type, indx, error; > struct flock lf; > struct nameidata nd; > + int stale = 0; > > oflags = SCARG(uap, flags); > if ((oflags & O_ACCMODE) == O_ACCMODE) > @@ -1025,8 +1026,15 @@ > * the descriptor while we are blocked in vn_open() > */ > fhold(fp); > +again: > error = vn_open(&nd, flags, cmode); > if (error) { > + /* > + * if the underlying filesystem returns ESTALE > + * we must have used a cached file handle. > + */ > + if (error == ESTALE && stale++ == 0) > + goto again; > /* > * release our own reference > */