From owner-freebsd-current@FreeBSD.ORG Tue Sep 6 08:21:08 2005 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 201FD16A420; Tue, 6 Sep 2005 08:21:08 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from haven.freebsd.dk (haven.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id BDA5343D48; Tue, 6 Sep 2005 08:21:07 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (unknown [192.168.48.2]) by haven.freebsd.dk (Postfix) with ESMTP id 25503BC66; Tue, 6 Sep 2005 08:21:05 +0000 (UTC) To: Don Lewis From: "Poul-Henning Kamp" In-Reply-To: Your message of "Tue, 06 Sep 2005 00:57:04 PDT." <200509060757.j867v42t031957@gw.catspoiler.org> Date: Tue, 06 Sep 2005 10:21:05 +0200 Message-ID: <64074.1125994865@phk.freebsd.dk> Sender: phk@phk.freebsd.dk Cc: current@FreeBSD.org Subject: Re: patch for ext2fs unmount problem at shutdown X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Sep 2005 08:21:08 -0000 In message <200509060757.j867v42t031957@gw.catspoiler.org>, Don Lewis writes: >> Why is this necessary ? As far as I know we do an orderly unmount >> of all filesystems at shutdown, so shouldn't ext2fs release the >> buffers at that time ? > >We count the busy buffers before unmounting anything, and skip the >unmount if the count is nonzero. I guess this has an interesting historical explanation, but I have a hard time seeing how we could arrive at this logic if we started from scratch today. My best guess is that this is an attempt to detect disk errors: The sync(2) call would push as much as possible onto disks and by skipping the unmount we would not hang waiting for the dead disk. I think we should do away with the nbusy check, including the 35 lines of softupdate magic and call vfs_unmountall() in all circumstances (but retain the check for !cold, RB_NOSYNC and panic). Instead we should add a flag to VFS_UNMOUNT that means "don't hang forever" and use that in vfs_unmountall(). Calling sync(2) up front still makes sense as it will take advantage of any parallism possible to multiple drives. Poul-Henning PS: Considering power management, sleep/suspend modes etc, it would make sense to add a "MNT_CLEAN" flag to pass to VOP_FSYNC which instructed the filesystem to flush everything to disk, and reset any "dirty" flags on the disk to "clean" but leave the filesystem mounted. (On subsequent I/O the first thing the filesystem must do is set the dirty flag again. That way it would be as safe (as possible) to power a sleeping/suspend machine off. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.