Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.3.8 /mm/swap_state.c

Filename:/mm/swap_state.c
Lines Added:20
Lines Deleted:19
Also changed in: (Previous) 2.3.7  2.2.0-pre7  2.2.0-pre3  2.1.6  2.1.4 
(Following) 2.3.9  2.3.13  2.3.16  2.3.22  2.3.23  2.3.24 

Location
[  2.3.8
  [  mm
     o  swap_state.c

Patch

diff -u --recursive --new-file v2.3.7/linux/mm/swap_state.c linux/mm/swap_state.c
--- v2.3.7/linux/mm/swap_state.c   Mon Jun 21 11:18:01 1999
+++ linux/mm/swap_state.c   Tue Jun 22 14:24:34 1999
@@ -66,7 +66,7 @@
 }
 #endif
 
-int add_to_swap_cache(struct page *page, unsigned long entry)
+void add_to_swap_cache(struct page *page, unsigned long entry)
 {
 #ifdef SWAP_CACHE_INFO
    swap_cache_add_total++;
@@ -79,19 +79,12 @@
       printk(KERN_ERR "swap_cache: replacing non-empty entry %08lx "
             "on page %08lx\n",
             page->offset, page_address(page));
-      return 0;
    }
    if (page->inode) {
       printk(KERN_ERR "swap_cache: replacing page-cached entry "
             "on page %08lx\n", page_address(page));
-      return 0;
    }
-   get_page(page);
-   page->inode = &swapper_inode;
-   page->offset = entry;
-   add_page_to_hash_queue(page, &swapper_inode, entry);
-   add_page_to_inode_queue(&swapper_inode, page);
-   return 1;
+   add_to_page_cache(page, &swapper_inode, entry);
 }
 
 /*
@@ -202,21 +195,27 @@
 
 static inline void remove_from_swap_cache(struct page *page)
 {
-   if (!page->inode) {
+   struct inode *inode = page->inode;
+
+   if (!inode) {
       printk ("VM: Removing swap cache page with zero inode hash "
          "on page %08lx\n", page_address(page));
       return;
    }
-   if (page->inode != &swapper_inode) {
+   if (inode != &swapper_inode) {
       printk ("VM: Removing swap cache page with wrong inode hash "
          "on page %08lx\n", page_address(page));
    }
+   if (!PageSwapCache(page))
+      PAGE_BUG(page);
 
 #ifdef DEBUG_SWAP
    printk("DebugVM: remove_from_swap_cache(%08lx count %d)\n",
          page_address(page), page_count(page));
 #endif
    PageClearSwapCache(page);
+   if (inode->i_op->flushpage)
+      inode->i_op->flushpage(inode, page, 0);
    remove_inode_page(page);
 }
 
@@ -266,8 +265,14 @@
    /* 
     * If we are the only user, then free up the swap cache. 
     */
-   if (PageSwapCache(page) && !is_page_shared(page))
-      delete_from_swap_cache(page);
+   lock_page(page);
+   if (PageSwapCache(page) && !is_page_shared(page)) {
+      long entry = page->offset;
+      remove_from_swap_cache(page);
+      swap_free(entry);
+      page_cache_release(page);
+   }
+   UnlockPage(page);
    
    __free_page(page);
 }
@@ -351,11 +356,8 @@
    /* 
     * Add it to the swap cache and read its contents.
     */
-   if (!add_to_swap_cache(new_page, entry))
-      goto out_free_page;
-
-   LockPage(new_page);
-   rw_swap_page(READ, entry, (char *) new_page_addr, wait);
+   add_to_swap_cache(new_page, entry);
+   rw_swap_page(READ, new_page, wait);
 #ifdef DEBUG_SWAP
    printk("DebugVM: read_swap_cache_async created "
          "entry %08lx at %p\n",
@@ -370,4 +372,3 @@
 out:
    return found_page;
 }
-


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.