# \[PATCHv2 17/41\] filemap: handle huge pages in filemap\_fdatawait\_range()

- From: Kirill A. Shutemov \<hidden\>
- Date: 2016-08-12 18:38:00 
- List: linux-block
- Page: https://ratatoskr.run/linux-block/2016/08/111380
- Thread: https://ratatoskr.run/linux-ext4/2016/08/110976/t.md

```text
We writeback whole huge page a time.

Signed-off-by: Kirill A. Shutemov <redacted>
---
 mm/filemap.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/filemap.c b/mm/filemap.c
index 93fa97f143ab..429f9a0962b3 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -372,9 +372,14 @@ static int __filemap_fdatawait_range(struct address_space *mapping,
 			if (page->index > end)
 				continue;
 
+			page = compound_head(page);
 			wait_on_page_writeback(page);
 			if (TestClearPageError(page))
 				ret = -EIO;
+			if (PageTransHuge(page)) {
+				index = page->index + HPAGE_PMD_NR;
+				i += index - pvec.pages[i]->index - 1;
+			}
 		}
 		pagevec_release(&pvec);
 		cond_resched();
-- 
2.8.1

```
