ceph: drop CAP_LINK_SHARED when sending "link" request to MDS
PATCH 1/2 ceph: drop CAP_LINK_SHARED when sending "link" request to MDS
From: "Yan, Zheng" <[email protected]>
To handle "link" request, the MDS need to xlock inode's linklock, which requires revoking any CAP_LINK_SHARED.
Signed-off-by Yan, Zheng <[email protected]>
--- fs/ceph/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ceph/dir.c +2 -0
@@ -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);
Signature · 1 line
1.8.1.4
PATCH 2/2 ceph: wake up writer if vmtruncate work get blocked
From: "Yan, Zheng" <[email protected]>
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 <[email protected]>
--- fs/ceph/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/ceph/inode.c +8 -1
@@ -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);
Signature · 1 line
1.8.1.4