From d84248881241351b9eed6971f9bcdad4d2ef36c0 Mon Sep 17 00:00:00 2001 From: majianpeng Date: Tue, 16 Jul 2013 19:36:21 +0800 Subject: ceph: Don't forget the 'up_read(&osdc->map_sem)' if met error. CC: stable@vger.kernel.org Signed-off-by: Jianpeng Ma Reviewed-by: Sage Weil --- fs/ceph/ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fs/ceph') diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index e0b4ef31d3c8..a5ce62eb7806 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -196,8 +196,10 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) r = ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, len, &dl.object_no, &dl.object_offset, &olen); - if (r < 0) + if (r < 0) { + up_read(&osdc->map_sem); return -EIO; + } dl.file_offset -= dl.object_offset; dl.object_size = ceph_file_layout_object_size(ci->i_layout); dl.block_size = ceph_file_layout_su(ci->i_layout); -- cgit v1.2.3 From c2db1373afeda9b99d44f06670308133ff36ec8b Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Sun, 21 Jul 2013 20:25:25 +0800 Subject: ceph: drop CAP_LINK_SHARED when sending "link" request to MDS To handle "link" request, the MDS need to xlock inode's linklock, which requires revoking any CAP_LINK_SHARED. Signed-off-by: Yan, Zheng Reviewed-by: Sage Weil --- fs/ceph/dir.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/ceph') diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index f02d82b7933e..0e4da4a9c213 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -796,6 +796,8 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, req->r_locked_dir = dir; req->r_dentry_drop = CEPH_CAP_FILE_SHARED; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; + /* release LINK_SHARED on source inode (mds will lock it) */ + req->r_old_inode_drop = CEPH_CAP_LINK_SHARED; err = ceph_mdsc_do_request(mdsc, dir, req); if (err) { d_drop(dentry); -- cgit v1.2.3 From 71b43258fca50da88f9d800c7f05ccc742dc7937 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Sun, 21 Jul 2013 20:25:26 +0800 Subject: ceph: wake up writer if vmtruncate work get blocked To write data, the writer first acquires the i_mutex, then try getting caps. The writer may sleep while holding the i_mutex. If the MDS revokes Fb cap in this case, vmtruncate work can't do its job because i_mutex is locked. We should wake up the writer and let it truncate the pages. Signed-off-by: Yan, Zheng Reviewed-by: Sage Weil --- fs/ceph/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'fs/ceph') diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 4906ada4a97c..55aaddb4047e 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1465,7 +1465,14 @@ static void ceph_vmtruncate_work(struct work_struct *work) struct inode *inode = &ci->vfs_inode; dout("vmtruncate_work %p\n", inode); - mutex_lock(&inode->i_mutex); + if (!mutex_trylock(&inode->i_mutex)) { + /* + * the i_mutex can be hold by a writer who is waiting for + * caps. wake up waiters, they will do pending vmtruncate. + */ + wake_up_all(&ci->i_cap_wq); + mutex_lock(&inode->i_mutex); + } __ceph_do_pending_vmtruncate(inode); mutex_unlock(&inode->i_mutex); iput(inode); -- cgit v1.2.3