blob: 1d98fcfc2ff0f9c68fd4f78cdd9a22a97dd646c2 [file] [log] [blame]
Theodore Ts'obd2d0212010-10-27 21:30:10 -04001/*
2 * linux/fs/ext4/page-io.c
3 *
4 * This contains the new page_io functions for ext4
5 *
6 * Written by Theodore Ts'o, 2010.
7 */
8
Theodore Ts'obd2d0212010-10-27 21:30:10 -04009#include <linux/fs.h>
10#include <linux/time.h>
11#include <linux/jbd2.h>
12#include <linux/highuid.h>
13#include <linux/pagemap.h>
14#include <linux/quotaops.h>
15#include <linux/string.h>
16#include <linux/buffer_head.h>
17#include <linux/writeback.h>
18#include <linux/pagevec.h>
19#include <linux/mpage.h>
20#include <linux/namei.h>
21#include <linux/uio.h>
22#include <linux/bio.h>
23#include <linux/workqueue.h>
24#include <linux/kernel.h>
25#include <linux/slab.h>
Jan Kara1ae48a62013-01-28 09:32:54 -050026#include <linux/mm.h>
Theodore Ts'obd2d0212010-10-27 21:30:10 -040027
28#include "ext4_jbd2.h"
29#include "xattr.h"
30#include "acl.h"
Theodore Ts'obd2d0212010-10-27 21:30:10 -040031
Jan Kara0058f962013-04-11 23:48:32 -040032static struct kmem_cache *io_end_cachep;
Theodore Ts'obd2d0212010-10-27 21:30:10 -040033
Theodore Ts'o5dabfc72010-10-27 21:30:14 -040034int __init ext4_init_pageio(void)
Theodore Ts'obd2d0212010-10-27 21:30:10 -040035{
Theodore Ts'obd2d0212010-10-27 21:30:10 -040036 io_end_cachep = KMEM_CACHE(ext4_io_end, SLAB_RECLAIM_ACCOUNT);
Jan Kara0058f962013-04-11 23:48:32 -040037 if (io_end_cachep == NULL)
Theodore Ts'obd2d0212010-10-27 21:30:10 -040038 return -ENOMEM;
Theodore Ts'obd2d0212010-10-27 21:30:10 -040039 return 0;
40}
41
Theodore Ts'o5dabfc72010-10-27 21:30:14 -040042void ext4_exit_pageio(void)
Theodore Ts'obd2d0212010-10-27 21:30:10 -040043{
44 kmem_cache_destroy(io_end_cachep);
Theodore Ts'obd2d0212010-10-27 21:30:10 -040045}
46
Theodore Ts'o1ada47d2013-03-20 09:39:42 -040047/*
48 * This function is called by ext4_evict_inode() to make sure there is
49 * no more pending I/O completion work left to do.
50 */
51void ext4_ioend_shutdown(struct inode *inode)
Theodore Ts'of7ad6d22010-11-08 13:43:33 -050052{
Eric Sandeene9e3bce2011-02-12 08:17:34 -050053 wait_queue_head_t *wq = ext4_ioend_wq(inode);
Theodore Ts'of7ad6d22010-11-08 13:43:33 -050054
55 wait_event(*wq, (atomic_read(&EXT4_I(inode)->i_ioend_count) == 0));
Theodore Ts'o1ada47d2013-03-20 09:39:42 -040056 /*
57 * We need to make sure the work structure is finished being
58 * used before we let the inode get destroyed.
59 */
60 if (work_pending(&EXT4_I(inode)->i_unwritten_work))
61 cancel_work_sync(&EXT4_I(inode)->i_unwritten_work);
Theodore Ts'of7ad6d22010-11-08 13:43:33 -050062}
63
Theodore Ts'obd2d0212010-10-27 21:30:10 -040064void ext4_free_io_end(ext4_io_end_t *io)
65{
66 int i;
67
68 BUG_ON(!io);
Dmitry Monakhov28a535f2012-09-29 00:14:55 -040069 BUG_ON(!list_empty(&io->list));
Dmitry Monakhov82e54222012-09-28 23:36:25 -040070 BUG_ON(io->flag & EXT4_IO_END_UNWRITTEN);
71
Theodore Ts'o4e298022011-10-30 18:41:19 -040072 if (atomic_dec_and_test(&EXT4_I(io->inode)->i_ioend_count))
73 wake_up_all(ext4_ioend_wq(io->inode));
Theodore Ts'obd2d0212010-10-27 21:30:10 -040074 kmem_cache_free(io_end_cachep, io);
75}
76
Dmitry Monakhov28a535f2012-09-29 00:14:55 -040077/* check a range of space and convert unwritten extents to written. */
78static int ext4_end_io(ext4_io_end_t *io)
Theodore Ts'obd2d0212010-10-27 21:30:10 -040079{
80 struct inode *inode = io->inode;
81 loff_t offset = io->offset;
82 ssize_t size = io->size;
83 int ret = 0;
84
85 ext4_debug("ext4_end_io_nolock: io 0x%p from inode %lu,list->next 0x%p,"
86 "list->prev 0x%p\n",
87 io, inode->i_ino, io->list.next, io->list.prev);
88
Theodore Ts'obd2d0212010-10-27 21:30:10 -040089 ret = ext4_convert_unwritten_extents(inode, offset, size);
90 if (ret < 0) {
Theodore Ts'ob82e3842011-10-31 10:56:32 -040091 ext4_msg(inode->i_sb, KERN_EMERG,
92 "failed to convert unwritten extents to written "
93 "extents -- potential data loss! "
94 "(inode %lu, offset %llu, size %zd, error %d)",
95 inode->i_ino, offset, size, ret);
Theodore Ts'obd2d0212010-10-27 21:30:10 -040096 }
Theodore Ts'ob82e3842011-10-31 10:56:32 -040097 /* Wake up anyone waiting on unwritten extent conversion */
Dmitry Monakhove27f41e2012-09-28 23:24:52 -040098 if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
Anatol Pomozov8d8c1822012-11-08 14:53:35 -050099 wake_up_all(ext4_ioend_wq(inode));
Jan Kara091e26d2013-01-29 22:48:17 -0500100 if (io->flag & EXT4_IO_END_DIRECT)
101 inode_dio_done(inode);
102 if (io->iocb)
103 aio_complete(io->iocb, io->result, 0);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400104 return ret;
105}
106
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400107static void dump_completed_IO(struct inode *inode)
108{
109#ifdef EXT4FS_DEBUG
110 struct list_head *cur, *before, *after;
111 ext4_io_end_t *io, *io0, *io1;
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400112
113 if (list_empty(&EXT4_I(inode)->i_completed_io_list)) {
114 ext4_debug("inode %lu completed_io list is empty\n",
115 inode->i_ino);
116 return;
117 }
118
119 ext4_debug("Dump inode %lu completed_io list\n", inode->i_ino);
120 list_for_each_entry(io, &EXT4_I(inode)->i_completed_io_list, list) {
121 cur = &io->list;
122 before = cur->prev;
123 io0 = container_of(before, ext4_io_end_t, list);
124 after = cur->next;
125 io1 = container_of(after, ext4_io_end_t, list);
126
127 ext4_debug("io 0x%p from inode %lu,prev 0x%p,next 0x%p\n",
128 io, inode->i_ino, io0, io1);
129 }
130#endif
131}
132
133/* Add the io_end to per-inode completed end_io list. */
134void ext4_add_complete_io(ext4_io_end_t *io_end)
135{
136 struct ext4_inode_info *ei = EXT4_I(io_end->inode);
137 struct workqueue_struct *wq;
138 unsigned long flags;
139
140 BUG_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN));
141 wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq;
142
143 spin_lock_irqsave(&ei->i_completed_io_lock, flags);
Jan Kara84c17542013-01-28 09:43:46 -0500144 if (list_empty(&ei->i_completed_io_list))
145 queue_work(wq, &ei->i_unwritten_work);
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400146 list_add_tail(&io_end->list, &ei->i_completed_io_list);
147 spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
148}
149
Jan Kara84c17542013-01-28 09:43:46 -0500150static int ext4_do_flush_completed_IO(struct inode *inode)
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400151{
152 ext4_io_end_t *io;
Jan Kara002bd7f2013-01-28 09:49:15 -0500153 struct list_head unwritten;
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400154 unsigned long flags;
155 struct ext4_inode_info *ei = EXT4_I(inode);
156 int err, ret = 0;
157
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400158 spin_lock_irqsave(&ei->i_completed_io_lock, flags);
159 dump_completed_IO(inode);
160 list_replace_init(&ei->i_completed_io_list, &unwritten);
161 spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
162
163 while (!list_empty(&unwritten)) {
164 io = list_entry(unwritten.next, ext4_io_end_t, list);
165 BUG_ON(!(io->flag & EXT4_IO_END_UNWRITTEN));
166 list_del_init(&io->list);
167
168 err = ext4_end_io(io);
169 if (unlikely(!ret && err))
170 ret = err;
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400171 io->flag &= ~EXT4_IO_END_UNWRITTEN;
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400172 ext4_free_io_end(io);
173 }
174 return ret;
175}
176
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400177/*
178 * work on completed aio dio IO, to convert unwritten extents to extents
179 */
Jan Kara84c17542013-01-28 09:43:46 -0500180void ext4_end_io_work(struct work_struct *work)
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400181{
Jan Kara84c17542013-01-28 09:43:46 -0500182 struct ext4_inode_info *ei = container_of(work, struct ext4_inode_info,
183 i_unwritten_work);
184 ext4_do_flush_completed_IO(&ei->vfs_inode);
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400185}
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400186
Dmitry Monakhovc2785312012-10-05 11:31:55 -0400187int ext4_flush_unwritten_io(struct inode *inode)
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400188{
Dmitry Monakhovc2785312012-10-05 11:31:55 -0400189 int ret;
190 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex) &&
191 !(inode->i_state & I_FREEING));
Jan Kara84c17542013-01-28 09:43:46 -0500192 ret = ext4_do_flush_completed_IO(inode);
Dmitry Monakhovc2785312012-10-05 11:31:55 -0400193 ext4_unwritten_wait(inode);
194 return ret;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400195}
196
197ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags)
198{
Jesper Juhlb17b35e2010-12-19 21:41:55 -0500199 ext4_io_end_t *io = kmem_cache_zalloc(io_end_cachep, flags);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400200 if (io) {
Theodore Ts'of7ad6d22010-11-08 13:43:33 -0500201 atomic_inc(&EXT4_I(inode)->i_ioend_count);
202 io->inode = inode;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400203 INIT_LIST_HEAD(&io->list);
204 }
205 return io;
206}
207
208/*
209 * Print an buffer I/O error compatible with the fs/buffer.c. This
210 * provides compatibility with dmesg scrapers that look for a specific
211 * buffer I/O error message. We really need a unified error reporting
212 * structure to userspace ala Digital Unix's uerf system, but it's
213 * probably not going to happen in my lifetime, due to LKML politics...
214 */
215static void buffer_io_error(struct buffer_head *bh)
216{
217 char b[BDEVNAME_SIZE];
218 printk(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n",
219 bdevname(bh->b_bdev, b),
220 (unsigned long long)bh->b_blocknr);
221}
222
223static void ext4_end_bio(struct bio *bio, int error)
224{
225 ext4_io_end_t *io_end = bio->bi_private;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400226 struct inode *inode;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400227 int i;
Jan Kara0058f962013-04-11 23:48:32 -0400228 int blocksize;
Curt Wohlgemuthd50bdd52011-02-07 12:46:14 -0500229 sector_t bi_sector = bio->bi_sector;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400230
231 BUG_ON(!io_end);
Jan Kara0058f962013-04-11 23:48:32 -0400232 inode = io_end->inode;
233 blocksize = 1 << inode->i_blkbits;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400234 bio->bi_private = NULL;
235 bio->bi_end_io = NULL;
236 if (test_bit(BIO_UPTODATE, &bio->bi_flags))
237 error = 0;
Jan Kara0058f962013-04-11 23:48:32 -0400238 for (i = 0; i < bio->bi_vcnt; i++) {
239 struct bio_vec *bvec = &bio->bi_io_vec[i];
240 struct page *page = bvec->bv_page;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400241 struct buffer_head *bh, *head;
Jan Kara0058f962013-04-11 23:48:32 -0400242 unsigned bio_start = bvec->bv_offset;
243 unsigned bio_end = bio_start + bvec->bv_len;
244 unsigned under_io = 0;
245 unsigned long flags;
246
247 if (!page)
248 continue;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400249
Curt Wohlgemuth39db00f2011-04-30 13:26:26 -0400250 if (error) {
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400251 SetPageError(page);
Curt Wohlgemuth39db00f2011-04-30 13:26:26 -0400252 set_bit(AS_EIO, &page->mapping->flags);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400253 }
Jan Kara0058f962013-04-11 23:48:32 -0400254 bh = head = page_buffers(page);
255 /*
256 * We check all buffers in the page under BH_Uptodate_Lock
257 * to avoid races with other end io clearing async_write flags
258 */
259 local_irq_save(flags);
260 bit_spin_lock(BH_Uptodate_Lock, &head->b_state);
261 do {
262 if (bh_offset(bh) < bio_start ||
263 bh_offset(bh) + blocksize > bio_end) {
264 if (buffer_async_write(bh))
265 under_io++;
266 continue;
267 }
268 clear_buffer_async_write(bh);
269 if (error)
270 buffer_io_error(bh);
271 } while ((bh = bh->b_this_page) != head);
272 bit_spin_unlock(BH_Uptodate_Lock, &head->b_state);
273 local_irq_restore(flags);
274 if (!under_io)
275 end_page_writeback(page);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400276 }
Jan Kara0058f962013-04-11 23:48:32 -0400277 bio_put(bio);
Theodore Ts'of7ad6d22010-11-08 13:43:33 -0500278
279 if (error) {
280 io_end->flag |= EXT4_IO_END_ERROR;
281 ext4_warning(inode->i_sb, "I/O error writing to inode %lu "
282 "(offset %llu size %ld starting block %llu)",
283 inode->i_ino,
284 (unsigned long long) io_end->offset,
285 (long) io_end->size,
286 (unsigned long long)
Curt Wohlgemuthd50bdd52011-02-07 12:46:14 -0500287 bi_sector >> (inode->i_blkbits - 9));
Theodore Ts'of7ad6d22010-11-08 13:43:33 -0500288 }
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400289
Theodore Ts'ob6168442011-02-28 13:12:38 -0500290 if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
291 ext4_free_io_end(io_end);
292 return;
293 }
294
Dmitry Monakhov28a535f2012-09-29 00:14:55 -0400295 ext4_add_complete_io(io_end);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400296}
297
298void ext4_io_submit(struct ext4_io_submit *io)
299{
300 struct bio *bio = io->io_bio;
301
302 if (bio) {
303 bio_get(io->io_bio);
304 submit_bio(io->io_op, io->io_bio);
305 BUG_ON(bio_flagged(io->io_bio, BIO_EOPNOTSUPP));
306 bio_put(io->io_bio);
307 }
Peter Huewe7dc57612011-02-21 21:01:42 -0500308 io->io_bio = NULL;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400309 io->io_op = 0;
Peter Huewe7dc57612011-02-21 21:01:42 -0500310 io->io_end = NULL;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400311}
312
313static int io_submit_init(struct ext4_io_submit *io,
314 struct inode *inode,
315 struct writeback_control *wbc,
316 struct buffer_head *bh)
317{
318 ext4_io_end_t *io_end;
319 struct page *page = bh->b_page;
320 int nvecs = bio_get_nr_vecs(bh->b_bdev);
321 struct bio *bio;
322
323 io_end = ext4_init_io_end(inode, GFP_NOFS);
324 if (!io_end)
325 return -ENOMEM;
Theodore Ts'o275d3ba2011-06-29 21:44:45 -0400326 bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES));
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400327 bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9);
328 bio->bi_bdev = bh->b_bdev;
329 bio->bi_private = io->io_end = io_end;
330 bio->bi_end_io = ext4_end_bio;
331
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400332 io_end->offset = (page->index << PAGE_CACHE_SHIFT) + bh_offset(bh);
333
334 io->io_bio = bio;
Jens Axboe721a9602011-03-09 11:56:30 +0100335 io->io_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400336 io->io_next_block = bh->b_blocknr;
337 return 0;
338}
339
340static int io_submit_add_bh(struct ext4_io_submit *io,
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400341 struct inode *inode,
342 struct writeback_control *wbc,
343 struct buffer_head *bh)
344{
345 ext4_io_end_t *io_end;
346 int ret;
347
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400348 if (io->io_bio && bh->b_blocknr != io->io_next_block) {
349submit_and_retry:
350 ext4_io_submit(io);
351 }
352 if (io->io_bio == NULL) {
353 ret = io_submit_init(io, inode, wbc, bh);
354 if (ret)
355 return ret;
356 }
357 io_end = io->io_end;
Tao Ma0edeb712011-10-31 17:30:44 -0400358 if (buffer_uninit(bh))
359 ext4_set_io_unwritten_flag(inode, io_end);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400360 io->io_end->size += bh->b_size;
361 io->io_next_block++;
362 ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh));
363 if (ret != bh->b_size)
364 goto submit_and_retry;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400365 return 0;
366}
367
368int ext4_bio_write_page(struct ext4_io_submit *io,
369 struct page *page,
370 int len,
371 struct writeback_control *wbc)
372{
373 struct inode *inode = page->mapping->host;
Jan Kara0058f962013-04-11 23:48:32 -0400374 unsigned block_start, blocksize;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400375 struct buffer_head *bh, *head;
376 int ret = 0;
Jan Kara0058f962013-04-11 23:48:32 -0400377 int nr_submitted = 0;
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400378
379 blocksize = 1 << inode->i_blkbits;
380
Curt Wohlgemuthd50bdd52011-02-07 12:46:14 -0500381 BUG_ON(!PageLocked(page));
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400382 BUG_ON(PageWriteback(page));
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400383
Theodore Ts'oa54aa762011-02-27 16:43:24 -0500384 set_page_writeback(page);
385 ClearPageError(page);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400386
Jan Kara0058f962013-04-11 23:48:32 -0400387 /*
388 * In the first loop we prepare and mark buffers to submit. We have to
389 * mark all buffers in the page before submitting so that
390 * end_page_writeback() cannot be called from ext4_bio_end_io() when IO
391 * on the first buffer finishes and we are still working on submitting
392 * the second buffer.
393 */
394 bh = head = page_buffers(page);
395 do {
396 block_start = bh_offset(bh);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400397 if (block_start >= len) {
Yongqiang Yang5a0dc732011-12-13 22:29:12 -0500398 /*
399 * Comments copied from block_write_full_page_endio:
400 *
401 * The page straddles i_size. It must be zeroed out on
402 * each and every writepage invocation because it may
403 * be mmapped. "A file is mapped in multiples of the
404 * page size. For a file that is not a multiple of
405 * the page size, the remaining memory is zeroed when
406 * mapped, and writes to that region are not written
407 * out to the file."
408 */
Jan Kara0058f962013-04-11 23:48:32 -0400409 zero_user_segment(page, block_start,
410 block_start + blocksize);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400411 clear_buffer_dirty(bh);
412 set_buffer_uptodate(bh);
413 continue;
414 }
Jan Kara8a850c32013-01-28 20:53:28 -0500415 if (!buffer_dirty(bh) || buffer_delay(bh) ||
416 !buffer_mapped(bh) || buffer_unwritten(bh)) {
417 /* A hole? We can safely clear the dirty bit */
418 if (!buffer_mapped(bh))
419 clear_buffer_dirty(bh);
420 if (io->io_bio)
421 ext4_io_submit(io);
422 continue;
423 }
Jan Kara0058f962013-04-11 23:48:32 -0400424 if (buffer_new(bh)) {
425 clear_buffer_new(bh);
426 unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
427 }
428 set_buffer_async_write(bh);
429 } while ((bh = bh->b_this_page) != head);
430
431 /* Now submit buffers to write */
432 bh = head = page_buffers(page);
433 do {
434 if (!buffer_async_write(bh))
435 continue;
436 ret = io_submit_add_bh(io, inode, wbc, bh);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400437 if (ret) {
438 /*
439 * We only get here on ENOMEM. Not much else
440 * we can do but mark the page as dirty, and
441 * better luck next time.
442 */
Jan Kara1ae48a62013-01-28 09:32:54 -0500443 redirty_page_for_writepage(wbc, page);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400444 break;
445 }
Jan Kara0058f962013-04-11 23:48:32 -0400446 nr_submitted++;
Jan Kara1ae48a62013-01-28 09:32:54 -0500447 clear_buffer_dirty(bh);
Jan Kara0058f962013-04-11 23:48:32 -0400448 } while ((bh = bh->b_this_page) != head);
449
450 /* Error stopped previous loop? Clean up buffers... */
451 if (ret) {
452 do {
453 clear_buffer_async_write(bh);
454 bh = bh->b_this_page;
455 } while (bh != head);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400456 }
457 unlock_page(page);
Jan Kara0058f962013-04-11 23:48:32 -0400458 /* Nothing submitted - we have to end page writeback */
459 if (!nr_submitted)
460 end_page_writeback(page);
Theodore Ts'obd2d0212010-10-27 21:30:10 -0400461 return ret;
462}