diff options
author | Jan Kara <jack@suse.cz> | 2013-01-28 09:49:15 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-01-28 09:49:15 -0500 |
commit | 002bd7fa3ac7441bdb36df67b2c64bc8c1be5360 (patch) | |
tree | 97b12473041ce1aea805aadb667b17028d99458d /fs/ext4 | |
parent | 84c17543ab5685d950da73209df0ecda26e72d3b (diff) |
ext4: simplify list handling in ext4_do_flush_completed_IO()
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>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/page-io.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index a0290176ee75..3fb385cd9670 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c | |||
@@ -160,14 +160,11 @@ void ext4_add_complete_io(ext4_io_end_t *io_end) | |||
160 | static int ext4_do_flush_completed_IO(struct inode *inode) | 160 | static int ext4_do_flush_completed_IO(struct inode *inode) |
161 | { | 161 | { |
162 | ext4_io_end_t *io; | 162 | ext4_io_end_t *io; |
163 | struct list_head unwritten, complete, to_free; | 163 | struct list_head unwritten; |
164 | unsigned long flags; | 164 | unsigned long flags; |
165 | struct ext4_inode_info *ei = EXT4_I(inode); | 165 | struct ext4_inode_info *ei = EXT4_I(inode); |
166 | int err, ret = 0; | 166 | int err, ret = 0; |
167 | 167 | ||
168 | INIT_LIST_HEAD(&complete); | ||
169 | INIT_LIST_HEAD(&to_free); | ||
170 | |||
171 | spin_lock_irqsave(&ei->i_completed_io_lock, flags); | 168 | spin_lock_irqsave(&ei->i_completed_io_lock, flags); |
172 | dump_completed_IO(inode); | 169 | dump_completed_IO(inode); |
173 | list_replace_init(&ei->i_completed_io_list, &unwritten); | 170 | list_replace_init(&ei->i_completed_io_list, &unwritten); |
@@ -181,20 +178,7 @@ static int ext4_do_flush_completed_IO(struct inode *inode) | |||
181 | err = ext4_end_io(io); | 178 | err = ext4_end_io(io); |
182 | if (unlikely(!ret && err)) | 179 | if (unlikely(!ret && err)) |
183 | ret = err; | 180 | ret = err; |
184 | |||
185 | list_add_tail(&io->list, &complete); | ||
186 | } | ||
187 | spin_lock_irqsave(&ei->i_completed_io_lock, flags); | ||
188 | while (!list_empty(&complete)) { | ||
189 | io = list_entry(complete.next, ext4_io_end_t, list); | ||
190 | io->flag &= ~EXT4_IO_END_UNWRITTEN; | 181 | io->flag &= ~EXT4_IO_END_UNWRITTEN; |
191 | list_move(&io->list, &to_free); | ||
192 | } | ||
193 | spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); | ||
194 | |||
195 | while (!list_empty(&to_free)) { | ||
196 | io = list_entry(to_free.next, ext4_io_end_t, list); | ||
197 | list_del_init(&io->list); | ||
198 | ext4_free_io_end(io); | 182 | ext4_free_io_end(io); |
199 | } | 183 | } |
200 | return ret; | 184 | return ret; |