Skip to content

Commit 765dad0

Browse files
Marcelo TosattiLinus Torvalds
authored andcommitted
[PATCH] small wait_on_page_writeback_range() optimization
filemap_fdatawait() calls wait_on_page_writeback_range() with -1 as "end" parameter. This is not needed since we know the EOF from the inode. Use that instead. Signed-off-by: Marcelo Tosatti <marcelo.tosatti@cyclades.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 6043ddd commit 765dad0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎mm/filemap.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,13 @@ EXPORT_SYMBOL(sync_page_range);
287287
*/
288288
int filemap_fdatawait(struct address_space *mapping)
289289
{
290-
return wait_on_page_writeback_range(mapping, 0, -1);
290+
loff_t i_size = i_size_read(mapping->host);
291+
292+
if (i_size == 0)
293+
return 0;
294+
295+
return wait_on_page_writeback_range(mapping, 0,
296+
(i_size - 1) >> PAGE_CACHE_SHIFT);
291297
}
292298
EXPORT_SYMBOL(filemap_fdatawait);
293299

0 commit comments

Comments
 (0)