Commit 5114a97a authored by Michal Hocko's avatar Michal Hocko Committed by Linus Torvalds

fs: use mapping_set_error instead of opencoded set_bit

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.orgSigned-off-by: default avatarMichal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 97139d4a
...@@ -241,10 +241,7 @@ static void vvp_vmpage_error(struct inode *inode, struct page *vmpage, int ioret ...@@ -241,10 +241,7 @@ static void vvp_vmpage_error(struct inode *inode, struct page *vmpage, int ioret
obj->vob_discard_page_warned = 0; obj->vob_discard_page_warned = 0;
} else { } else {
SetPageError(vmpage); SetPageError(vmpage);
if (ioret == -ENOSPC) mapping_set_error(inode->i_mapping, ioret);
set_bit(AS_ENOSPC, &inode->i_mapping->flags);
else
set_bit(AS_EIO, &inode->i_mapping->flags);
if ((ioret == -ESHUTDOWN || ioret == -EINTR) && if ((ioret == -ESHUTDOWN || ioret == -EINTR) &&
obj->vob_discard_page_warned == 0) { obj->vob_discard_page_warned == 0) {
......
...@@ -398,8 +398,7 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb, ...@@ -398,8 +398,7 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
switch (ret) { switch (ret) {
case -EDQUOT: case -EDQUOT:
case -ENOSPC: case -ENOSPC:
set_bit(AS_ENOSPC, mapping_set_error(wb->vnode->vfs_inode.i_mapping, -ENOSPC);
&wb->vnode->vfs_inode.i_mapping->flags);
break; break;
case -EROFS: case -EROFS:
case -EIO: case -EIO:
...@@ -409,7 +408,7 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb, ...@@ -409,7 +408,7 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
case -ENOMEDIUM: case -ENOMEDIUM:
case -ENXIO: case -ENXIO:
afs_kill_pages(wb->vnode, true, first, last); 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; break;
case -EACCES: case -EACCES:
case -EPERM: case -EPERM:
......
...@@ -351,7 +351,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate) ...@@ -351,7 +351,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
} else { } else {
buffer_io_error(bh, ", lost async page write"); 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); set_buffer_write_io_error(bh);
clear_buffer_uptodate(bh); clear_buffer_uptodate(bh);
SetPageError(page); SetPageError(page);
...@@ -3249,7 +3249,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free) ...@@ -3249,7 +3249,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free)
bh = head; bh = head;
do { do {
if (buffer_write_io_error(bh) && page->mapping) 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)) if (buffer_busy(bh))
goto failed; goto failed;
bh = bh->b_this_page; bh = bh->b_this_page;
......
...@@ -778,7 +778,7 @@ static int writepage_strip(struct page *page, ...@@ -778,7 +778,7 @@ static int writepage_strip(struct page *page,
fail: fail:
EXOFS_DBGMSG("Error: writepage_strip(0x%lx, 0x%lx)=>%d\n", EXOFS_DBGMSG("Error: writepage_strip(0x%lx, 0x%lx)=>%d\n",
inode->i_ino, page->index, ret); inode->i_ino, page->index, ret);
set_bit(AS_EIO, &page->mapping->flags); mapping_set_error(page->mapping, -EIO);
unlock_page(page); unlock_page(page);
return ret; return ret;
} }
......
...@@ -88,7 +88,7 @@ static void ext4_finish_bio(struct bio *bio) ...@@ -88,7 +88,7 @@ static void ext4_finish_bio(struct bio *bio)
if (bio->bi_error) { if (bio->bi_error) {
SetPageError(page); SetPageError(page);
set_bit(AS_EIO, &page->mapping->flags); mapping_set_error(page->mapping, -EIO);
} }
bh = head = page_buffers(page); bh = head = page_buffers(page);
/* /*
......
...@@ -75,7 +75,7 @@ static void f2fs_write_end_io(struct bio *bio) ...@@ -75,7 +75,7 @@ static void f2fs_write_end_io(struct bio *bio)
fscrypt_pullback_bio_page(&page, true); fscrypt_pullback_bio_page(&page, true);
if (unlikely(bio->bi_error)) { if (unlikely(bio->bi_error)) {
set_bit(AS_EIO, &page->mapping->flags); mapping_set_error(page->mapping, -EIO);
f2fs_stop_checkpoint(sbi, true); f2fs_stop_checkpoint(sbi, true);
} }
end_page_writeback(page); end_page_writeback(page);
......
...@@ -269,8 +269,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal, ...@@ -269,8 +269,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
* filemap_fdatawait_range(), set it again so * filemap_fdatawait_range(), set it again so
* that user process can get -EIO from fsync(). * that user process can get -EIO from fsync().
*/ */
set_bit(AS_EIO, mapping_set_error(jinode->i_vfs_inode->i_mapping, -EIO);
&jinode->i_vfs_inode->i_mapping->flags);
if (!ret) if (!ret)
ret = err; ret = err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment