From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>,
linux-fsdevel@vger.kernel.org, Al Viro <viro@ZenIV.linux.org.uk>
Subject: [PATCH] fs: take i_mutex in __page_symlink()
Date: Mon, 1 Apr 2013 11:23:42 -0400 [thread overview]
Message-ID: <1364829822-18989-1-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <20130328140635.GA32635@thunk.org>
In Documentation/filesystems/Locking, it's documented that
write_begin() is guaranteed to be called with i_mutex locked. The
function __page_symlink() was not taking i_mutex before calling
pagecache_write_begin(), which will eventually result in the file
system's write_begin()'s function getting called.
Other callers of pagecache_write_begin such as in fs/splice.c, call
pagecache_write_begin() with i_mutex locked, so fix __page_symlink()
to be consistent.
This was discovered by the addition of a new ext4 debugging assertion
which checked to make sure i_mutex was locked before calling
ext4_truncate().
Reported-by: Zheng Liu <gnehzuil.liu@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-fsdevel@vger.kernel.org
Cc: Al Viro <viro@ZenIV.linux.org.uk>
---
Note: I plan to carry the following patch in the ext4 tree, unless
someone objects or Al insists on carrying this in the vfs git tree.
fs/namei.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/namei.c b/fs/namei.c
index 57ae9c8..548e57b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4035,8 +4035,10 @@ int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
flags |= AOP_FLAG_NOFS;
retry:
+ mutex_lock(&inode->i_mutex);
err = pagecache_write_begin(NULL, mapping, 0, len-1,
flags, &page, &fsdata);
+ mutex_unlock(&inode->i_mutex);
if (err)
goto fail;
--
1.7.12.rc0.22.gcdd159b
next prev parent reply other threads:[~2013-04-01 15:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1364390347-4360-1-git-send-email-wenqing.lz@taobao.com>
[not found] ` <20130327134110.GI5861@thunk.org>
[not found] ` <20130327140250.GA4316@gmail.com>
[not found] ` <20130327135155.GK5861@thunk.org>
[not found] ` <20130327150735.GA4395@gmail.com>
[not found] ` <20130327151922.GA4487@gmail.com>
[not found] ` <20130327151248.GE14900@thunk.org>
[not found] ` <20130327153506.GA4565@gmail.com>
2013-03-28 14:06 ` [PATCH] ext4: take i_mutex in ext4_symlink to eliminate a warning from ext4_truncate Theodore Ts'o
2013-04-01 15:23 ` Theodore Ts'o [this message]
2013-04-01 16:35 ` [PATCH] fs: take i_mutex in __page_symlink() Al Viro
2013-04-01 17:38 ` Theodore Ts'o
2013-04-02 8:19 ` Dmitry Monakhov
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=1364829822-18989-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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).