提交 0de447c9 编写于 作者: J Jeff Layton 提交者: Zheng Zengkai

ceph: don't leak snap_rwsem in handle_cap_grant

stable inclusion
from stable-v5.10.138
commit aee18421bda6bf12a7cba6a3d7751c0e1cfd0094
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60QFD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=aee18421bda6bf12a7cba6a3d7751c0e1cfd0094

--------------------------------

commit 58dd4385 upstream.

When handle_cap_grant is called on an IMPORT op, then the snap_rwsem is
held and the function is expected to release it before returning. It
currently fails to do that in all cases which could lead to a deadlock.

Fixes: 6f05b30e ("ceph: reset i_requested_max_size if file write is not wanted")
Link: https://tracker.ceph.com/issues/55857Signed-off-by: NJeff Layton <jlayton@kernel.org>
Reviewed-by: NLuís Henriques <lhenriques@suse.de>
Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 b45e4101
......@@ -3501,24 +3501,23 @@ static void handle_cap_grant(struct inode *inode,
fill_inline = true;
}
if (ci->i_auth_cap == cap &&
le32_to_cpu(grant->op) == CEPH_CAP_OP_IMPORT) {
if (newcaps & ~extra_info->issued)
wake = true;
if (le32_to_cpu(grant->op) == CEPH_CAP_OP_IMPORT) {
if (ci->i_auth_cap == cap) {
if (newcaps & ~extra_info->issued)
wake = true;
if (ci->i_requested_max_size > max_size ||
!(le32_to_cpu(grant->wanted) & CEPH_CAP_ANY_FILE_WR)) {
/* re-request max_size if necessary */
ci->i_requested_max_size = 0;
wake = true;
}
if (ci->i_requested_max_size > max_size ||
!(le32_to_cpu(grant->wanted) & CEPH_CAP_ANY_FILE_WR)) {
/* re-request max_size if necessary */
ci->i_requested_max_size = 0;
wake = true;
ceph_kick_flushing_inode_caps(session, ci);
}
ceph_kick_flushing_inode_caps(session, ci);
spin_unlock(&ci->i_ceph_lock);
up_read(&session->s_mdsc->snap_rwsem);
} else {
spin_unlock(&ci->i_ceph_lock);
}
spin_unlock(&ci->i_ceph_lock);
if (fill_inline)
ceph_fill_inline_data(inode, NULL, extra_info->inline_data,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册