diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-02-26 14:09:20 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-02-26 14:09:20 -0500 |
commit | 168fc0223c0e944957b1f31d88c2334fc904baf1 (patch) | |
tree | 1768f86cca5cef5ae1ba2275fca7ea9f0c0630d5 /fs/ext4 | |
parent | 78aaced3408141bb7c836f2db0ca435790399da5 (diff) |
ext4: move setup of the mpd structure to write_cache_pages_da()
Move the initialization of all of the fields of the mpd structure to
write_cache_pages_da(). This simplifies the code considerably.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/inode.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c2e6af338234..dcc2287433b6 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2714,7 +2714,8 @@ static int ext4_da_writepages_trans_blocks(struct inode *inode) | |||
2714 | /* | 2714 | /* |
2715 | * write_cache_pages_da - walk the list of dirty pages of the given | 2715 | * write_cache_pages_da - walk the list of dirty pages of the given |
2716 | * address space and accumulate pages that need writing, and call | 2716 | * address space and accumulate pages that need writing, and call |
2717 | * mpage_da_map_and_submit to map the pages and then write them. | 2717 | * mpage_da_map_and_submit to map a single contiguous memory region |
2718 | * and then write them. | ||
2718 | */ | 2719 | */ |
2719 | static int write_cache_pages_da(struct address_space *mapping, | 2720 | static int write_cache_pages_da(struct address_space *mapping, |
2720 | struct writeback_control *wbc, | 2721 | struct writeback_control *wbc, |
@@ -2722,7 +2723,7 @@ static int write_cache_pages_da(struct address_space *mapping, | |||
2722 | pgoff_t *done_index) | 2723 | pgoff_t *done_index) |
2723 | { | 2724 | { |
2724 | struct buffer_head *bh, *head; | 2725 | struct buffer_head *bh, *head; |
2725 | struct inode *inode = mpd->inode; | 2726 | struct inode *inode = mapping->host; |
2726 | struct pagevec pvec; | 2727 | struct pagevec pvec; |
2727 | unsigned int nr_pages; | 2728 | unsigned int nr_pages; |
2728 | sector_t logical; | 2729 | sector_t logical; |
@@ -2730,6 +2731,9 @@ static int write_cache_pages_da(struct address_space *mapping, | |||
2730 | long nr_to_write = wbc->nr_to_write; | 2731 | long nr_to_write = wbc->nr_to_write; |
2731 | int i, tag, ret = 0; | 2732 | int i, tag, ret = 0; |
2732 | 2733 | ||
2734 | memset(mpd, 0, sizeof(struct mpage_da_data)); | ||
2735 | mpd->wbc = wbc; | ||
2736 | mpd->inode = inode; | ||
2733 | pagevec_init(&pvec, 0); | 2737 | pagevec_init(&pvec, 0); |
2734 | index = wbc->range_start >> PAGE_CACHE_SHIFT; | 2738 | index = wbc->range_start >> PAGE_CACHE_SHIFT; |
2735 | end = wbc->range_end >> PAGE_CACHE_SHIFT; | 2739 | end = wbc->range_end >> PAGE_CACHE_SHIFT; |
@@ -2794,16 +2798,8 @@ static int write_cache_pages_da(struct address_space *mapping, | |||
2794 | 2798 | ||
2795 | BUG_ON(PageWriteback(page)); | 2799 | BUG_ON(PageWriteback(page)); |
2796 | 2800 | ||
2797 | if (mpd->next_page != page->index) { | 2801 | if (mpd->next_page != page->index) |
2798 | /* | ||
2799 | * Start next extent of pages and blocks | ||
2800 | */ | ||
2801 | mpd->first_page = page->index; | 2802 | mpd->first_page = page->index; |
2802 | mpd->b_size = 0; | ||
2803 | mpd->b_state = 0; | ||
2804 | mpd->b_blocknr = 0; | ||
2805 | } | ||
2806 | |||
2807 | mpd->next_page = page->index + 1; | 2803 | mpd->next_page = page->index + 1; |
2808 | logical = (sector_t) page->index << | 2804 | logical = (sector_t) page->index << |
2809 | (PAGE_CACHE_SHIFT - inode->i_blkbits); | 2805 | (PAGE_CACHE_SHIFT - inode->i_blkbits); |
@@ -2975,9 +2971,6 @@ static int ext4_da_writepages(struct address_space *mapping, | |||
2975 | wbc->nr_to_write = desired_nr_to_write; | 2971 | wbc->nr_to_write = desired_nr_to_write; |
2976 | } | 2972 | } |
2977 | 2973 | ||
2978 | mpd.wbc = wbc; | ||
2979 | mpd.inode = mapping->host; | ||
2980 | |||
2981 | retry: | 2974 | retry: |
2982 | if (wbc->sync_mode == WB_SYNC_ALL) | 2975 | if (wbc->sync_mode == WB_SYNC_ALL) |
2983 | tag_pages_for_writeback(mapping, index, end); | 2976 | tag_pages_for_writeback(mapping, index, end); |
@@ -3008,14 +3001,6 @@ retry: | |||
3008 | * contiguous region of logical blocks that need | 3001 | * contiguous region of logical blocks that need |
3009 | * blocks to be allocated by ext4 and submit them. | 3002 | * blocks to be allocated by ext4 and submit them. |
3010 | */ | 3003 | */ |
3011 | mpd.b_size = 0; | ||
3012 | mpd.b_state = 0; | ||
3013 | mpd.b_blocknr = 0; | ||
3014 | mpd.first_page = 0; | ||
3015 | mpd.next_page = 0; | ||
3016 | mpd.io_done = 0; | ||
3017 | mpd.pages_written = 0; | ||
3018 | mpd.retval = 0; | ||
3019 | ret = write_cache_pages_da(mapping, wbc, &mpd, &done_index); | 3004 | ret = write_cache_pages_da(mapping, wbc, &mpd, &done_index); |
3020 | /* | 3005 | /* |
3021 | * If we have a contiguous extent of pages and we | 3006 | * If we have a contiguous extent of pages and we |