mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: Joshua Hudson <joshudson@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to explain to lock validator: locking inodes in inode order
Date: Tue, 18 Jul 2006 11:09:56 +0200	[thread overview]
Message-ID: <1153213796.3038.11.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <bda6d13a0607172119v3c908ac8u8a39acd315dc6336@mail.gmail.com>

Hi,

> Yes. It never takes a lock on any higher inode without holding the lock on a
> lower inode first. I have a full proof across the VFS+FS [see below].

ok just checking. The reason this is important is that once you tell
lockdep this is a special situation, it better be that, since you're
losing any checking for the "but what if not" case. 
> 
> >
> > all places in the kernel that take this mutex in that order only do it
> > in i_ino order, including all directory operations like cross directory
> > rename?
> 
> I had to disable the kernel's locking of multiple objects in namei.c using a
> new FS_ flag because it would actually deadlock for this filesystem.

ok fun ;) It might be interesting to talk to Al Viro about this at some
point, maybe there is something interesting in your locking that could
improve the linux VFS locking scheme

To annotate for lockdep,  you probably can use the same constants as we
used for inodes (after all you're sort of doing the same anyway); so
your code can be made to look roughly like this: 

if ( < ) {
   mutex_lock_nested( ..... , I_MUTEX_PARENT);
   mutex_lock_nested( ..... , I_MUTEX_CHILD);
} else {
   mutex_lock_nested( ..... , I_MUTEX_PARENT);
   mutex_lock_nested( ..... , I_MUTEX_CHILD);
}

this means that you tell that the first mutex taken is the parent in a
parent-child relationship which is hierarchical for "external" reasons
(in this case your sorting).

Greetings,
    Arjan van de Ven


      reply	other threads:[~2006-07-18  9:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-18  2:24 Joshua Hudson
2006-07-18  3:31 ` Arjan van de Ven
2006-07-18  4:19   ` Joshua Hudson
2006-07-18  9:09     ` Arjan van de Ven [this message]

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=1153213796.3038.11.camel@laptopd505.fenrus.org \
    --to=arjan@infradead.org \
    --cc=joshudson@gmail.com \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®