All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Ceph Development <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 2/3] ceph: clean up locking annotation for ceph_get_snap_realm and __lookup_snap_realm
Date: Mon, 21 Jun 2021 22:48:39 +0200	[thread overview]
Message-ID: <CAOi1vP83Za9rW3wK-XvOW8k=UXObczyQeQgTmrQRRXJ0yOmXsw@mail.gmail.com> (raw)
In-Reply-To: <20210603165231.110559-3-jlayton@kernel.org>

On Thu, Jun 3, 2021 at 6:52 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> They both say that the snap_rwsem must be held for write, but I don't
> see any real reason for it, and it's not currently always called that
> way.
>
> The lookup is just walking the rbtree, so holding it for read should be
> fine there. The "get" is bumping the refcount and (possibly) removing
> it from the empty list. I see no need to hold the snap_rwsem for write
> for that.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/snap.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
> index bc6c33d485e6..f8cac2abab3f 100644
> --- a/fs/ceph/snap.c
> +++ b/fs/ceph/snap.c
> @@ -60,12 +60,12 @@
>  /*
>   * increase ref count for the realm
>   *
> - * caller must hold snap_rwsem for write.
> + * caller must hold snap_rwsem.
>   */
>  void ceph_get_snap_realm(struct ceph_mds_client *mdsc,
>                          struct ceph_snap_realm *realm)
>  {
> -       lockdep_assert_held_write(&mdsc->snap_rwsem);
> +       lockdep_assert_held(&mdsc->snap_rwsem);
>
>         dout("get_realm %p %d -> %d\n", realm,
>              atomic_read(&realm->nref), atomic_read(&realm->nref)+1);
> @@ -139,7 +139,7 @@ static struct ceph_snap_realm *ceph_create_snap_realm(
>  /*
>   * lookup the realm rooted at @ino.
>   *
> - * caller must hold snap_rwsem for write.
> + * caller must hold snap_rwsem.
>   */
>  static struct ceph_snap_realm *__lookup_snap_realm(struct ceph_mds_client *mdsc,
>                                                    u64 ino)
> @@ -147,7 +147,7 @@ static struct ceph_snap_realm *__lookup_snap_realm(struct ceph_mds_client *mdsc,
>         struct rb_node *n = mdsc->snap_realms.rb_node;
>         struct ceph_snap_realm *r;
>
> -       lockdep_assert_held_write(&mdsc->snap_rwsem);
> +       lockdep_assert_held(&mdsc->snap_rwsem);
>
>         while (n) {
>                 r = rb_entry(n, struct ceph_snap_realm, node);
> --
> 2.31.1
>

Ah, since you are relaxing the requirement some of those lockdep
asserts from the previous patch aren't actually redundant.  This seems
fine to me: lookup definitely doesn't need the write lock and allowing
concurrent gets should be OK.  The write lock made some sense back when
get was an atomic_read followed by atomic_inc but not now.

Reviewed-by: Ilya Dryomov <idryomov@gmail.com>

Thanks,

                Ilya

  reply	other threads:[~2021-06-21 20:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 16:52 [PATCH 0/3] ceph: locking fixes for snaprealm handling Jeff Layton
2021-06-03 16:52 ` [PATCH 1/3] ceph: add some lockdep assertions around " Jeff Layton
2021-06-21 20:05   ` Ilya Dryomov
2021-06-21 20:51     ` Jeff Layton
2021-06-21 21:27       ` Ilya Dryomov
2021-06-03 16:52 ` [PATCH 2/3] ceph: clean up locking annotation for ceph_get_snap_realm and __lookup_snap_realm Jeff Layton
2021-06-21 20:48   ` Ilya Dryomov [this message]
2021-06-03 16:52 ` [PATCH 3/3] ceph: must hold snap_rwsem when filling inode for async create Jeff Layton
2021-06-21 19:45   ` Ilya Dryomov

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='CAOi1vP83Za9rW3wK-XvOW8k=UXObczyQeQgTmrQRRXJ0yOmXsw@mail.gmail.com' \
    --to=idryomov@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=jlayton@kernel.org \
    /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.