From: Dave Hansen <haveblue@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: hch@infradead.org, miklos@szeredi.hu, Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 2/8] move mnt_want_write() into open_namei_create()
Date: Fri, 28 Sep 2007 11:13:31 -0700 [thread overview]
Message-ID: <20070928181331.E9388A9C@kernel> (raw)
In-Reply-To: <20070928181330.27B367AC@kernel>
In a moment, we're going to make may_open() stop doing
the mnt_want/drop_write() pair. Doing this first makes
the next patch simpler.
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---
lxc-dave/fs/namei.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff -puN fs/namei.c~move-mnt_want_write-into-open_namei_create fs/namei.c
--- lxc/fs/namei.c~move-mnt_want_write-into-open_namei_create 2007-09-28 11:03:19.000000000 -0700
+++ lxc-dave/fs/namei.c 2007-09-28 11:03:19.000000000 -0700
@@ -1686,6 +1686,19 @@ static int open_namei_create(struct name
int error;
struct dentry *dir = nd->dentry;
+ /*
+ * This ensures that the mnt stays writable
+ * over the vfs_create() call to may_open(),
+ * which takes a more persistent
+ * mnt_want_write().
+ */
+ error = mnt_want_write(nd->mnt);
+ if (error) {
+ mutex_unlock(&dir->d_inode->i_mutex);
+ dput(nd->dentry);
+ return error;
+ }
+
if (!IS_POSIXACL(dir->d_inode))
mode &= ~current->fs->umask;
error = vfs_create(dir->d_inode, path->dentry, mode, nd);
@@ -1693,9 +1706,16 @@ static int open_namei_create(struct name
dput(nd->dentry);
nd->dentry = path->dentry;
if (error)
- return error;
+ goto out;
/* Don't check for write permission, don't truncate */
- return may_open(nd, 0, flag & ~O_TRUNC);
+ error = may_open(nd, 0, flag & ~O_TRUNC);
+out:
+ /*
+ * if needed, may_open() has taken a write
+ * on the mnt for us, so we can release ours.
+ */
+ mnt_drop_write(nd->mnt);
+ return error;
}
/*
@@ -1778,11 +1798,7 @@ do_last:
/* Negative dentry, just create the file */
if (!path.dentry->d_inode) {
- error = mnt_want_write(nd->mnt);
- if (error)
- goto exit_mutex_unlock;
error = open_namei_create(nd, &path, flag, mode);
- mnt_drop_write(nd->mnt);
if (error)
goto exit;
return 0;
_
next prev parent reply other threads:[~2007-09-28 18:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-28 18:13 [RFC][PATCH 1/8] get mount write in __dentry_open() Dave Hansen
2007-09-28 18:13 ` Dave Hansen [this message]
2007-09-28 18:13 ` [RFC][PATCH 3/8] move mnt_want_write() out of may_open() Dave Hansen
2007-10-01 19:55 ` Miklos Szeredi
2007-10-01 20:10 ` Dave Hansen
2007-09-28 18:13 ` [RFC][PATCH 4/8] do namei_flags calculation inside open_namei() Dave Hansen
2007-09-28 18:13 ` [RFC][PATCH 5/8] make open_namei() return a filp Dave Hansen
2007-09-28 18:13 ` [RFC][PATCH 6/8] kill do_filp_open() Dave Hansen
2007-09-28 18:13 ` [RFC][PATCH 7/8] kill filp_open() Dave Hansen
2007-09-28 18:13 ` [RFC][PATCH 8/8] keep track of mnt_writer state of struct file Dave Hansen
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=20070928181331.E9388A9C@kernel \
--to=haveblue@us.ibm.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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