login
Header Space

 
 

[PATCH] update kvm's anon_inodes.c for r/o bind mounts

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Avi Kivity <avi@...>
Cc: linux-kernel@vger.kernel.org <linux-kernel@...>, kvm-devel <kvm@...>, Anthony N. Liguori [imap] <aliguori@...>
Date: Thursday, July 17, 2008 - 2:45 am

That also reminds me.  kvm somehow has an outdated copy of
anon_inodes.c.  It needs to be updated for the r/o bind mount patches to
add a proper mnt_want/drop_write().  Otherwise, you'll run into warnings
about imbalanced mount writer counts.  Something like this will do, but
it would be best to just stay up to date with mainline for this kind of
stuff.

diff --git a/kernel/anon_inodes.c b/kernel/anon_inodes.c
index 74630ea..a47bc55 100644
--- a/kernel/anon_inodes.c
+++ b/kernel/anon_inodes.c
@@ -90,9 +90,6 @@ int anon_inode_getfd(const char *name, const struct file_operations *fops,
 
 	if (IS_ERR(anon_inode_inode))
 		return -ENODEV;
-	file = get_empty_filp();
-	if (!file)
-		return -ENFILE;
 
 	inode = igrab(anon_inode_inode);
 	if (IS_ERR(inode)) {
@@ -121,14 +118,15 @@ int anon_inode_getfd(const char *name, const struct file_operations *fops,
 	dentry->d_flags &= ~DCACHE_UNHASHED;
 	d_instantiate(dentry, inode);
 
-	file->f_vfsmnt = mntget(anon_inode_mnt);
-	file->f_dentry = dentry;
-	file->f_mapping = inode->i_mapping;
+	file = alloc_file(anon_inode_mnt, dentry, FMODE_READ | FMODE_WRITE,
+			(struct file_operations *)fops);
+	if (!file) {
+		error = -ENFILE;
+		goto err_dput;
+	}
 
 	file->f_pos = 0;
 	file->f_flags = O_RDWR;
-	file->f_op = (struct file_operations *)fops;
-	file->f_mode = FMODE_READ | FMODE_WRITE;
 	file->f_version = 0;
 	file->private_data = priv;
 
@@ -136,12 +134,13 @@ int anon_inode_getfd(const char *name, const struct file_operations *fops,
 
 	return fd;
 
+err_dput:
+	dput(dentry);
 err_put_unused_fd:
 	put_unused_fd(fd);
 err_iput:
 	iput(inode);
 err_put_filp:
-	fput(file);
 	return error;
 }
 


-- Dave

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kvm causing memory corruption? ~2.6.25-rc6, Dave Hansen, (Tue Mar 25, 5:12 pm)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Mon Jun 2, 6:30 pm)
Re: kvm causing memory corruption? now 2.6.26-rc4, Avi Kivity, (Wed Jun 4, 9:42 am)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Fri Jun 6, 3:41 am)
Re: kvm causing memory corruption? now 2.6.26-rc4, Avi Kivity, (Thu Jun 12, 9:10 am)
Re: kvm causing memory corruption? now 2.6.26-rc8, Dave Hansen, (Tue Jul 15, 2:57 pm)
Re: kvm causing memory corruption? now 2.6.26, Dave Hansen, (Wed Jul 16, 5:44 pm)
Re: kvm causing memory corruption? now 2.6.26, Avi Kivity, (Thu Jul 17, 1:38 am)
KVM overflows the stack, Dave Hansen, (Wed Jul 16, 6:48 pm)
Re: KVM overflows the stack, Dave Hansen, (Thu Jul 17, 2:27 am)
Re: KVM overflows the stack, Avi Kivity, (Thu Jul 17, 1:52 am)
[PATCH] update kvm's anon_inodes.c for r/o bind mounts, Dave Hansen, (Thu Jul 17, 2:45 am)
Re: KVM overflows the stack, Dave Hansen, (Thu Jul 17, 2:14 am)
Re: KVM overflows the stack, Avi Kivity, (Thu Jul 17, 2:42 am)
Re: KVM overflows the stack, Roland Dreier, (Thu Jul 17, 2:08 am)
Re: KVM overflows the stack, Dave Hansen, (Thu Jul 17, 10:06 am)
Re: KVM overflows the stack, Avi Kivity, (Thu Jul 17, 10:15 am)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Mon Jun 16, 2:07 pm)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Mon Jun 2, 8:59 pm)
speck-geostationary