f2fs: fix to return correct error number in f2fs_sync_node_pages()
authorChao Yu <chao@kernel.org>
Thu, 8 May 2025 05:14:27 +0000 (07:14 +0200)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 8 May 2025 15:21:58 +0000 (15:21 +0000)
If __write_node_folio() failed, it will return AOP_WRITEPAGE_ACTIVATE,
the incorrect return value may be passed to userspace in below path,
fix it.

- sync_filesystem
 - sync_fs
  - f2fs_issue_checkpoint
   - block_operations
    - f2fs_sync_node_pages
     - __write_node_folio
     : return AOP_WRITEPAGE_ACTIVATE

Cc: stable@vger.kernel.org
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/node.c

index ec74eb9982a537e7351bbfe5b5d10aae08f96176..69308523c34e5db799412f22a3b748b3b7ea6b49 100644 (file)
@@ -2092,10 +2092,14 @@ write_node:
 
                        ret = __write_node_folio(folio, false, &submitted,
                                                wbc, do_balance, io_type, NULL);
-                       if (ret)
+                       if (ret) {
                                folio_unlock(folio);
-                       else if (submitted)
+                               folio_batch_release(&fbatch);
+                               ret = -EIO;
+                               goto out;
+                       } else if (submitted) {
                                nwritten++;
+                       }
 
                        if (--wbc->nr_to_write == 0)
                                break;