From owner-freebsd-fs Fri Dec 6 15:59:42 2002 Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD33E37B401 for ; Fri, 6 Dec 2002 15:59:40 -0800 (PST) Received: from smtp02.iprimus.net.au (smtp02.iprimus.net.au [210.50.76.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F7A943EA9 for ; Fri, 6 Dec 2002 15:59:39 -0800 (PST) (envelope-from tim@robbins.dropbear.id.au) Received: from dilbert.robbins.dropbear.id.au ([210.50.218.27]) by smtp02.iprimus.net.au with Microsoft SMTPSVC(5.0.2195.5600); Sat, 7 Dec 2002 10:59:26 +1100 Received: from dilbert.robbins.dropbear.id.au (vac8o01zm78abzs3@localhost [127.0.0.1]) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6) with ESMTP id gB6NxPWo057534; Sat, 7 Dec 2002 10:59:25 +1100 (EST) (envelope-from tim@dilbert.robbins.dropbear.id.au) Received: (from tim@localhost) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6/Submit) id gB6NxNUh057533; Sat, 7 Dec 2002 10:59:23 +1100 (EST) (envelope-from tim) Date: Sat, 7 Dec 2002 10:59:23 +1100 From: Tim Robbins To: Ian Dowse Cc: freebsd-fs@FreeBSD.ORG Subject: Re: vflush() and dependencies between vnodes Message-ID: <20021207105923.A57199@dilbert.robbins.dropbear.id.au> References: <20021205131858.A54625@dilbert.robbins.dropbear.id.au> <200212051022.aa49886@salmon.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200212051022.aa49886@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Thu, Dec 05, 2002 at 10:22:34AM +0000 X-OriginalArrivalTime: 06 Dec 2002 23:59:27.0610 (UTC) FILETIME=[82892DA0:01C29D83] Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Thu, Dec 05, 2002 at 10:22:34AM +0000, Ian Dowse wrote: > In message <20021205131858.A54625@dilbert.robbins.dropbear.id.au>, Tim Robbins > writes: > >I've spent the past couple of days tracking down the bug that caused > >umount -f on smbfs to panic, and umount without -f to often give EBUSY > >when it should not have. > > > >smbfs stores a pointer to each file or directory's parent directory in > >the smbnode struct and vref()'s the parent directory's vnode. This means > >that an smbfs directory vnode cannot be removed before all of its > >children have vrele()'d it. However, vflush() iterates through the > >mount's vnode list from start to end, so if a directory vnode appears > >in the list before its children, it will not be removed. This causes a > >panic when umount -f is used because smbfs_reclaim() calls vrele() on the > >parent vnode after it has already been freed. This also causes umount > >without -f to erroneously return EBUSY. > > >Can anyone think of a better way to solve this problem than to keep > >rescanning the mount's vnode list until no more vnodes can be freed, > >like the patch below does? > > I think for the non-forced case, an approach like this is quite a > reasonable solution to avoid the EBUSY errors. For the forced case > it shouldn't be necessary though - vnodes are not freed until the > last reference is dropped, so even if a referenced vnode gets killed > before the vnode that references it, calling vrele() on the original > vnode should do the right thing and be safe. True, there's no need to rescan the mount's vnode list when it's been forcibly unmounted. All of the "lastpass" logic can probably be removed, then. And you're right, it is safe to vrele() the original vnode. The problem with smbfs is that it stores a pointer to the parent's "smbnode" structure inside its own, but the parent's smbnode is freed when the parent is reclaimed. It ends up accessing data that has already been freed since the parent's vnode is stored inside its smbnode. The solution seems to be to store a pointer to the parent's vnode inside the childrens' struct smbnodes. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message