[XFS] fix writeback control handling fix a reversed condition on where to
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / xfs / linux-2.6 / xfs_aops.c
index 9ea33ea6a225747bf3cf82d1221cd362c975eb13..52707b5ddcb82d58648dcbe89b674f465aef5f37 100644 (file)
@@ -722,8 +722,17 @@ xfs_convert_page(
                SetPageUptodate(page);
 
        if (startio) {
-               if (count)
-                       wbc->nr_to_write--;
+               if (count) {
+                       struct backing_dev_info *bdi;
+
+                       bdi = inode->i_mapping->backing_dev_info;
+                       if (bdi_write_congested(bdi)) {
+                               wbc->encountered_congestion = 1;
+                               done = 1;
+                       } else if (--wbc->nr_to_write <= 0) {
+                               done = 1;
+                       }
+               }
                xfs_start_page_writeback(page, wbc, !page_dirty, count);
        }
 
@@ -812,7 +821,7 @@ xfs_page_state_convert(
        int                     all_bh = unmapped;
 
        /* wait for other IO threads? */
-       if (startio && wbc->sync_mode != WB_SYNC_NONE)
+       if (startio && (wbc->sync_mode == WB_SYNC_NONE && wbc->nonblocking))
                trylock_flag |= BMAPI_TRYLOCK;
 
        /* Is this page beyond the end of the file? */