Date: Thu, 2 Jun 2005 03:41:36 -0700 (PDT) From: Don Lewis <truckman@FreeBSD.org> To: Alexander@Leidinger.net Cc: phk@phk.freebsd.dk, current@FreeBSD.org Subject: Re: [RFC] [PATCH] VM & VFS changes Message-ID: <200506021041.j52AfaQH003213@gw.catspoiler.org> In-Reply-To: <20050602094332.949xldwlwk4c8k4g@netchild.homeip.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2 Jun, Alexander Leidinger wrote: > Don Lewis <truckman@FreeBSD.org> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506021041.j52AfaQH003213>