From owner-freebsd-current@FreeBSD.ORG Thu Jun 2 10:41:46 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 C625A16A41C for ; Thu, 2 Jun 2005 10:41:46 +0000 (GMT) (envelope-from truckman@FreeBSD.org) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67B8943D53 for ; Thu, 2 Jun 2005 10:41:46 +0000 (GMT) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.13.1/8.13.1) with ESMTP id j52AfaQH003213; Thu, 2 Jun 2005 03:41:41 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <200506021041.j52AfaQH003213@gw.catspoiler.org> Date: Thu, 2 Jun 2005 03:41:36 -0700 (PDT) From: Don Lewis To: Alexander@Leidinger.net In-Reply-To: <20050602094332.949xldwlwk4c8k4g@netchild.homeip.net> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Cc: phk@phk.freebsd.dk, current@FreeBSD.org Subject: Re: [RFC] [PATCH] VM & VFS changes 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: Thu, 02 Jun 2005 10:41:46 -0000 On 2 Jun, Alexander Leidinger wrote: > Don Lewis wrote: > >>>>>> Wouldn't a loop like the following be enough? >>>>>> while swap >>>>>> umount unbusy-FS >>>>>> swap-off swap >>>>>> >>>>>> This assumes that swap-off doesn't turns off the swap if it isn't >>>>>> able to put >>>>>> everything back into other swap or physical RAM areas. > >> I think this can be unwound in one pass if a list of the dependency >> pairs is kept and then properly sorted before processing. The types of >> dependencies are: >> md depends on file system (vnode backed md) >> md depends on swap (swap backed file system) >> file system depends on md (md backed file system) >> swap depends on md (swap on an md) >> file system depends on file system (mount relationship) >> First undo any dependencies that ultimately depend on swap, unconfigure >> the swap devices, and finally undo any dependencies that swap depended >> on. > > I still don't understand why my approach above doesn't solve this problem. > > A FS is busy when something is still open. So if the FS is used as a > container for swap, the FS is busy and it isn't supposed to be umounted. If > a md is configured on the swap area you want to disable with swap-off, my > above description allows the call to fail. Since the md/swap/FS part is > cycle-free, we have an upper bound of sum(#md)+sum(#swap)+sum(#FS) > iterations (actually it's less than that, but my point is: a linear number > of iterations with an upper bound) of this loop. When the loop finishes, no > swap is enabled anymore. -> Goal reached. > > What am I overlooking? Create a large, but nearly empty file system, /a Mount a file system backed by a physical disk on /a/b Create the file /a/b/c and configure it to be used as swap Write a large amount of data to the file /a/d, which will overflow RAM and be paged out to /a/b/c It won't be possible to disable swapping to /a/b/c because there is not sufficient RAM to page in the data stored there. It won't be possible to unmount /a/b because /a/b/c is busy. It won't be possible to unmount /a because it is busy because /a/b is mounted on it. If the dependencies are tracked so that this configuration (swapping to anything that is directly or indirectly dependent on a swap-backed file system) can be forbidden, then either the algorithm that I suggested, or your iterative algorithm should work. Your algorithm could even be simplified by pulling the swap-off out of the loop. unconfigure md's that are not busy do { foreach filesystem in reverse(mountlist) { unmount filesystem if (success and backed by md) unconfigure md /* either swap or vnode backed */ } } while (progress) swap-off do { foreach filesystem in reverse(mountlist) { unmount filesystem if (success and backed by md) unconfigure md /* only vnode backed remain */ } } while (progress) Removing the swap-off from the loop may avoid a lot of paging activity because all the paged-out data from swap backed md's will be discarded before swap is disabled.