public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 1/8] get mount write in __dentry_open()
@ 2007-09-28 18:13 Dave Hansen
  2007-09-28 18:13 ` [RFC][PATCH 2/8] move mnt_want_write() into open_namei_create() Dave Hansen
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Dave Hansen @ 2007-09-28 18:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: hch, miklos, Dave Hansen


The first three patches here fix actual bugs.  I think
the last two will reduce the chance for any future bugs
to creep in.  RFC for now.

--

This is a bug fix for the r/o bind mount patch set.

We need to ensure taking a mnt write on the mnt
referenced by any new struct file.  

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 lxc-dave/fs/open.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff -puN fs/open.c~get-write-in-__dentry_open fs/open.c
--- lxc/fs/open.c~get-write-in-__dentry_open	2007-09-28 11:03:18.000000000 -0700
+++ lxc-dave/fs/open.c	2007-09-28 11:03:18.000000000 -0700
@@ -778,9 +778,15 @@ static struct file *__dentry_open(struct
 				FMODE_PREAD | FMODE_PWRITE;
 	inode = dentry->d_inode;
 	if (f->f_mode & FMODE_WRITE) {
-		error = get_write_access(inode);
+		error = mnt_want_write(mnt);
 		if (error)
 			goto cleanup_file;
+
+		error = get_write_access(inode);
+		if (error) {
+			mnt_drop_write(mnt);
+			goto cleanup_file;
+		}
 	}
 
 	f->f_mapping = inode->i_mapping;
@@ -820,8 +826,10 @@ static struct file *__dentry_open(struct
 
 cleanup_all:
 	fops_put(f->f_op);
-	if (f->f_mode & FMODE_WRITE)
+	if (f->f_mode & FMODE_WRITE) {
 		put_write_access(inode);
+		mnt_drop_write(mnt);
+	}
 	file_kill(f);
 	f->f_path.dentry = NULL;
 	f->f_path.mnt = NULL;
_

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-10-01 20:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-28 18:13 [RFC][PATCH 1/8] get mount write in __dentry_open() Dave Hansen
2007-09-28 18:13 ` [RFC][PATCH 2/8] move mnt_want_write() into open_namei_create() Dave Hansen
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox