From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 6/7] ext4: add mutex_is_locked() assertion to ext4_truncate()
Date: Sun, 24 Mar 2013 20:06:53 -0400 [thread overview]
Message-ID: <1364170014-10295-7-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1364170014-10295-1-git-send-email-tytso@mit.edu>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/ext4/inode.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ab20015..eb9a5a9 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -258,8 +258,21 @@ void ext4_evict_inode(struct inode *inode)
"couldn't mark inode dirty (err %d)", err);
goto stop_handle;
}
- if (inode->i_blocks)
+ if (inode->i_blocks) {
+ /*
+ * Since we are evicting the inode, it shouldn't be
+ * locked. We've added a warning which triggers if
+ * the mutex is not locked, so take the lock even
+ * though it's not strictly necessary. However,
+ * taking the lock using a simple mutex_lock() will
+ * trigger a (false positive) lockdep warning, so take
+ * it using a trylock.
+ */
+ int locked = mutex_trylock(&inode->i_mutex);
ext4_truncate(inode);
+ if (likely(locked))
+ mutex_unlock(&inode->i_mutex);
+ }
/*
* ext4_ext_truncate() doesn't reserve any slop when it
@@ -3789,6 +3802,7 @@ void ext4_truncate(struct inode *inode)
struct address_space *mapping = inode->i_mapping;
loff_t page_len;
+ WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
trace_ext4_truncate_enter(inode);
if (!ext4_can_truncate(inode))
--
1.7.12.rc0.22.gcdd159b
next prev parent reply other threads:[~2013-03-25 0:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 0:06 [PATCH 0/7] ext4 code simplification and clean ups Theodore Ts'o
2013-03-25 0:06 ` [PATCH 1/7] ext4: collapse handling of data=ordered and data=writeback codepaths Theodore Ts'o
2013-03-27 12:57 ` Lukáš Czerner
2013-03-25 0:06 ` [PATCH 2/7] ext4: fold ext4_generic_write_end() into ext4_write_end() Theodore Ts'o
2013-03-27 12:58 ` Lukáš Czerner
2013-03-27 15:35 ` Jan Kara
2013-03-25 0:06 ` [PATCH 3/7] ext4: fold ext4_alloc_blocks() in ext4_alloc_branch() Theodore Ts'o
2013-03-27 17:01 ` Jan Kara
2013-03-25 0:06 ` [PATCH 4/7] ext4: refactor punch hole code Theodore Ts'o
[not found] ` <alpine.LFD.2.00.1303261334060.2455@(none)>
2013-03-27 2:38 ` Theodore Ts'o
2013-03-27 10:49 ` Lukáš Czerner
2013-03-25 0:06 ` [PATCH 5/7] ext4: refactor truncate code Theodore Ts'o
[not found] ` <alpine.LFD.2.00.1303271128480.2455@(none)>
2013-03-27 12:36 ` Theodore Ts'o
2013-03-27 13:31 ` Lukáš Czerner
2013-03-25 0:06 ` Theodore Ts'o [this message]
2013-03-26 9:31 ` [PATCH 6/7] ext4: add mutex_is_locked() assertion to ext4_truncate() Lukáš Czerner
2013-03-27 2:29 ` Theodore Ts'o
2013-03-25 0:06 ` [PATCH 7/7] ext4: add might_sleep() annotations Theodore Ts'o
2013-03-26 9:48 ` Lukáš Czerner
2013-03-26 9:49 ` Lukáš Czerner
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=1364170014-10295-7-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@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;
as well as URLs for NNTP newsgroup(s).