diff mbox series

[2/3] ceph: check page writeback error during write

Message ID 20190606134754.31725-2-zyan@redhat.com (mailing list archive)
State New, archived
Headers show
Series [1/3] ceph: pass filp to ceph_get_caps() | expand

Commit Message

Yan, Zheng June 6, 2019, 1:47 p.m. UTC
make write(2) return error prematurely if there is writeback error.
User can use fsync() or fdatasync() to clear the error.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
---
 fs/ceph/caps.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index e88a21d830e1..6063e5f4035a 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2816,6 +2816,14 @@  int ceph_get_caps(struct file *filp, int need, int want,
 		break;
 	}
 
+	if (_got & CEPH_CAP_FILE_WR) {
+		ret = filemap_check_wb_err(inode->i_mapping, filp->f_wb_err);
+		if (ret < 0) {
+			ceph_put_cap_refs(ci, _got);
+			return ret;
+		}
+	}
+
 	if ((_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE))
 		ceph_fscache_revalidate_cookie(ci);