From: Jens Axboe <jens.axboe@oracle.com>
To: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Andrew Morton <akpm@osdl.org>,
linux-fsdevel@vger.kernel.org,
Michael Halcrow <mhalcrow@us.ibm.com>
Subject: Re: i_mutex locking in generic_file_splice_write()
Date: Sun, 15 Oct 2006 22:08:28 +0200 [thread overview]
Message-ID: <20061015200828.GO14399@kernel.dk> (raw)
In-Reply-To: <20061015195657.GA13426@ca-server1.us.oracle.com>
On Sun, Oct 15 2006, Mark Fasheh wrote:
> On Sun, Oct 15, 2006 at 08:05:20PM +0200, Jens Axboe wrote:
> > This wont fly, it's completely tailored to splice in that one one inode
> > can be NULL. It also requires the 2nd inode to be that potentially NULL
> > pointer.
> *shrug* from my memory, 1st pointer always valid, 2nd possibly NULL seemed
> to be a common paradigm, though I can't really point to any code, now that I
> think of it.
>
>
> > The function should work for any of the inodes to be NULL, if exported
> > as a helper.
> Here's a version that also handles both inodes being the same. We're quickly
> approaching an elevated level of scariness in inode_double_lock :) Also,
> things have been un-inlined.
Hmm, it doesn't seem any different :-). Bad diff attached?
> +void inode_double_lock(struct inode *inode1, struct inode *inode2)
> +{
> + if (!inode2) {
> + mutex_lock(&inode1->i_mutex);
> + return;
> + }
> +
> + if (inode1 < inode2) {
> + mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT);
> + mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD);
> + } else {
> + mutex_lock_nested(&inode2->i_mutex, I_MUTEX_PARENT);
> + mutex_lock_nested(&inode1->i_mutex, I_MUTEX_CHILD);
> + }
> +}
--
Jens Axboe
next prev parent reply other threads:[~2006-10-15 20:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-12 19:01 i_mutex locking in generic_file_splice_write() Mark Fasheh
2006-10-12 19:54 ` Andrew Morton
2006-10-13 0:17 ` Mark Fasheh
2006-10-13 7:45 ` Jens Axboe
2006-10-13 8:11 ` Andrew Morton
2006-10-13 8:18 ` Jens Axboe
2006-10-13 19:44 ` Mark Fasheh
2006-10-15 18:05 ` Jens Axboe
2006-10-15 19:56 ` Mark Fasheh
2006-10-15 20:08 ` Jens Axboe [this message]
2006-10-15 20:14 ` Mark Fasheh
2006-10-16 17:58 ` Andreas Dilger
2006-10-16 22:24 ` Mark Fasheh
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=20061015200828.GO14399@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=akpm@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mark.fasheh@oracle.com \
--cc=mhalcrow@us.ibm.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).