fs: use mapping_set_error instead of opencoded set_bit
authorMichal Hocko <mhocko@suse.com>
Tue, 11 Oct 2016 20:56:01 +0000 (13:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Oct 2016 22:06:33 +0000 (15:06 -0700)
The mapping_set_error() helper sets the correct AS_ flag for the mapping
so there is no reason to open code it.  Use the helper directly.

[akpm@linux-foundation.org: be honest about conversion from -ENXIO to -EIO]
Link: http://lkml.kernel.org/r/20160912111608.2588-2-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/staging/lustre/lustre/llite/vvp_page.c
fs/afs/write.c
fs/buffer.c
fs/exofs/inode.c
fs/ext4/page-io.c
fs/f2fs/data.c
fs/jbd2/commit.c

index 5d79efc1aafe5cd106a663c62893d4f8ff5c854a..046e84d7a15890e5b624763fe03f66a441eb7740 100644 (file)
@@ -241,10 +241,7 @@ static void vvp_vmpage_error(struct inode *inode, struct page *vmpage, int ioret
                obj->vob_discard_page_warned = 0;
        } else {
                SetPageError(vmpage);
-               if (ioret == -ENOSPC)
-                       set_bit(AS_ENOSPC, &inode->i_mapping->flags);
-               else
-                       set_bit(AS_EIO, &inode->i_mapping->flags);
+               mapping_set_error(inode->i_mapping, ioret);
 
                if ((ioret == -ESHUTDOWN || ioret == -EINTR) &&
                    obj->vob_discard_page_warned == 0) {
index 14d506efd1aaabebd33d4e08a3891e001da2b80f..f865c3f05bea5074a91a547e4682523e8aab88be 100644 (file)
@@ -398,8 +398,7 @@ no_more:
                switch (ret) {
                case -EDQUOT:
                case -ENOSPC:
-                       set_bit(AS_ENOSPC,
-                               &wb->vnode->vfs_inode.i_mapping->flags);
+                       mapping_set_error(wb->vnode->vfs_inode.i_mapping, -ENOSPC);
                        break;
                case -EROFS:
                case -EIO:
@@ -409,7 +408,7 @@ no_more:
                case -ENOMEDIUM:
                case -ENXIO:
                        afs_kill_pages(wb->vnode, true, first, last);
-                       set_bit(AS_EIO, &wb->vnode->vfs_inode.i_mapping->flags);
+                       mapping_set_error(wb->vnode->vfs_inode.i_mapping, -EIO);
                        break;
                case -EACCES:
                case -EPERM:
index 7dad8713fac817e60d613ec55fede7ddca6f2192..b205a629001df1bc936a13aef23fcdbeba04e89d 100644 (file)
@@ -351,7 +351,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
                set_buffer_uptodate(bh);
        } else {
                buffer_io_error(bh, ", lost async page write");
-               set_bit(AS_EIO, &page->mapping->flags);
+               mapping_set_error(page->mapping, -EIO);
                set_buffer_write_io_error(bh);
                clear_buffer_uptodate(bh);
                SetPageError(page);
@@ -3249,7 +3249,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free)
        bh = head;
        do {
                if (buffer_write_io_error(bh) && page->mapping)
-                       set_bit(AS_EIO, &page->mapping->flags);
+                       mapping_set_error(page->mapping, -EIO);
                if (buffer_busy(bh))
                        goto failed;
                bh = bh->b_this_page;
index d42ff527ab217f456f4ec4f17e13386320f1d8fc..d8072bc074a44f74c09c47c2905eb0d1c7ac87dc 100644 (file)
@@ -778,7 +778,7 @@ try_again:
 fail:
        EXOFS_DBGMSG("Error: writepage_strip(0x%lx, 0x%lx)=>%d\n",
                     inode->i_ino, page->index, ret);
-       set_bit(AS_EIO, &page->mapping->flags);
+       mapping_set_error(page->mapping, -EIO);
        unlock_page(page);
        return ret;
 }
index b4cbee936cf8a59808abaed876730671d4715d65..0094923e5ebf56a6a65198cf5a7040078b73240a 100644 (file)
@@ -88,7 +88,7 @@ static void ext4_finish_bio(struct bio *bio)
 
                if (bio->bi_error) {
                        SetPageError(page);
-                       set_bit(AS_EIO, &page->mapping->flags);
+                       mapping_set_error(page->mapping, -EIO);
                }
                bh = head = page_buffers(page);
                /*
index 0d0177c9149c191d7fe64ebb9ff55d7ee03476e4..9ae194fd2fdb81cbc54bfed9220da527d6b21a89 100644 (file)
@@ -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);
index 5bb565f9989ccfde3ba9726e1d39285e5a408d60..31f8ca0466392eef588a2e61fbc5b34b132c5345 100644 (file)
@@ -269,8 +269,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
                         * filemap_fdatawait_range(), set it again so
                         * that user process can get -EIO from fsync().
                         */
-                       set_bit(AS_EIO,
-                               &jinode->i_vfs_inode->i_mapping->flags);
+                       mapping_set_error(jinode->i_vfs_inode->i_mapping, -EIO);
 
                        if (!ret)
                                ret = err;