home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
- From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
- Newsgroups: comp.os.linux
- Subject: Re: Swap files (was: Re: .97 kernel and root disk/probs with swapping)
- Message-ID: <1992Sep1.083154.5064@klaava.Helsinki.FI>
- Date: 1 Sep 92 08:31:54 GMT
- References: <1992Aug31.024052.12351@cc.umontreal.ca> <1992Aug31.194716.16232@klaava.Helsinki.FI> <bjl.715328078@freyr>
- Organization: University of Helsinki
- Lines: 54
-
- In article <bjl.715328078@freyr> B.J.Lippolt@research.ptt.nl writes:
- >
- >On the subject of swapping.
- >
- >Would it be possible to implement a scheme (a la SunOS) where you can
- >'add' swap files to the swap space? E.g. I have a 8Mb swap partition, and
- >when I need more (which happens once in a while) I just create a swap
- >file and add it to my 8 Mb swap space. Would this be a minor (i.e. I
- >can do it myself) or a major change?
-
- It wouldn't be too hard: right now swap-map numbers are 31-bit entities,
- and it would be pretty easy to use the high 7 bits to be indexes to the
- swap-file, while keeping the low 24 bits as the page-in-swapfile index.
- The changes would be pretty minimal, although it would need a thorough
- understanding of the swapping setup. It's an interesting thought: I
- might implement it myself some time when I have nothing better to do.
-
- Anyway - if you are interested to implement it yourself, the thing to do
- is roughly:
-
- - change all the swap-file related variables to be arrays, and add a
- "nr_swapfiles" variable that keeps count of how many are in use. The
- variables are rougly:
- swap_bitmap, swap_lockmap, swap_device, swap_file
- as well as some optimization values (lowest_bit, highest_bit) used so
- that the routines wouldn't have to go through the full bitmap all the
- time.
-
- It would look a bit like this:
-
- struct swap_info {
- struct inode * swap_file;
- int swap_device;
- char * swap_bitmap;
- char * swap_lockmap;
- int lowest_bit, int highest_bit;
- } swap_info[MAX_SWAPFILES];
-
- int nr_swapfiles = 0;
-
- - change the "get_swap_page()", "rw_swap_page()" and "swap_free()"
- functions to understand the high bits of the swap block-nr, and
- naturally the sys_swapon() system call to enable it all.
-
- The changes shouldn't actually be more than a couple of lines in each
- place, and it shouldn't be more than a couple of hours work - assuming
- you understand the code.
-
- On the other hand, I've been looking into a "sys_swapoff()" system call
- (which needs a bit more thought: you have to make sure the swapfile
- isn't used by anything), and I might implement the aboev at the same
- time. No promises.
-
- Linus
-