4 * Copyright (C) 2002, Linus Torvalds.
6 * Contains functions related to preparing and submitting BIOs which contain
7 * multiple pagecache pages.
9 * 15May2002 akpm@zip.com.au
11 * 27Jun2002 axboe@suse.de
12 * use bio_add_page() to build bio's just the right size
15 #include <linux/kernel.h>
16 #include <linux/module.h>
18 #include <linux/kdev_t.h>
19 #include <linux/bio.h>
21 #include <linux/buffer_head.h>
22 #include <linux/blkdev.h>
23 #include <linux/highmem.h>
24 #include <linux/prefetch.h>
25 #include <linux/mpage.h>
26 #include <linux/writeback.h>
27 #include <linux/backing-dev.h>
28 #include <linux/pagevec.h>
31 * I/O completion handler for multipage BIOs.
33 * The mpage code never puts partial pages into a BIO (except for end-of-file).
34 * If a page does not map to a contiguous run of blocks then it simply falls
35 * back to block_read_full_page().
37 * Why is this? If a page's completion depends on a number of different BIOs
38 * which can complete in any order (or at the same time) then determining the
39 * status of that page is hard. See end_buffer_async_read() for the details.
40 * There is no point in duplicating all that complexity.
42 static int mpage_end_io_read(struct bio
*bio
, unsigned int bytes_done
, int err
)
44 const int uptodate
= test_bit(BIO_UPTODATE
, &bio
->bi_flags
);
45 struct bio_vec
*bvec
= bio
->bi_io_vec
+ bio
->bi_vcnt
- 1;
51 struct page
*page
= bvec
->bv_page
;
53 if (--bvec
>= bio
->bi_io_vec
)
54 prefetchw(&bvec
->bv_page
->flags
);
57 SetPageUptodate(page
);
59 ClearPageUptodate(page
);
63 } while (bvec
>= bio
->bi_io_vec
);
68 static int mpage_end_io_write(struct bio
*bio
, unsigned int bytes_done
, int err
)
70 const int uptodate
= test_bit(BIO_UPTODATE
, &bio
->bi_flags
);
71 struct bio_vec
*bvec
= bio
->bi_io_vec
+ bio
->bi_vcnt
- 1;
77 struct page
*page
= bvec
->bv_page
;
79 if (--bvec
>= bio
->bi_io_vec
)
80 prefetchw(&bvec
->bv_page
->flags
);
84 #if 0 // mask by Victor Yu. 02-12-2007
86 set_bit(AS_EIO
, &page
->mapping
->flags
);
88 if (page
->u
.xx
.mapping
)
89 set_bit(AS_EIO
, &page
->u
.xx
.mapping
->flags
);
92 end_page_writeback(page
);
93 } while (bvec
>= bio
->bi_io_vec
);
98 static struct bio
*mpage_bio_submit(int rw
, struct bio
*bio
)
100 bio
->bi_end_io
= mpage_end_io_read
;
102 bio
->bi_end_io
= mpage_end_io_write
;
108 mpage_alloc(struct block_device
*bdev
,
109 sector_t first_sector
, int nr_vecs
,
114 bio
= bio_alloc(gfp_flags
, nr_vecs
);
116 if (bio
== NULL
&& (current
->flags
& PF_MEMALLOC
)) {
117 while (!bio
&& (nr_vecs
/= 2))
118 bio
= bio_alloc(gfp_flags
, nr_vecs
);
123 bio
->bi_sector
= first_sector
;
129 * support function for mpage_readpages. The fs supplied get_block might
130 * return an up to date buffer. This is used to map that buffer into
131 * the page, which allows readpage to avoid triggering a duplicate call
134 * The idea is to avoid adding buffers to pages that don't already have
135 * them. So when the buffer is up to date and the page size == block size,
136 * this marks the page up to date instead of adding new buffers.
139 map_buffer_to_page(struct page
*page
, struct buffer_head
*bh
, int page_block
)
141 #if 0 // mask by Victor Yu. 02-12-2007
142 struct inode
*inode
= page
->mapping
->host
;
144 struct inode
*inode
= page
->u
.xx
.mapping
->host
;
146 struct buffer_head
*page_bh
, *head
;
149 if (!page_has_buffers(page
)) {
151 * don't make any buffers if there is only one buffer on
152 * the page and the page just needs to be set up to date
154 if (inode
->i_blkbits
== PAGE_CACHE_SHIFT
&&
155 buffer_uptodate(bh
)) {
156 SetPageUptodate(page
);
159 create_empty_buffers(page
, 1 << inode
->i_blkbits
, 0);
161 head
= page_buffers(page
);
164 if (block
== page_block
) {
165 page_bh
->b_state
= bh
->b_state
;
166 page_bh
->b_bdev
= bh
->b_bdev
;
167 page_bh
->b_blocknr
= bh
->b_blocknr
;
170 page_bh
= page_bh
->b_this_page
;
172 } while (page_bh
!= head
);
176 * This is the worker routine which does all the work of mapping the disk
177 * blocks and constructs largest possible bios, submits them for IO if the
178 * blocks are not contiguous on the disk.
180 * We pass a buffer_head back and forth and use its buffer_mapped() flag to
181 * represent the validity of its disk mapping and to decide when to do the next
185 do_mpage_readpage(struct bio
*bio
, struct page
*page
, unsigned nr_pages
,
186 sector_t
*last_block_in_bio
, struct buffer_head
*map_bh
,
187 unsigned long *first_logical_block
, get_block_t get_block
)
189 #if 0 // mask by Victor Yu. 02-12-2007
190 struct inode
*inode
= page
->mapping
->host
;
192 struct inode
*inode
= page
->u
.xx
.mapping
->host
;
194 const unsigned blkbits
= inode
->i_blkbits
;
195 const unsigned blocks_per_page
= PAGE_CACHE_SIZE
>> blkbits
;
196 const unsigned blocksize
= 1 << blkbits
;
197 sector_t block_in_file
;
199 sector_t last_block_in_file
;
200 sector_t blocks
[MAX_BUF_PER_PAGE
];
202 unsigned first_hole
= blocks_per_page
;
203 struct block_device
*bdev
= NULL
;
205 int fully_mapped
= 1;
207 unsigned relative_block
;
209 if (page_has_buffers(page
))
212 block_in_file
= (sector_t
)page
->index
<< (PAGE_CACHE_SHIFT
- blkbits
);
213 last_block
= block_in_file
+ nr_pages
* blocks_per_page
;
214 last_block_in_file
= (i_size_read(inode
) + blocksize
- 1) >> blkbits
;
215 if (last_block
> last_block_in_file
)
216 last_block
= last_block_in_file
;
220 * Map blocks using the result from the previous get_blocks call first.
222 nblocks
= map_bh
->b_size
>> blkbits
;
223 if (buffer_mapped(map_bh
) && block_in_file
> *first_logical_block
&&
224 block_in_file
< (*first_logical_block
+ nblocks
)) {
225 unsigned map_offset
= block_in_file
- *first_logical_block
;
226 unsigned last
= nblocks
- map_offset
;
228 for (relative_block
= 0; ; relative_block
++) {
229 if (relative_block
== last
) {
230 clear_buffer_mapped(map_bh
);
233 if (page_block
== blocks_per_page
)
235 blocks
[page_block
] = map_bh
->b_blocknr
+ map_offset
+
240 bdev
= map_bh
->b_bdev
;
244 * Then do more get_blocks calls until we are done with this page.
246 map_bh
->b_page
= page
;
247 while (page_block
< blocks_per_page
) {
251 if (block_in_file
< last_block
) {
252 map_bh
->b_size
= (last_block
-block_in_file
) << blkbits
;
253 if (get_block(inode
, block_in_file
, map_bh
, 0))
255 *first_logical_block
= block_in_file
;
258 if (!buffer_mapped(map_bh
)) {
260 if (first_hole
== blocks_per_page
)
261 first_hole
= page_block
;
264 clear_buffer_mapped(map_bh
);
268 /* some filesystems will copy data into the page during
269 * the get_block call, in which case we don't want to
270 * read it again. map_buffer_to_page copies the data
271 * we just collected from get_block into the page's buffers
272 * so readpage doesn't have to repeat the get_block call
274 if (buffer_uptodate(map_bh
)) {
275 map_buffer_to_page(page
, map_bh
, page_block
);
279 if (first_hole
!= blocks_per_page
)
280 goto confused
; /* hole -> non-hole */
282 /* Contiguous blocks? */
283 if (page_block
&& blocks
[page_block
-1] != map_bh
->b_blocknr
-1)
285 nblocks
= map_bh
->b_size
>> blkbits
;
286 for (relative_block
= 0; ; relative_block
++) {
287 if (relative_block
== nblocks
) {
288 clear_buffer_mapped(map_bh
);
290 } else if (page_block
== blocks_per_page
)
292 blocks
[page_block
] = map_bh
->b_blocknr
+relative_block
;
296 bdev
= map_bh
->b_bdev
;
299 if (first_hole
!= blocks_per_page
) {
300 char *kaddr
= kmap_atomic(page
, KM_USER0
);
301 memset(kaddr
+ (first_hole
<< blkbits
), 0,
302 PAGE_CACHE_SIZE
- (first_hole
<< blkbits
));
303 flush_dcache_page(page
);
304 kunmap_atomic(kaddr
, KM_USER0
);
305 if (first_hole
== 0) {
306 SetPageUptodate(page
);
310 } else if (fully_mapped
) {
311 SetPageMappedToDisk(page
);
315 * This page will go to BIO. Do we need to send this BIO off first?
317 if (bio
&& (*last_block_in_bio
!= blocks
[0] - 1))
318 bio
= mpage_bio_submit(READ
, bio
);
322 bio
= mpage_alloc(bdev
, blocks
[0] << (blkbits
- 9),
323 min_t(int, nr_pages
, bio_get_nr_vecs(bdev
)),
329 length
= first_hole
<< blkbits
;
330 if (bio_add_page(bio
, page
, length
, 0) < length
) {
331 bio
= mpage_bio_submit(READ
, bio
);
335 if (buffer_boundary(map_bh
) || (first_hole
!= blocks_per_page
))
336 bio
= mpage_bio_submit(READ
, bio
);
338 *last_block_in_bio
= blocks
[blocks_per_page
- 1];
344 bio
= mpage_bio_submit(READ
, bio
);
345 if (!PageUptodate(page
))
346 block_read_full_page(page
, get_block
);
353 * mpage_readpages - populate an address space with some pages, and
354 * start reads against them.
356 * @mapping: the address_space
357 * @pages: The address of a list_head which contains the target pages. These
358 * pages have their ->index populated and are otherwise uninitialised.
360 * The page at @pages->prev has the lowest file offset, and reads should be
361 * issued in @pages->prev to @pages->next order.
363 * @nr_pages: The number of pages at *@pages
364 * @get_block: The filesystem's block mapper function.
366 * This function walks the pages and the blocks within each page, building and
367 * emitting large BIOs.
369 * If anything unusual happens, such as:
371 * - encountering a page which has buffers
372 * - encountering a page which has a non-hole after a hole
373 * - encountering a page with non-contiguous blocks
375 * then this code just gives up and calls the buffer_head-based read function.
376 * It does handle a page which has holes at the end - that is a common case:
377 * the end-of-file on blocksize < PAGE_CACHE_SIZE setups.
379 * BH_Boundary explanation:
381 * There is a problem. The mpage read code assembles several pages, gets all
382 * their disk mappings, and then submits them all. That's fine, but obtaining
383 * the disk mappings may require I/O. Reads of indirect blocks, for example.
385 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be
386 * submitted in the following order:
387 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16
388 * because the indirect block has to be read to get the mappings of blocks
389 * 13,14,15,16. Obviously, this impacts performance.
391 * So what we do it to allow the filesystem's get_block() function to set
392 * BH_Boundary when it maps block 11. BH_Boundary says: mapping of the block
393 * after this one will require I/O against a block which is probably close to
394 * this one. So you should push what I/O you have currently accumulated.
396 * This all causes the disk requests to be issued in the correct order.
399 mpage_readpages(struct address_space
*mapping
, struct list_head
*pages
,
400 unsigned nr_pages
, get_block_t get_block
)
402 struct bio
*bio
= NULL
;
404 sector_t last_block_in_bio
= 0;
405 struct pagevec lru_pvec
;
406 struct buffer_head map_bh
;
407 unsigned long first_logical_block
= 0;
409 clear_buffer_mapped(&map_bh
);
410 pagevec_init(&lru_pvec
, 0);
411 for (page_idx
= 0; page_idx
< nr_pages
; page_idx
++) {
412 struct page
*page
= list_entry(pages
->prev
, struct page
, lru
);
414 prefetchw(&page
->flags
);
415 list_del(&page
->lru
);
416 if (!add_to_page_cache(page
, mapping
,
417 page
->index
, GFP_KERNEL
)) {
418 bio
= do_mpage_readpage(bio
, page
,
420 &last_block_in_bio
, &map_bh
,
421 &first_logical_block
,
423 if (!pagevec_add(&lru_pvec
, page
))
424 __pagevec_lru_add(&lru_pvec
);
426 page_cache_release(page
);
429 pagevec_lru_add(&lru_pvec
);
430 BUG_ON(!list_empty(pages
));
432 mpage_bio_submit(READ
, bio
);
435 EXPORT_SYMBOL(mpage_readpages
);
438 * This isn't called much at all
440 int mpage_readpage(struct page
*page
, get_block_t get_block
)
442 struct bio
*bio
= NULL
;
443 sector_t last_block_in_bio
= 0;
444 struct buffer_head map_bh
;
445 unsigned long first_logical_block
= 0;
447 clear_buffer_mapped(&map_bh
);
448 bio
= do_mpage_readpage(bio
, page
, 1, &last_block_in_bio
,
449 &map_bh
, &first_logical_block
, get_block
);
451 mpage_bio_submit(READ
, bio
);
454 EXPORT_SYMBOL(mpage_readpage
);
457 * Writing is not so simple.
459 * If the page has buffers then they will be used for obtaining the disk
460 * mapping. We only support pages which are fully mapped-and-dirty, with a
461 * special case for pages which are unmapped at the end: end-of-file.
463 * If the page has no buffers (preferred) then the page is mapped here.
465 * If all blocks are found to be contiguous then the page can go into the
466 * BIO. Otherwise fall back to the mapping's writepage().
468 * FIXME: This code wants an estimate of how many pages are still to be
469 * written, so it can intelligently allocate a suitably-sized BIO. For now,
470 * just allocate full-size (16-page) BIOs.
473 __mpage_writepage(struct bio
*bio
, struct page
*page
, get_block_t get_block
,
474 sector_t
*last_block_in_bio
, int *ret
, struct writeback_control
*wbc
,
475 writepage_t writepage_fn
)
477 #if 0 // mask by Victor Yu. 02-12-2007
478 struct address_space
*mapping
= page
->mapping
;
479 struct inode
*inode
= page
->mapping
->host
;
481 struct address_space
*mapping
= page
->u
.xx
.mapping
;
482 struct inode
*inode
= page
->u
.xx
.mapping
->host
;
484 const unsigned blkbits
= inode
->i_blkbits
;
485 unsigned long end_index
;
486 const unsigned blocks_per_page
= PAGE_CACHE_SIZE
>> blkbits
;
488 sector_t block_in_file
;
489 sector_t blocks
[MAX_BUF_PER_PAGE
];
491 unsigned first_unmapped
= blocks_per_page
;
492 struct block_device
*bdev
= NULL
;
494 sector_t boundary_block
= 0;
495 struct block_device
*boundary_bdev
= NULL
;
497 struct buffer_head map_bh
;
498 loff_t i_size
= i_size_read(inode
);
500 if (page_has_buffers(page
)) {
501 struct buffer_head
*head
= page_buffers(page
);
502 struct buffer_head
*bh
= head
;
504 /* If they're all mapped and dirty, do it */
507 BUG_ON(buffer_locked(bh
));
508 if (!buffer_mapped(bh
)) {
510 * unmapped dirty buffers are created by
511 * __set_page_dirty_buffers -> mmapped data
513 if (buffer_dirty(bh
))
515 if (first_unmapped
== blocks_per_page
)
516 first_unmapped
= page_block
;
520 if (first_unmapped
!= blocks_per_page
)
521 goto confused
; /* hole -> non-hole */
523 if (!buffer_dirty(bh
) || !buffer_uptodate(bh
))
526 if (bh
->b_blocknr
!= blocks
[page_block
-1] + 1)
529 blocks
[page_block
++] = bh
->b_blocknr
;
530 boundary
= buffer_boundary(bh
);
532 boundary_block
= bh
->b_blocknr
;
533 boundary_bdev
= bh
->b_bdev
;
536 } while ((bh
= bh
->b_this_page
) != head
);
542 * Page has buffers, but they are all unmapped. The page was
543 * created by pagein or read over a hole which was handled by
544 * block_read_full_page(). If this address_space is also
545 * using mpage_readpages then this can rarely happen.
551 * The page has no buffers: map it to disk
553 BUG_ON(!PageUptodate(page
));
554 block_in_file
= (sector_t
)page
->index
<< (PAGE_CACHE_SHIFT
- blkbits
);
555 last_block
= (i_size
- 1) >> blkbits
;
556 map_bh
.b_page
= page
;
557 for (page_block
= 0; page_block
< blocks_per_page
; ) {
560 map_bh
.b_size
= 1 << blkbits
;
561 if (get_block(inode
, block_in_file
, &map_bh
, 1))
563 if (buffer_new(&map_bh
))
564 unmap_underlying_metadata(map_bh
.b_bdev
,
566 if (buffer_boundary(&map_bh
)) {
567 boundary_block
= map_bh
.b_blocknr
;
568 boundary_bdev
= map_bh
.b_bdev
;
571 if (map_bh
.b_blocknr
!= blocks
[page_block
-1] + 1)
574 blocks
[page_block
++] = map_bh
.b_blocknr
;
575 boundary
= buffer_boundary(&map_bh
);
576 bdev
= map_bh
.b_bdev
;
577 if (block_in_file
== last_block
)
581 BUG_ON(page_block
== 0);
583 first_unmapped
= page_block
;
586 end_index
= i_size
>> PAGE_CACHE_SHIFT
;
587 if (page
->index
>= end_index
) {
589 * The page straddles i_size. It must be zeroed out on each
590 * and every writepage invokation because it may be mmapped.
591 * "A file is mapped in multiples of the page size. For a file
592 * that is not a multiple of the page size, the remaining memory
593 * is zeroed when mapped, and writes to that region are not
594 * written out to the file."
596 unsigned offset
= i_size
& (PAGE_CACHE_SIZE
- 1);
599 if (page
->index
> end_index
|| !offset
)
601 kaddr
= kmap_atomic(page
, KM_USER0
);
602 memset(kaddr
+ offset
, 0, PAGE_CACHE_SIZE
- offset
);
603 flush_dcache_page(page
);
604 kunmap_atomic(kaddr
, KM_USER0
);
608 * This page will go to BIO. Do we need to send this BIO off first?
610 if (bio
&& *last_block_in_bio
!= blocks
[0] - 1)
611 bio
= mpage_bio_submit(WRITE
, bio
);
615 bio
= mpage_alloc(bdev
, blocks
[0] << (blkbits
- 9),
616 bio_get_nr_vecs(bdev
), GFP_NOFS
|__GFP_HIGH
);
622 * Must try to add the page before marking the buffer clean or
623 * the confused fail path above (OOM) will be very confused when
624 * it finds all bh marked clean (i.e. it will not write anything)
626 length
= first_unmapped
<< blkbits
;
627 if (bio_add_page(bio
, page
, length
, 0) < length
) {
628 bio
= mpage_bio_submit(WRITE
, bio
);
633 * OK, we have our BIO, so we can now mark the buffers clean. Make
634 * sure to only clean buffers which we know we'll be writing.
636 if (page_has_buffers(page
)) {
637 struct buffer_head
*head
= page_buffers(page
);
638 struct buffer_head
*bh
= head
;
639 unsigned buffer_counter
= 0;
642 if (buffer_counter
++ == first_unmapped
)
644 clear_buffer_dirty(bh
);
645 bh
= bh
->b_this_page
;
646 } while (bh
!= head
);
649 * we cannot drop the bh if the page is not uptodate
650 * or a concurrent readpage would fail to serialize with the bh
651 * and it would read from disk before we reach the platter.
653 if (buffer_heads_over_limit
&& PageUptodate(page
))
654 try_to_free_buffers(page
);
657 BUG_ON(PageWriteback(page
));
658 set_page_writeback(page
);
660 if (boundary
|| (first_unmapped
!= blocks_per_page
)) {
661 bio
= mpage_bio_submit(WRITE
, bio
);
662 if (boundary_block
) {
663 write_boundary_block(boundary_bdev
,
664 boundary_block
, 1 << blkbits
);
667 *last_block_in_bio
= blocks
[blocks_per_page
- 1];
673 bio
= mpage_bio_submit(WRITE
, bio
);
676 *ret
= (*writepage_fn
)(page
, wbc
);
682 * The caller has a ref on the inode, so *mapping is stable
686 set_bit(AS_ENOSPC
, &mapping
->flags
);
688 set_bit(AS_EIO
, &mapping
->flags
);
695 * mpage_writepages - walk the list of dirty pages of the given
696 * address space and writepage() all of them.
698 * @mapping: address space structure to write
699 * @wbc: subtract the number of written pages from *@wbc->nr_to_write
700 * @get_block: the filesystem's block mapper function.
701 * If this is NULL then use a_ops->writepage. Otherwise, go
704 * This is a library function, which implements the writepages()
705 * address_space_operation.
707 * If a page is already under I/O, generic_writepages() skips it, even
708 * if it's dirty. This is desirable behaviour for memory-cleaning writeback,
709 * but it is INCORRECT for data-integrity system calls such as fsync(). fsync()
710 * and msync() need to guarantee that all the data which was dirty at the time
711 * the call was made get new I/O started against them. If wbc->sync_mode is
712 * WB_SYNC_ALL then we were called for data integrity and we must wait for
713 * existing IO to complete.
715 * If you fix this you should check generic_writepages() also!
718 mpage_writepages(struct address_space
*mapping
,
719 struct writeback_control
*wbc
, get_block_t get_block
)
721 struct backing_dev_info
*bdi
= mapping
->backing_dev_info
;
722 struct bio
*bio
= NULL
;
723 sector_t last_block_in_bio
= 0;
726 int (*writepage
)(struct page
*page
, struct writeback_control
*wbc
);
730 pgoff_t end
; /* Inclusive */
734 if (wbc
->nonblocking
&& bdi_write_congested(bdi
)) {
735 wbc
->encountered_congestion
= 1;
740 if (get_block
== NULL
)
741 writepage
= mapping
->a_ops
->writepage
;
743 pagevec_init(&pvec
, 0);
744 if (wbc
->range_cyclic
) {
745 index
= mapping
->writeback_index
; /* Start from prev offset */
748 index
= wbc
->range_start
>> PAGE_CACHE_SHIFT
;
749 end
= wbc
->range_end
>> PAGE_CACHE_SHIFT
;
750 if (wbc
->range_start
== 0 && wbc
->range_end
== LLONG_MAX
)
755 while (!done
&& (index
<= end
) &&
756 (nr_pages
= pagevec_lookup_tag(&pvec
, mapping
, &index
,
758 min(end
- index
, (pgoff_t
)PAGEVEC_SIZE
-1) + 1))) {
762 for (i
= 0; i
< nr_pages
; i
++) {
763 struct page
*page
= pvec
.pages
[i
];
766 * At this point we hold neither mapping->tree_lock nor
767 * lock on the page itself: the page may be truncated or
768 * invalidated (changing page->mapping to NULL), or even
769 * swizzled back from swapper_space to tmpfs file
775 #if 0 // mask by Victor Yu. 02-12-2007
776 if (unlikely(page
->mapping
!= mapping
)) {
778 if (unlikely(page
->u
.xx
.mapping
!= mapping
)) {
784 if (!wbc
->range_cyclic
&& page
->index
> end
) {
790 if (wbc
->sync_mode
!= WB_SYNC_NONE
)
791 wait_on_page_writeback(page
);
793 if (PageWriteback(page
) ||
794 !clear_page_dirty_for_io(page
)) {
800 ret
= (*writepage
)(page
, wbc
);
810 #if 0 // mask by Victor Yu. 02-12-2007
811 bio
= __mpage_writepage(bio
, page
, get_block
,
812 &last_block_in_bio
, &ret
, wbc
,
813 page
->mapping
->a_ops
->writepage
);
815 bio
= __mpage_writepage(bio
, page
, get_block
,
816 &last_block_in_bio
, &ret
, wbc
,
817 page
->u
.xx
.mapping
->a_ops
->writepage
);
820 if (unlikely(ret
== AOP_WRITEPAGE_ACTIVATE
))
822 if (ret
|| (--(wbc
->nr_to_write
) <= 0))
824 if (wbc
->nonblocking
&& bdi_write_congested(bdi
)) {
825 wbc
->encountered_congestion
= 1;
829 pagevec_release(&pvec
);
832 if (!scanned
&& !done
) {
834 * We hit the last page and there is more work to be done: wrap
835 * back to the start of the file
841 if (wbc
->range_cyclic
|| (range_whole
&& wbc
->nr_to_write
> 0))
842 mapping
->writeback_index
= index
;
844 mpage_bio_submit(WRITE
, bio
);
847 EXPORT_SYMBOL(mpage_writepages
);
849 int mpage_writepage(struct page
*page
, get_block_t get_block
,
850 struct writeback_control
*wbc
)
854 sector_t last_block_in_bio
= 0;
856 bio
= __mpage_writepage(NULL
, page
, get_block
,
857 &last_block_in_bio
, &ret
, wbc
, NULL
);
859 mpage_bio_submit(WRITE
, bio
);
863 EXPORT_SYMBOL(mpage_writepage
);