linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@poochiereds.net>
To: NeilBrown <neilb@suse.com>
Cc: Jeff Layton <jlayton@kernel.org>,
	"<linux-fsdevel@vger.kernel.org>" <linux-fsdevel@vger.kernel.org>,
	Bruce Fields <bfields@fieldses.org>,
	asn@redhat.com
Subject: Re: [PATCH v2] locks: ignore same lock in blocked_lock_hash
Date: Mon, 25 Mar 2019 08:31:23 -0400	[thread overview]
Message-ID: <CAOhYWNK0ou60nKRs2T9ZWObjGmJsvzkLAXLkw9b0Zj-uD1KY=w@mail.gmail.com> (raw)
In-Reply-To: <878sx55c3b.fsf@notabene.neil.brown.name>

On Sat, Mar 23, 2019 at 8:51 PM NeilBrown <neilb@suse.com> wrote:
>
>
> The patch title
>    locks: ignore same lock in blocked_lock_hash
>
> is a bit misleading the lock isn't in the hash, but it is linked from
> something that is.  Maybe
>
>    locks: ignore same lock in posix_locks_deadlock()
>
> ??
>
> On Sat, Mar 23 2019, Jeff Layton wrote:
>
> > Andreas reported that he was seeing the tdbtorture test fail in
> > some cases with -EDEADLCK when it wasn't before. Some debugging
> > showed that deadlock detection was sometimes discovering the
> > caller's lock request itself in a dependency chain.
> >
> > If posix_locks_deadlock() fails to find a deadlock, the caller_fl
> > will be passed to __locks_insert_block(), and this wakes up all
> > locks that are blocked on caller_fl, clearing the fl_blocker link.
> >
> > So if posix_locks_deadlock() finds caller_fl while searching for
> > a deadlock, it can be sure that link in the cycle is about to be
> > broken and it need not treat it as the cause of a deadlock.
> >
> > URL: https://bugzilla.kernel.org/show_bug.cgi?id=202975
> > Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other requests.")
> > Cc: stable@vger.kernel.org
> > Reported-by: Andreas Schneider <asn@redhat.com>
> > Signed-off-by: Neil Brown <neilb@suse.com>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  fs/locks.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/fs/locks.c b/fs/locks.c
> > index eaa1cfaf73b0..a939a274dc71 100644
> > --- a/fs/locks.c
> > +++ b/fs/locks.c
> > @@ -1023,6 +1023,19 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
> >       while ((block_fl = what_owner_is_waiting_for(block_fl))) {
> >               if (i++ > MAX_DEADLK_ITERATIONS)
> >                       return 0;
> > +
> > +             /*
> > +              * It's possible that we're retrying this lock request after
> > +              * another task is has blocked on it. A lock request can't
> > +              * block itself, and any locks that are blocked on it will
> > +              * also be awoken soon (and have their fl_blocker pointer
> > +              * cleared). Any dependency chain that contains the request
> > +              * itself is therefore about to be broken, so we can safely
> > +              * ignore it.
>
> That first sentence isn't working for me .... maybe remove the "is" ??
>
> Thanks,
> NeilBrown
>
>
> > +              */
> > +             if (block_fl == caller_fl)
> > +                     return 0;
> > +
> >               if (posix_same_owner(caller_fl, block_fl))
> >                       return 1;
> >       }
> > --
> > 2.20.1

Makes sense. That said, I think I'm starting to like your earlier idea
of just waking up any locks blocked on this request prior to the
deadlock check. I've tested that and it also fixes this, and may be a
bit more efficient. I'll follow up with a v3 patch that does that.

Thanks,
-- 
Jeff Layton <jlayton@poochiereds.net>

  reply	other threads:[~2019-03-25 12:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 11:27 [PATCH] locks: ignore same lock in blocked_lock_hash Jeff Layton
2019-03-21 21:51 ` NeilBrown
2019-03-22  0:42 ` J. Bruce Fields
2019-03-22  1:58   ` NeilBrown
2019-03-22 20:27     ` J. Bruce Fields
2019-03-23 12:08       ` [PATCH v2] " Jeff Layton
2019-03-24  0:51         ` NeilBrown
2019-03-25 12:31           ` Jeff Layton [this message]
2019-03-25 12:32             ` [PATCH v3] locks: wake any locks blocked on request before deadlock check Jeff Layton
2019-03-25 22:09               ` J. Bruce Fields
2019-03-25 22:33               ` NeilBrown
2019-03-23 12:05     ` [PATCH] locks: ignore same lock in blocked_lock_hash Jeff Layton

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='CAOhYWNK0ou60nKRs2T9ZWObjGmJsvzkLAXLkw9b0Zj-uD1KY=w@mail.gmail.com' \
    --to=jlayton@poochiereds.net \
    --cc=asn@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=neilb@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).