From: "Luís Henriques" <lhenriques@suse.de>
To: Jeff Layton <jlayton@kernel.org>
Cc: xiubli@redhat.com, idryomov@gmail.com, ceph-devel@vger.kernel.org
Subject: Re: [PATCH] ceph: don't leak snap_rwsem in handle_cap_grant
Date: Mon, 06 Jun 2022 11:12:54 +0100 [thread overview]
Message-ID: <87fski2j89.fsf@brahms.olymp> (raw)
In-Reply-To: <20220603203957.55337-1-jlayton@kernel.org> (Jeff Layton's message of "Fri, 3 Jun 2022 16:39:57 -0400")
Jeff Layton <jlayton@kernel.org> writes:
> 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.
>
> URL: https://tracker.ceph.com/issues/55857
This looks good. Maybe it could have here a 'Fixes: e8a4d26771547'.
Otherwise:
Reviewed-by: Luís Henriques <lhenriques@suse.de>
Cheers,
--
Luís
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> fs/ceph/caps.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 258093e9074d..0a48bf829671 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -3579,24 +3579,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,
> --
>
> 2.36.1
>
next prev parent reply other threads:[~2022-06-06 10:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-03 20:39 [PATCH] ceph: don't leak snap_rwsem in handle_cap_grant Jeff Layton
2022-06-06 5:17 ` Xiubo Li
2022-06-06 10:26 ` Jeff Layton
2022-06-06 11:55 ` Xiubo Li
2022-06-06 7:12 ` Xiubo Li
2022-06-06 10:12 ` Luís Henriques [this message]
2022-06-06 10:36 ` Jeff Layton
2022-06-06 11:58 ` Xiubo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fski2j89.fsf@brahms.olymp \
--to=lhenriques@suse.de \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.