public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Zach Brown <zach.brown@oracle.com>
To: Chris Mason <chris.mason@oracle.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
	Peter Zijlstra <peterz@infradead.org>,
	Jens Axboe <jens.axboe@oracle.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	linux-aio@kvack.org
Subject: Re: dio_get_page() lockdep complaints
Date: Fri, 09 Nov 2007 10:35:04 -0800	[thread overview]
Message-ID: <4734A858.2010307@oracle.com> (raw)
In-Reply-To: <20071109130156.4b05a652@think.oraclecorp.com>


> Without getting into a huge patch, the best fix would just be switching
> to try lock.  If the tail doesn't get packed, the world doesn't end.

So, something like this?

---

reiserfs: trylock i_mutex in file release when packing

The mmap_sem is nested under the i_mutex.  reiserfs_file_release() wants
to acquire the i_mutex to pack the file but it can be called with the mmap_sem
held by munmap.  This has produced lockdep warnings in testing.

  http://lkml.org/lkml/2007/4/19/73

This acquires the i_mutex in reiserfs_file_release() with a trylock.  If the
i_mutex is already held it simply won't pack.  There are already a host of
conditions under which it won't pack.

Totally untested, but built.

 Signed-off-by: Zach Brown <zach.brown@oracle.com>

diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index a804903..40085f1 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -46,7 +46,13 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 		return 0;
 	}
 
-	mutex_lock(&inode->i_mutex);
+	/*
+	 * We can be called from munmap while holding mmap_sem, but mmap_sem
+	 * is nested inside i_mutex.  If we can't get i_mutex then we just
+	 * don't pack.
+	 */
+	if (mutex_trylock(&inode->i_mutex) == 0)
+		return 0;
 
 	mutex_lock(&(REISERFS_I(inode)->i_mmap));
 	if (REISERFS_I(inode)->i_flags & i_ever_mapped)


  reply	other threads:[~2007-11-09 18:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-19  7:38 dio_get_page() lockdep complaints Jens Axboe
2007-04-19  8:01 ` Andrew Morton
2007-04-19  8:01   ` Jens Axboe
2007-04-19  8:25     ` Andrew Morton
2007-04-19  8:34       ` Jens Axboe
2007-04-19 12:43         ` Vladimir V. Saveliev
2007-04-19 12:49           ` Jens Axboe
2007-04-19 12:52             ` Jens Axboe
2007-04-19 13:53               ` Roland Dreier
2007-04-19 14:20                 ` Jens Axboe
2007-04-19 14:15         ` Jens Axboe
2007-04-19 14:55           ` Vladimir V. Saveliev
2007-04-19 14:57       ` Vladimir V. Saveliev
2007-04-19 16:42         ` Andrew Morton
2007-04-19 14:36   ` Chris Mason
2007-11-09 17:02 ` Peter Zijlstra
2007-11-09 17:30   ` Zach Brown
2007-11-09 17:45     ` Trond Myklebust
2007-11-09 17:48       ` Zach Brown
2007-11-09 18:01         ` Chris Mason
2007-11-09 18:35           ` Zach Brown [this message]
2007-11-09 18:53             ` Chris Mason
2007-11-09 18:57               ` Chris Mason
2007-11-09 19:16                 ` Zach Brown
2007-11-09 19:35                   ` Chris Mason
2007-11-11 19:49       ` Peter Zijlstra
2007-11-12  8:45         ` Martin Schwidefsky
2007-11-12  9:27           ` Peter Zijlstra

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=4734A858.2010307@oracle.com \
    --to=zach.brown@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris.mason@oracle.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=trond.myklebust@fys.uio.no \
    /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