]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
async: make the final inode deletion an asynchronous event
authorArjan van de Ven <arjan@linux.intel.com>
Tue, 6 Jan 2009 15:20:54 +0000 (07:20 -0800)
committerArjan van de Ven <arjan@linux.intel.com>
Wed, 7 Jan 2009 16:47:24 +0000 (08:47 -0800)
this makes "rm -rf" on a (names cached) kernel tree go from
11.6 to 8.6 seconds on an ext3 filesystem

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
fs/inode.c
fs/super.c
include/linux/fs.h

index 7a6e8c2ff7b16b472b2bc7fd40894cfc3d8d0904..0013ac1af8e75d6178dbcf67a311ea3e4d326ff7 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/bootmem.h>
 #include <linux/inotify.h>
 #include <linux/mount.h>
+#include <linux/async.h>
 
 /*
  * This is needed for the following functions:
@@ -1138,16 +1139,11 @@ EXPORT_SYMBOL(remove_inode_hash);
  * I_FREEING is set so that no-one will take a new reference to the inode while
  * it is being deleted.
  */
-void generic_delete_inode(struct inode *inode)
+static void generic_delete_inode_async(void *data, async_cookie_t cookie)
 {
+       struct inode *inode = data;
        const struct super_operations *op = inode->i_sb->s_op;
 
-       list_del_init(&inode->i_list);
-       list_del_init(&inode->i_sb_list);
-       inode->i_state |= I_FREEING;
-       inodes_stat.nr_inodes--;
-       spin_unlock(&inode_lock);
-
        security_inode_delete(inode);
 
        if (op->delete_inode) {
@@ -1171,6 +1167,16 @@ void generic_delete_inode(struct inode *inode)
        destroy_inode(inode);
 }
 
+void generic_delete_inode(struct inode *inode)
+{
+       list_del_init(&inode->i_list);
+       list_del_init(&inode->i_sb_list);
+       inode->i_state |= I_FREEING;
+       inodes_stat.nr_inodes--;
+       spin_unlock(&inode_lock);
+       async_schedule_special(generic_delete_inode_async, inode, &inode->i_sb->s_async_list);
+}
+
 EXPORT_SYMBOL(generic_delete_inode);
 
 static void generic_forget_inode(struct inode *inode)
index ddba069d7a99e515f4c6bb16dd61b4b379423a9c..cb20744ec789e1dc83254f3b0912c4b1df12b49f 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/kobject.h>
 #include <linux/mutex.h>
 #include <linux/file.h>
+#include <linux/async.h>
 #include <asm/uaccess.h>
 #include "internal.h"
 
@@ -71,6 +72,7 @@ static struct super_block *alloc_super(struct file_system_type *type)
                INIT_HLIST_HEAD(&s->s_anon);
                INIT_LIST_HEAD(&s->s_inodes);
                INIT_LIST_HEAD(&s->s_dentry_lru);
+               INIT_LIST_HEAD(&s->s_async_list);
                init_rwsem(&s->s_umount);
                mutex_init(&s->s_lock);
                lockdep_set_class(&s->s_umount, &type->s_umount_key);
@@ -289,11 +291,18 @@ void generic_shutdown_super(struct super_block *sb)
 {
        const struct super_operations *sop = sb->s_op;
 
+
        if (sb->s_root) {
                shrink_dcache_for_umount(sb);
                fsync_super(sb);
                lock_super(sb);
                sb->s_flags &= ~MS_ACTIVE;
+
+               /*
+                * wait for asynchronous fs operations to finish before going further
+                */
+               async_synchronize_full_special(&sb->s_async_list);
+
                /* bad name - it should be evict_inodes() */
                invalidate_inodes(sb);
                lock_kernel();
@@ -449,6 +458,7 @@ void sync_filesystems(int wait)
                if (sb->s_flags & MS_RDONLY)
                        continue;
                sb->s_need_sync_fs = 1;
+               async_synchronize_full_special(&sb->s_async_list);
        }
 
 restart:
index d7eba77f666e9558e31061b3a63d7b5d720c4a82..e38a64d71efff910fbc9b6a8ad578a0cd509aea4 100644 (file)
@@ -1184,6 +1184,11 @@ struct super_block {
         * generic_show_options()
         */
        char *s_options;
+
+       /*
+        * storage for asynchronous operations
+        */
+       struct list_head s_async_list;
 };
 
 extern struct timespec current_fs_time(struct super_block *sb);