From: Xiubo Li <xiubli@xxxxxxxxxx> Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx> --- fs/ceph/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index cb0ad0faee45..b371f596b97d 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2281,7 +2281,7 @@ static int fill_fscrypt_truncate(struct inode *inode, /* Try to writeback the dirty pagecaches */ if (issued & (CEPH_CAP_FILE_BUFFER)) - filemap_fdatawrite(&inode->i_data); + filemap_write_and_wait(inode->i_mapping); page = __page_cache_alloc(GFP_KERNEL); if (page == NULL) { @@ -2393,6 +2393,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *c bool fill_fscrypt; int truncate_retry = 20; /* The RMW will take around 50ms */ +retry: prealloc_cf = ceph_alloc_cap_flush(); if (!prealloc_cf) return -ENOMEM; @@ -2404,7 +2405,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *c return PTR_ERR(req); } -retry: fill_fscrypt = false; spin_lock(&ci->i_ceph_lock); issued = __ceph_caps_issued(ci, NULL); @@ -2667,6 +2667,8 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *c if (err == -EAGAIN && truncate_retry--) { dout("setattr %p result=%d (%s locally, %d remote), retry it!\n", inode, err, ceph_cap_string(dirtied), mask); + ceph_mdsc_put_request(req); + ceph_free_cap_flush(prealloc_cf); goto retry; } } -- 2.27.0