home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9562 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.6 KB  |  65 lines

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