Whamcloud - gitweb
- set_page_dirty ifdef for kernels on either side of 2.4.10
authorbraam <braam>
Wed, 13 Feb 2002 20:31:30 +0000 (20:31 +0000)
committerbraam <braam>
Wed, 13 Feb 2002 20:31:30 +0000 (20:31 +0000)
lustre/llite/rw.c
lustre/obdfs/rw.c

index f5b262b..1402c31 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/errno.h>
 #include <linux/locks.h>
 #include <linux/unistd.h>
-
+#include <linux/version.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
@@ -32,6 +32,7 @@
 #include <linux/lustre_mds.h>
 #include <linux/lustre_light.h>
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10))
 /*
  * Add a page to the dirty page list.
  */
@@ -55,6 +56,27 @@ void __set_page_dirty(struct page *page)
         if (mapping->host)
                 mark_inode_dirty_pages(mapping->host);
 }
+#else
+/*
+ * Add a page to the dirty page list.
+ */
+void set_page_dirty(struct page *page)
+{
+       if (!test_and_set_bit(PG_dirty, &page->flags)) {
+               struct address_space *mapping = page->mapping;
+
+               if (mapping) {
+                       spin_lock(&pagecache_lock);
+                       list_del(&page->list);
+                       list_add(&page->list, &mapping->dirty_pages);
+                       spin_unlock(&pagecache_lock);
+
+                       if (mapping->host)
+                               mark_inode_dirty_pages(mapping->host);
+               }
+       }
+}
+#endif
 
 static void inline ll_oa_from_inode(struct obdo *oa, struct inode *inode)
 {
@@ -102,25 +124,6 @@ static void inline ll_oa_from_inode(struct obdo *oa, struct inode *inode)
         }
 } /* ll_oa_from_inode */
 
-/*
- * Add a page to the dirty page list.
- */
-#if 0
-void set_page_dirty(struct page *page)
-{
-       if (!test_and_set_bit(PG_dirty, &page->flags)) {
-               struct address_space *mapping = page->mapping;
-
-               if (mapping) {
-                       list_del(&page->list);
-                       list_add(&page->list, &mapping->dirty_pages);
-
-                       if (mapping->host)
-                               mark_inode_dirty_pages(mapping->host);
-               }
-       }
-}
-#endif
 
 
 
index c22f6a3..c61883b 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/locks.h>
 #include <linux/unistd.h>
+#include <linux/version.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -43,7 +44,53 @@ static int cache_writes = 0;
 
 /* page cache support stuff */ 
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
+/*
+ * Add a page to the dirty page list.
+ */
+void __set_page_dirty(struct page *page)
+{
+        struct address_space *mapping;
+        spinlock_t *pg_lock;
+
+        pg_lock = PAGECACHE_LOCK(page);
+        spin_lock(pg_lock);
 
+        mapping = page->mapping;
+        spin_lock(&mapping->page_lock);
+
+        list_del(&page->list);
+        list_add(&page->list, &mapping->dirty_pages);
+
+        spin_unlock(&mapping->page_lock);
+        spin_unlock(pg_lock);
+
+        if (mapping->host)
+                mark_inode_dirty_pages(mapping->host);
+}
+/*
+ * Remove page from dirty list
+ */
+void __set_page_clean(struct page *page)
+{
+       struct address_space *mapping = page->mapping;
+       struct inode *inode;
+       
+       if (!mapping)
+               return;
+
+       list_del(&page->list);
+       list_add(&page->list, &mapping->clean_pages);
+
+       inode = mapping->host;
+       if (list_empty(&mapping->dirty_pages)) { 
+               CDEBUG(D_INODE, "inode clean\n");
+               inode->i_state &= ~I_DIRTY_PAGES;
+       }
+       EXIT;
+}
+
+#else
 /*
  * Add a page to the dirty page list.
  */
@@ -63,7 +110,6 @@ void set_page_dirty(struct page *page)
                }
        }
 }
-
 /*
  * Remove page from dirty list
  */
@@ -88,6 +134,9 @@ void __set_page_clean(struct page *page)
        EXIT;
 }
 
+#endif
+
+
 inline void set_page_clean(struct page *page)
 {
        if (PageDirty(page)) {