History

mm: move readahead nr_pages check into read_pages

Simplify the callers by moving the check for nr_pages and the BUG_ON into read_pages().

Matthew Wilcox (Oracle) committed 6 years ago

Commit ad4ae1c1 parent a1ef8561 file · +7 −5Browse files

Unified · Split

mm/readahead.c+7−5
@@ -119,6 +119,9 @@ static void read_pages(struct address_space *mapping, struct file *filp, · 118 unmodified lines
119119 struct blk_plug plug;
120120 unsigned page_idx;
121121
122+ if (!nr_pages)
123+ return;
124+
122125 blk_start_plug(&plug);
123126
124127 if (mapping->a_ops->readpages) {
@@ -138,6 +141,8 @@ static void read_pages(struct address_space *mapping, struct file *filp, · 13 unmodified lines
138141
139142 out:
140143 blk_finish_plug(&plug);
144+
145+ BUG_ON(!list_empty(pages));
141146 }
142147
143148 /*
@@ -180,8 +185,7 @@ void __do_page_cache_readahead(struct address_space *mapping, · 36 unmodified lines
180185 * contiguous pages before continuing with the next
181186 * batch.
182187 */
183− if (nr_pages)
184− read_pages(mapping, filp, &page_pool, nr_pages,
188+ read_pages(mapping, filp, &page_pool, nr_pages,
185189 gfp_mask);
186190 nr_pages = 0;
187191 continue;
@@ -202,9 +206,7 @@ void __do_page_cache_readahead(struct address_space *mapping, · 14 unmodified lines
202206 * uptodate then the caller will launch readpage again, and
203207 * will then handle the error.
204208 */
205− if (nr_pages)
206− read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask);
207− BUG_ON(!list_empty(&page_pool));
209+ read_pages(mapping, filp, &page_pool, nr_pages, gfp_mask);
208210 }
209211
210212 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t