cifs: return the more nuanced writeback error on close()
authorChenXiaoSong <chenxiaosong2@huawei.com>
Wed, 18 May 2022 14:56:49 +0000 (22:56 +0800)
committerSteve French <stfrench@microsoft.com>
Sun, 22 May 2022 05:01:06 +0000 (00:01 -0500)
As filemap_check_errors() only report -EIO or -ENOSPC, we return more nuanced
writeback error -(file->f_mapping->wb_err & MAX_ERRNO).

  filemap_write_and_wait
    filemap_write_and_wait_range
      filemap_check_errors
        -ENOSPC or -EIO
  filemap_check_wb_err
    errseq_check
      return -(file->f_mapping->wb_err & MAX_ERRNO)

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/file.c

index 03f217fa490d16cd6b59b78ec85af3b979d79bbe..89ebfee5c91c64852792b89f569d1a7bcf5791df 100644 (file)
@@ -2777,8 +2777,11 @@ int cifs_flush(struct file *file, fl_owner_t id)
                rc = filemap_write_and_wait(inode->i_mapping);
 
        cifs_dbg(FYI, "Flush inode %p file %p rc %d\n", inode, file, rc);
-       if (rc)
+       if (rc) {
+               /* get more nuanced writeback errors */
+               rc = filemap_check_wb_err(file->f_mapping, 0);
                trace_cifs_flush_err(inode->i_ino, rc);
+       }
        return rc;
 }