Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[pandora-kernel.git] / fs / cifs / file.c
index 1aa95a5..8a49b2e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/pagevec.h>
 #include <linux/smp_lock.h>
 #include <linux/writeback.h>
+#include <linux/task_io_accounting_ops.h>
 #include <linux/delay.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
@@ -1244,14 +1245,21 @@ retry:
                                wait_on_page_writeback(page);
 
                        if (PageWriteback(page) ||
-                                       !test_clear_page_dirty(page)) {
+                                       !clear_page_dirty_for_io(page)) {
                                unlock_page(page);
                                break;
                        }
 
+                       /*
+                        * This actually clears the dirty bit in the radix tree.
+                        * See cifs_writepage() for more commentary.
+                        */
+                       set_page_writeback(page);
+
                        if (page_offset(page) >= mapping->host->i_size) {
                                done = 1;
                                unlock_page(page);
+                               end_page_writeback(page);
                                break;
                        }
 
@@ -1315,6 +1323,7 @@ retry:
                                        SetPageError(page);
                                kunmap(page);
                                unlock_page(page);
+                               end_page_writeback(page);
                                page_cache_release(page);
                        }
                        if ((wbc->nr_to_write -= n_iov) <= 0)
@@ -1351,11 +1360,23 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc)
         if (!PageUptodate(page)) {
                cFYI(1, ("ppw - page not up to date"));
        }
-       
+
+       /*
+        * Set the "writeback" flag, and clear "dirty" in the radix tree.
+        *
+        * A writepage() implementation always needs to do either this,
+        * or re-dirty the page with "redirty_page_for_writepage()" in
+        * the case of a failure.
+        *
+        * Just unlocking the page will cause the radix tree tag-bits
+        * to fail to update with the state of the page correctly.
+        */
+       set_page_writeback(page);               
        rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE);
        SetPageUptodate(page); /* BB add check for error and Clearuptodate? */
        unlock_page(page);
-       page_cache_release(page);       
+       end_page_writeback(page);
+       page_cache_release(page);
        FreeXid(xid);
        return rc;
 }
@@ -1812,6 +1833,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                        cFYI(1, ("Read error in readpages: %d", rc));
                        break;
                } else if (bytes_read > 0) {
+                       task_io_account_read(bytes_read);
                        pSMBr = (struct smb_com_read_rsp *)smb_read_data;
                        cifs_copy_cache_pages(mapping, page_list, bytes_read,
                                smb_read_data + 4 /* RFC1001 hdr */ +