From: Jaegeuk Kim Date: Fri, 4 May 2018 06:26:02 +0000 (-0700) Subject: UPSTREAM: f2fs: avoid fsync() failure caused by EAGAIN in writepage() X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=086f384e23b5b282e4914ac2ce9522294471abd2;p=sagit-ice-cold%2Fkernel_xiaomi_msm8998.git UPSTREAM: f2fs: avoid fsync() failure caused by EAGAIN in writepage() pageout() in MM traslates EAGAIN, so calls handle_write_error() -> mapping_set_error() -> set_bit(AS_EIO, ...). file_write_and_wait_range() will see EIO error, which is critical to return value of fsync() followed by atomic_write failure to user. Change-Id: I6124ed299baf5e5b8993bb6b54f07bb8771eda8c Signed-off-by: Jaegeuk Kim (cherry picked from commit 520a9486182437847212c8e226d042b1e14b7cc2) --- diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a670702cf3ff..3d846b027fa1 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1902,7 +1902,13 @@ out: redirty_out: redirty_page_for_writepage(wbc, page); - if (!err) + /* + * pageout() in MM traslates EAGAIN, so calls handle_write_error() + * -> mapping_set_error() -> set_bit(AS_EIO, ...). + * file_write_and_wait_range() will see EIO error, which is critical + * to return value of fsync() followed by atomic_write failure to user. + */ + if (!err || wbc->for_reclaim) return AOP_WRITEPAGE_ACTIVATE; unlock_page(page); return err;