f2fs: avoid fsync() failure caused by EAGAIN in writepage()
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 4 May 2018 06:26:02 +0000 (23:26 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 4 May 2018 17:51:22 +0000 (10:51 -0700)
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.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 5477fc09c3cdf7c7b4591ad8301b9aa93099e654..ac8720fa5868ba1381605e68d7d7f9a678bd55de 100644 (file)
@@ -1904,7 +1904,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;