Lines Matching refs:mpd

1547 static void mpage_release_unused_pages(struct mpage_da_data *mpd,
1553 struct inode *inode = mpd->inode;
1557 if (mpd->first_page >= mpd->next_page)
1560 mpd->scanned_until_end = 0;
1561 index = mpd->first_page;
1562 end = mpd->next_page - 1;
2106 static int mpage_submit_page(struct mpage_da_data *mpd, struct page *page)
2112 BUG_ON(page->index != mpd->first_page);
2127 size = i_size_read(mpd->inode);
2129 !ext4_verity_in_progress(mpd->inode))
2133 err = ext4_bio_write_page(&mpd->io_submit, page, len, mpd->wbc, false);
2135 mpd->wbc->nr_to_write--;
2136 mpd->first_page++;
2153 * @mpd - extent of blocks
2164 static bool mpage_add_bh_to_extent(struct mpage_da_data *mpd, ext4_lblk_t lblk,
2167 struct ext4_map_blocks *map = &mpd->map;
2181 if (!mpd->do_map)
2205 * @mpd - extent of blocks for mapping
2218 static int mpage_process_page_bufs(struct mpage_da_data *mpd,
2223 struct inode *inode = mpd->inode;
2234 if (lblk >= blocks || !mpage_add_bh_to_extent(mpd, lblk, bh)) {
2236 if (mpd->map.m_len)
2239 if (!mpd->do_map)
2246 if (mpd->map.m_len == 0) {
2247 err = mpage_submit_page(mpd, head->b_page);
2252 mpd->scanned_until_end = 1;
2262 * @mpd - description of extent to map, on return next extent to map
2273 static int mpage_process_page(struct mpage_da_data *mpd, struct page *page,
2278 ext4_io_end_t *io_end = mpd->io_submit.io_end;
2282 int blkbits = mpd->inode->i_blkbits;
2288 if (lblk < mpd->map.m_lblk)
2290 if (lblk >= mpd->map.m_lblk + mpd->map.m_len) {
2295 mpd->map.m_len = 0;
2296 mpd->map.m_flags = 0;
2300 err = mpage_process_page_bufs(mpd, head, bh, lblk);
2303 if (!err && mpd->map.m_len && mpd->map.m_lblk > lblk) {
2309 io_end_vec->offset = (loff_t)mpd->map.m_lblk << blkbits;
2335 * @mpd - description of extent to map, on return next extent to map
2345 static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
2349 struct inode *inode = mpd->inode;
2357 start = mpd->map.m_lblk >> bpp_bits;
2358 end = (mpd->map.m_lblk + mpd->map.m_len - 1) >> bpp_bits;
2360 pblock = mpd->map.m_pblk;
2371 err = mpage_process_page(mpd, page, &lblk, &pblock,
2381 err = mpage_submit_page(mpd, page);
2388 mpd->map.m_len = 0;
2389 mpd->map.m_flags = 0;
2396 static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd)
2398 struct inode *inode = mpd->inode;
2399 struct ext4_map_blocks *map = &mpd->map;
2432 if (!mpd->io_submit.io_end->handle &&
2434 mpd->io_submit.io_end->handle = handle->h_rsv_handle;
2437 ext4_set_io_unwritten_flag(inode, mpd->io_submit.io_end);
2445 * mpage_map_and_submit_extent - map extent starting at mpd->lblk of length
2446 * mpd->len and submit pages underlying it for IO
2449 * @mpd - extent to map
2454 * The function maps extent starting at mpd->lblk of length mpd->len. If it is
2465 struct mpage_da_data *mpd,
2468 struct inode *inode = mpd->inode;
2469 struct ext4_map_blocks *map = &mpd->map;
2473 ext4_io_end_t *io_end = mpd->io_submit.io_end;
2481 err = mpage_map_one_extent(handle, mpd);
2520 err = mpage_map_and_submit_buffers(mpd);
2530 disksize = ((loff_t)mpd->first_page) << PAGE_SHIFT;
2573 * @mpd - where to look for pages
2579 * these buffers. The extent found is returned in @mpd structure (starting at
2580 * mpd->lblk with length mpd->len blocks).
2587 static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
2589 struct address_space *mapping = mpd->inode->i_mapping;
2592 long left = mpd->wbc->nr_to_write;
2593 pgoff_t index = mpd->first_page;
2594 pgoff_t end = mpd->last_page;
2597 int blkbits = mpd->inode->i_blkbits;
2601 if (mpd->wbc->sync_mode == WB_SYNC_ALL || mpd->wbc->tagged_writepages)
2607 mpd->map.m_len = 0;
2608 mpd->next_page = index;
2626 if (mpd->wbc->sync_mode == WB_SYNC_NONE && left <= 0)
2630 if (mpd->map.m_len > 0 && mpd->next_page != page->index)
2643 (mpd->wbc->sync_mode == WB_SYNC_NONE)) ||
2668 ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index);
2674 if (mpd->map.m_len == 0)
2675 mpd->first_page = page->index;
2676 mpd->next_page = page->index + 1;
2677 /* Add all dirty buffers to mpd */
2681 err = mpage_process_page_bufs(mpd, head, head, lblk);
2690 mpd->scanned_until_end = 1;
2705 struct mpage_da_data mpd;
2781 mpd.first_page = writeback_index;
2782 mpd.last_page = -1;
2784 mpd.first_page = wbc->range_start >> PAGE_SHIFT;
2785 mpd.last_page = wbc->range_end >> PAGE_SHIFT;
2788 mpd.inode = inode;
2789 mpd.wbc = wbc;
2790 ext4_io_submit_init(&mpd.io_submit, wbc);
2793 tag_pages_for_writeback(mapping, mpd.first_page, mpd.last_page);
2802 mpd.do_map = 0;
2803 mpd.scanned_until_end = 0;
2804 mpd.io_submit.io_end = ext4_init_io_end(inode, GFP_KERNEL);
2805 if (!mpd.io_submit.io_end) {
2809 ret = mpage_prepare_extent_to_map(&mpd);
2811 mpage_release_unused_pages(&mpd, false);
2813 ext4_io_submit(&mpd.io_submit);
2814 ext4_put_io_end_defer(mpd.io_submit.io_end);
2815 mpd.io_submit.io_end = NULL;
2819 while (!mpd.scanned_until_end && wbc->nr_to_write > 0) {
2821 mpd.io_submit.io_end = ext4_init_io_end(inode, GFP_KERNEL);
2822 if (!mpd.io_submit.io_end) {
2846 ext4_put_io_end(mpd.io_submit.io_end);
2847 mpd.io_submit.io_end = NULL;
2850 mpd.do_map = 1;
2852 trace_ext4_da_write_pages(inode, mpd.first_page, mpd.wbc);
2853 ret = mpage_prepare_extent_to_map(&mpd);
2854 if (!ret && mpd.map.m_len)
2855 ret = mpage_map_and_submit_extent(handle, &mpd,
2870 mpd.do_map = 0;
2873 mpage_release_unused_pages(&mpd, give_up_on_write);
2875 ext4_io_submit(&mpd.io_submit);
2885 ext4_put_io_end_defer(mpd.io_submit.io_end);
2888 ext4_put_io_end(mpd.io_submit.io_end);
2889 mpd.io_submit.io_end = NULL;
2909 mpd.last_page = writeback_index - 1;
2910 mpd.first_page = 0;
2920 mapping->writeback_index = mpd.first_page;