fs: use mapping_set_error instead of opencoded set_bit
[cascardo/linux.git] / fs / f2fs / data.c
index ed834cd..9ae194f 100644 (file)
@@ -35,7 +35,7 @@ static void f2fs_read_end_io(struct bio *bio)
        int i;
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(FAULT_IO))
+       if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO))
                bio->bi_error = -EIO;
 #endif
 
@@ -75,7 +75,7 @@ static void f2fs_write_end_io(struct bio *bio)
                fscrypt_pullback_bio_page(&page, true);
 
                if (unlikely(bio->bi_error)) {
-                       set_bit(AS_EIO, &page->mapping->flags);
+                       mapping_set_error(page->mapping, -EIO);
                        f2fs_stop_checkpoint(sbi, true);
                }
                end_page_writeback(page);
@@ -1355,6 +1355,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
        int cycled;
        int range_whole = 0;
        int tag;
+       int nwritten = 0;
 
        pagevec_init(&pvec, 0);
 
@@ -1429,6 +1430,8 @@ continue_unlock:
                                done_index = page->index + 1;
                                done = 1;
                                break;
+                       } else {
+                               nwritten++;
                        }
 
                        if (--wbc->nr_to_write <= 0 &&
@@ -1450,6 +1453,10 @@ continue_unlock:
        if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
                mapping->writeback_index = done_index;
 
+       if (nwritten)
+               f2fs_submit_merged_bio_cond(F2FS_M_SB(mapping), mapping->host,
+                                                       NULL, 0, DATA, WRITE);
+
        return ret;
 }
 
@@ -1491,7 +1498,6 @@ static int f2fs_write_data_pages(struct address_space *mapping,
         * if some pages were truncated, we cannot guarantee its mapping->host
         * to detect pending bios.
         */
-       f2fs_submit_merged_bio(sbi, DATA, WRITE);
 
        remove_dirty_inode(inode);
        return ret;