From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Davide Libenzi <davidel-AhlLAIvw+VEjIGhXcJzhZg@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 12/20] KVM: Remove kvmfs in favor of the anonymous inodes source
Date: Sun, 8 Jul 2007 14:54:41 +0300 [thread overview]
Message-ID: <11838956893490-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <11838956891287-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
kvm uses a pseudo filesystem, kvmfs, to generate inodes, a job that the
new anonymous inodes source does much better.
Cc: Davide Libenzi <davidel-AhlLAIvw+VEjIGhXcJzhZg@public.gmane.org>
Signed-off-by: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
drivers/kvm/kvm_main.c | 143 ++++--------------------------------------------
fs/anon_inodes.c | 1 +
include/linux/magic.h | 1 -
3 files changed, 12 insertions(+), 133 deletions(-)
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 5603000..26ca90f 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -43,6 +43,7 @@
#include <linux/sched.h>
#include <linux/cpumask.h>
#include <linux/smp.h>
+#include <linux/anon_inodes.h>
#include "x86_emulate.h"
#include "segment_descriptor.h"
@@ -81,8 +82,6 @@ static struct kvm_stats_debugfs_item {
static struct dentry *debugfs_dir;
-struct vfsmount *kvmfs_mnt;
-
#define MAX_IO_MSRS 256
#define CR0_RESEVED_BITS 0xffffffff1ffaffc0ULL
@@ -104,55 +103,6 @@ struct segment_descriptor_64 {
static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
unsigned long arg);
-static struct inode *kvmfs_inode(struct file_operations *fops)
-{
- int error = -ENOMEM;
- struct inode *inode = new_inode(kvmfs_mnt->mnt_sb);
-
- if (!inode)
- goto eexit_1;
-
- inode->i_fop = fops;
-
- /*
- * Mark the inode dirty from the very beginning,
- * that way it will never be moved to the dirty
- * list because mark_inode_dirty() will think
- * that it already _is_ on the dirty list.
- */
- inode->i_state = I_DIRTY;
- inode->i_mode = S_IRUSR | S_IWUSR;
- inode->i_uid = current->fsuid;
- inode->i_gid = current->fsgid;
- inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
- return inode;
-
-eexit_1:
- return ERR_PTR(error);
-}
-
-static struct file *kvmfs_file(struct inode *inode, void *private_data)
-{
- struct file *file = get_empty_filp();
-
- if (!file)
- return ERR_PTR(-ENFILE);
-
- file->f_path.mnt = mntget(kvmfs_mnt);
- file->f_path.dentry = d_alloc_anon(inode);
- if (!file->f_path.dentry)
- return ERR_PTR(-ENOMEM);
- file->f_mapping = inode->i_mapping;
-
- file->f_pos = 0;
- file->f_flags = O_RDWR;
- file->f_op = inode->i_fop;
- file->f_mode = FMODE_READ | FMODE_WRITE;
- file->f_version = 0;
- file->private_data = private_data;
- return file;
-}
-
unsigned long segment_base(u16 selector)
{
struct descriptor_table gdt;
@@ -2413,34 +2363,12 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu)
struct inode *inode;
struct file *file;
+ r = anon_inode_getfd(&fd, &inode, &file,
+ "kvm-vcpu", &kvm_vcpu_fops, vcpu);
+ if (r)
+ return r;
atomic_inc(&vcpu->kvm->filp->f_count);
- inode = kvmfs_inode(&kvm_vcpu_fops);
- if (IS_ERR(inode)) {
- r = PTR_ERR(inode);
- goto out1;
- }
-
- file = kvmfs_file(inode, vcpu);
- if (IS_ERR(file)) {
- r = PTR_ERR(file);
- goto out2;
- }
-
- r = get_unused_fd();
- if (r < 0)
- goto out3;
- fd = r;
- fd_install(fd, file);
-
return fd;
-
-out3:
- fput(file);
-out2:
- iput(inode);
-out1:
- fput(vcpu->kvm->filp);
- return r;
}
/*
@@ -2905,41 +2833,18 @@ static int kvm_dev_ioctl_create_vm(void)
struct file *file;
struct kvm *kvm;
- inode = kvmfs_inode(&kvm_vm_fops);
- if (IS_ERR(inode)) {
- r = PTR_ERR(inode);
- goto out1;
- }
-
kvm = kvm_create_vm();
- if (IS_ERR(kvm)) {
- r = PTR_ERR(kvm);
- goto out2;
+ if (IS_ERR(kvm))
+ return PTR_ERR(kvm);
+ r = anon_inode_getfd(&fd, &inode, &file, "kvm-vm", &kvm_vm_fops, kvm);
+ if (r) {
+ kvm_destroy_vm(kvm);
+ return r;
}
- file = kvmfs_file(inode, kvm);
- if (IS_ERR(file)) {
- r = PTR_ERR(file);
- goto out3;
- }
kvm->filp = file;
- r = get_unused_fd();
- if (r < 0)
- goto out4;
- fd = r;
- fd_install(fd, file);
-
return fd;
-
-out4:
- fput(file);
-out3:
- kvm_destroy_vm(kvm);
-out2:
- iput(inode);
-out1:
- return r;
}
static long kvm_dev_ioctl(struct file *filp,
@@ -3211,18 +3116,6 @@ static struct sys_device kvm_sysdev = {
hpa_t bad_page_address;
-static int kvmfs_get_sb(struct file_system_type *fs_type, int flags,
- const char *dev_name, void *data, struct vfsmount *mnt)
-{
- return get_sb_pseudo(fs_type, "kvm:", NULL, KVMFS_SUPER_MAGIC, mnt);
-}
-
-static struct file_system_type kvm_fs_type = {
- .name = "kvmfs",
- .get_sb = kvmfs_get_sb,
- .kill_sb = kill_anon_super,
-};
-
int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
{
int r;
@@ -3307,14 +3200,6 @@ static __init int kvm_init(void)
if (r)
goto out4;
- r = register_filesystem(&kvm_fs_type);
- if (r)
- goto out3;
-
- kvmfs_mnt = kern_mount(&kvm_fs_type);
- r = PTR_ERR(kvmfs_mnt);
- if (IS_ERR(kvmfs_mnt))
- goto out2;
kvm_init_debug();
kvm_init_msr_list();
@@ -3331,10 +3216,6 @@ static __init int kvm_init(void)
out:
kvm_exit_debug();
- mntput(kvmfs_mnt);
-out2:
- unregister_filesystem(&kvm_fs_type);
-out3:
kvm_mmu_module_exit();
out4:
return r;
@@ -3344,8 +3225,6 @@ static __exit void kvm_exit(void)
{
kvm_exit_debug();
__free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT));
- mntput(kvmfs_mnt);
- unregister_filesystem(&kvm_fs_type);
kvm_mmu_module_exit();
}
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 40fe3a3..edc6748 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -139,6 +139,7 @@ err_put_filp:
put_filp(file);
return error;
}
+EXPORT_SYMBOL_GPL(anon_inode_getfd);
/*
* A single inode exist for all anon_inode files. Contrary to pipes,
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 9d713c0..36cc20d 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -13,7 +13,6 @@
#define HPFS_SUPER_MAGIC 0xf995e849
#define ISOFS_SUPER_MAGIC 0x9660
#define JFFS2_SUPER_MAGIC 0x72b6
-#define KVMFS_SUPER_MAGIC 0x19700426
#define ANON_INODE_FS_MAGIC 0x09041934
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
--
1.5.2.2
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
next prev parent reply other threads:[~2007-07-08 11:54 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-08 11:54 [PATCH 00/20] KVM updates for 2.6.23, part 2 Avi Kivity
[not found] ` <11838956891287-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-08 11:54 ` [PATCH 01/20] KVM: Implement emulation of "pop reg" instruction (opcode 0x58-0x5f) Avi Kivity
2007-07-08 11:54 ` [PATCH 02/20] KVM: Implement emulation of instruction "ret" (opcode 0xc3) Avi Kivity
2007-07-08 11:54 ` [PATCH 03/20] KVM: Adds support for in-kernel mmio handlers Avi Kivity
2007-07-08 11:54 ` [PATCH 04/20] KVM: VMX: Fix interrupt checking on lightweight exit Avi Kivity
2007-07-08 11:54 ` [PATCH 05/20] KVM: Add support for in-kernel pio handlers Avi Kivity
2007-07-08 11:54 ` [PATCH 06/20] KVM: Fix x86 emulator writeback Avi Kivity
2007-07-08 11:54 ` [PATCH 07/20] KVM: Avoid useless memory write when possible Avi Kivity
2007-07-08 11:54 ` [PATCH 08/20] KVM: VMX: Reinitialize the real-mode tss when entering real mode Avi Kivity
2007-07-08 11:54 ` [PATCH 09/20] KVM: MMU: Fix Wrong tlb flush order Avi Kivity
[not found] ` <1183895689306-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-08 12:21 ` Ingo Molnar
[not found] ` <20070708122137.GB30226-X9Un+BFzKDI@public.gmane.org>
2007-07-08 12:42 ` Avi Kivity
2007-07-08 11:54 ` [PATCH 10/20] KVM: VMX: Remove unnecessary code in vmx_tlb_flush() Avi Kivity
2007-07-08 11:54 ` [PATCH 11/20] KVM: SVM: Reliably detect if SVM was disabled by BIOS Avi Kivity
[not found] ` <11838956892580-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-08 13:43 ` Roland Dreier
[not found] ` <aday7hr105d.fsf-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2007-07-08 13:45 ` Avi Kivity
2007-07-08 11:54 ` Avi Kivity [this message]
2007-07-08 11:54 ` [PATCH 13/20] KVM: Clean up #includes Avi Kivity
2007-07-08 11:54 ` [PATCH 14/20] HOTPLUG: Add CPU_DYING notifier Avi Kivity
2007-07-08 11:54 ` [PATCH 15/20] HOTPLUG: Adapt cpuset hotplug callback to CPU_DYING Avi Kivity
2007-07-08 11:54 ` [PATCH 16/20] HOTPLUG: Adapt thermal throttle " Avi Kivity
2007-07-08 11:54 ` [PATCH 17/20] SMP: Implement on_cpu() Avi Kivity
[not found] ` <p73lkdqzpdm.fsf@bingen.suse.de>
[not found] ` <p73lkdqzpdm.fsf-KvMlXPVkKihbpigZmTR7Iw@public.gmane.org>
2007-07-09 6:46 ` Avi Kivity
[not found] ` <4691D9C1.4050309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-09 7:16 ` Andi Kleen
2007-07-09 9:40 ` Avi Kivity
[not found] ` <46920270.3080309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-09 11:28 ` Avi Kivity
[not found] ` <46921BE9.4040801-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-09 19:24 ` Satyam Sharma
[not found] ` <a781481a0707091224s3fb1a2acr6d3ccce091480f61-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-07-10 6:03 ` Avi Kivity
[not found] ` <4693211D.4040406-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-10 9:22 ` Satyam Sharma
2007-07-10 11:03 ` Avi Kivity
[not found] ` <46936766.20900-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-11 0:07 ` Satyam Sharma
[not found] ` <a781481a0707101707w121da1b7hc82dc0e3638e4570-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-07-11 7:26 ` Avi Kivity
[not found] ` <46948626.6050308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-11 7:47 ` Satyam Sharma
2007-07-11 9:43 ` gcc + kvm + 64 bit ? confused :-/ Benjamin Budts
[not found] ` <4694A63E.1050606-rJAIWvhRp0CZIoH1IeqzKA@public.gmane.org>
2007-07-11 9:47 ` Avi Kivity
2007-07-11 10:54 ` Andi Kleen
2007-07-08 11:54 ` [PATCH 18/20] KVM: Keep track of which cpus have virtualization enabled Avi Kivity
2007-07-08 11:54 ` [PATCH 19/20] KVM: Tune hotplug/suspend IPIs Avi Kivity
2007-07-08 11:54 ` [PATCH 20/20] KVM: Use CPU_DYING for disabling virtualization Avi Kivity
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=11838956893490-git-send-email-avi@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=davidel-AhlLAIvw+VEjIGhXcJzhZg@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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