Simplify the callers by moving the check for nr_pages and the BUG_ON into read_pages().
Unified · Split
| @@ -119,6 +119,9 @@ static void read_pages(struct address_space *mapping, struct file *filp, · 118 unmodified lines | |||
| 119 | struct blk_plug plug; | 119 | struct blk_plug plug; |
| 120 | unsigned page_idx; | 120 | unsigned page_idx; |
| 121 | 121 | ||
| 122 | if (!nr_pages) | ||
| 123 | return; | ||
| 124 | |||
| 122 | blk_start_plug(&plug); | 125 | blk_start_plug(&plug); |
| 123 | 126 | ||
| 124 | if (mapping->a_ops->readpages) { | 127 | if (mapping->a_ops->readpages) { |
| @@ -138,6 +141,8 @@ static void read_pages(struct address_space *mapping, struct file *filp, · 13 unmodified lines | |||
| 138 | 141 | ||
| 139 | out: | 142 | out: |
| 140 | blk_finish_plug(&plug); | 143 | blk_finish_plug(&plug); |
| 144 | |||
| 145 | BUG_ON(!list_empty(pages)); | ||
| 141 | } | 146 | } |
| 142 | 147 | ||
| 143 | /* | 148 | /* |
| @@ -180,8 +185,7 @@ void __do_page_cache_readahead(struct address_space *mapping, · 36 unmodified lines | |||
| 180 | * contiguous pages before continuing with the next | 185 | * contiguous pages before continuing with the next |
| 181 | * batch. | 186 | * batch. |
| 182 | */ | 187 | */ |
| 183 | if (nr_pages) | 188 | read_pages(mapping, filp, &page_pool, nr_pages, |
| 184 | read_pages(mapping, filp, &page_pool, nr_pages, | ||
| 185 | gfp_mask); | 189 | gfp_mask); |
| 186 | nr_pages = 0; | 190 | nr_pages = 0; |
| 187 | continue; | 191 | continue; |
| @@ -202,9 +206,7 @@ void __do_page_cache_readahead(struct address_space *mapping, · 14 unmodified lines | |||
| 202 | * uptodate then the caller will launch readpage again, and | 206 | * uptodate then the caller will launch readpage again, and |
| 203 | * will then handle the error. | 207 | * will then handle the error. |
| 204 | */ | 208 | */ |
| 205 | if (nr_pages) | 209 | read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask); |
| 206 | read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask); | ||
| 207 | BUG_ON(!list_empty(&page_pool)); | ||
| 208 | } | 210 | } |
| 209 | 211 | ||
| 210 | /* | 212 | /* |