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@xxxxxxxxxx> --- fs/ceph/caps.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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); -- 2.17.2