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

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

Advertisement

Kernel v2.4.6 /mm/filemap.c

Filename:/mm/filemap.c
Lines Added:21
Lines Deleted:13
Also changed in: (Previous) 2.4.6-pre9  2.4.6-pre8  2.4.6-pre7  2.4.6-pre6  2.4.6-pre5  2.4.6-pre4 
(Following) 2.4.6-ac1  2.4.6-ac2  2.4.6-ac3  2.4.6-ac4  2.4.6-ac5  2.4.7-pre4 

Location
[  2.4.6
  [  mm
     o  filemap.c

Patch

diff -u --recursive --new-file v2.4.5/linux/mm/filemap.c linux/mm/filemap.c
--- v2.4.5/linux/mm/filemap.c   Tue May 22 10:52:35 2001
+++ linux/mm/filemap.c   Tue Jun 12 11:16:41 2001
@@ -230,17 +230,17 @@
       unsigned long offset;
 
       page = list_entry(curr, struct page, list);
-      curr = curr->next;
       offset = page->index;
 
       /* Is one of the pages to truncate? */
       if ((offset >= start) || (*partial && (offset + 1) == start)) {
+         list_del(head);
+         list_add(head, curr);
          if (TryLockPage(page)) {
             page_cache_get(page);
             spin_unlock(&pagecache_lock);
             wait_on_page(page);
-            page_cache_release(page);
-            return 1;
+            goto out_restart;
          }
          page_cache_get(page);
          spin_unlock(&pagecache_lock);
@@ -252,11 +252,15 @@
             truncate_complete_page(page);
 
          UnlockPage(page);
-         page_cache_release(page);
-         return 1;
+         goto out_restart;
       }
+      curr = curr->next;
    }
    return 0;
+out_restart:
+   page_cache_release(page);
+   spin_lock(&pagecache_lock);
+   return 1;
 }
 
 
@@ -273,15 +277,19 @@
 {
    unsigned long start = (lstart + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
    unsigned partial = lstart & (PAGE_CACHE_SIZE - 1);
+   int complete;
 
-repeat:
    spin_lock(&pagecache_lock);
-   if (truncate_list_pages(&mapping->clean_pages, start, &partial))
-      goto repeat;
-   if (truncate_list_pages(&mapping->dirty_pages, start, &partial))
-      goto repeat;
-   if (truncate_list_pages(&mapping->locked_pages, start, &partial))
-      goto repeat;
+   do {
+      complete = 1;
+      while (truncate_list_pages(&mapping->clean_pages, start, &partial))
+         complete = 0;
+      while (truncate_list_pages(&mapping->dirty_pages, start, &partial))
+         complete = 0;
+      while (truncate_list_pages(&mapping->locked_pages, start, &partial))
+         complete = 0;
+   } while (!complete);
+   /* Traversed all three lists without dropping the lock */
    spin_unlock(&pagecache_lock);
 }
 
@@ -529,7 +537,7 @@
    if (PageLocked(page))
       BUG();
 
-   flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (1 << PG_dirty) | (1 << PG_referenced)+
 | (1 << PG_arch_1));
+   flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (1 << PG_dirty) | (1 << PG_referenced)+
 | (1 << PG_arch_1) | (1 << PG_checked));
    page->flags = flags | (1 << PG_locked);
    page_cache_get(page);
    page->index = offset;


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