ext4: simplify list handling in ext4_do_flush_completed_IO()
authorJan Kara <jack@suse.cz>
Mon, 28 Jan 2013 14:49:15 +0000 (09:49 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 28 Jan 2013 14:49:15 +0000 (09:49 -0500)
The function splices i_completed_io_list to its private list
first.  From that moment on we don't need any lock for working with
io_end structures because all io_end structure on the list are only
our own. So we can remove the other two lists in the function and free
io_end immediately after we are done with it.

CC: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/page-io.c

index a0290176ee75af7f0a50342655ed82676ec082c3..3fb385cd9670bada95bdd5c4c89149262418e9ef 100644 (file)
@@ -160,14 +160,11 @@ void ext4_add_complete_io(ext4_io_end_t *io_end)
 static int ext4_do_flush_completed_IO(struct inode *inode)
 {
        ext4_io_end_t *io;
-       struct list_head unwritten, complete, to_free;
+       struct list_head unwritten;
        unsigned long flags;
        struct ext4_inode_info *ei = EXT4_I(inode);
        int err, ret = 0;
 
-       INIT_LIST_HEAD(&complete);
-       INIT_LIST_HEAD(&to_free);
-
        spin_lock_irqsave(&ei->i_completed_io_lock, flags);
        dump_completed_IO(inode);
        list_replace_init(&ei->i_completed_io_list, &unwritten);
@@ -181,20 +178,7 @@ static int ext4_do_flush_completed_IO(struct inode *inode)
                err = ext4_end_io(io);
                if (unlikely(!ret && err))
                        ret = err;
-
-               list_add_tail(&io->list, &complete);
-       }
-       spin_lock_irqsave(&ei->i_completed_io_lock, flags);
-       while (!list_empty(&complete)) {
-               io = list_entry(complete.next, ext4_io_end_t, list);
                io->flag &= ~EXT4_IO_END_UNWRITTEN;
-               list_move(&io->list, &to_free);
-       }
-       spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
-
-       while (!list_empty(&to_free)) {
-               io = list_entry(to_free.next, ext4_io_end_t, list);
-               list_del_init(&io->list);
                ext4_free_io_end(io);
        }
        return ret;