public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Avi Kivity <avi@qumranet.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kvm-devel <kvm@vger.kernel.org>,
	"Anthony N. Liguori [imap]" <aliguori@us.ibm.com>
Subject: [PATCH] update kvm's anon_inodes.c for r/o bind mounts
Date: Wed, 16 Jul 2008 23:45:56 -0700	[thread overview]
Message-ID: <1216277156.11664.21.camel@nimitz> (raw)
In-Reply-To: <487EDE26.8040201@qumranet.com>

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


  parent reply	other threads:[~2008-07-17  6:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 21:12 kvm causing memory corruption? ~2.6.25-rc6 Dave Hansen
2008-03-26  9:50 ` [kvm-devel] " Avi Kivity
2008-03-26 16:52   ` Dave Hansen
2008-03-26 16:58     ` Avi Kivity
2008-03-26 17:16       ` Dave Hansen
2008-03-27  9:36         ` Avi Kivity
2008-03-27 10:10           ` Avi Kivity
2008-03-27 14:55             ` Dave Hansen
2008-03-27 14:59               ` Avi Kivity
2008-03-27 16:30                 ` Dave Hansen
2008-06-02 22:30                 ` kvm causing memory corruption? now 2.6.26-rc4 Dave Hansen
2008-06-03  0:59                   ` Dave Hansen
2008-06-04 13:42                   ` Avi Kivity
2008-06-06  7:41                     ` Dave Hansen
2008-06-12 13:10                       ` Avi Kivity
2008-06-16 18:07                         ` Dave Hansen
2008-07-15 18:57                         ` kvm causing memory corruption? now 2.6.26-rc8 Dave Hansen
2008-07-16 21:44                           ` kvm causing memory corruption? now 2.6.26 Dave Hansen
2008-07-16 22:48                             ` KVM overflows the stack Dave Hansen
2008-07-17  5:52                               ` Avi Kivity
2008-07-17  6:08                                 ` Roland Dreier
2008-07-17 14:06                                   ` Dave Hansen
2008-07-17 14:15                                     ` Avi Kivity
2008-07-17  6:14                                 ` Dave Hansen
2008-07-17  6:42                                   ` Avi Kivity
2008-07-17  6:45                                 ` Dave Hansen [this message]
2008-07-19  7:33                                   ` [PATCH] update kvm's anon_inodes.c for r/o bind mounts Avi Kivity
2008-07-17  6:27                               ` KVM overflows the stack Dave Hansen
2008-07-17  5:38                             ` kvm causing memory corruption? now 2.6.26 Avi Kivity
2008-03-27 15:50           ` [kvm-devel] kvm causing memory corruption? ~2.6.25-rc6 Dave Hansen
2008-03-27 15:53             ` Avi Kivity
2008-03-27 16:30               ` 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=1216277156.11664.21.camel@nimitz \
    --to=dave@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@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