Skip to content

Commit e5dbd33

Browse files
Matthew Wilcox (Oracle)dhowells
authored andcommitted
mm/writeback: Add wait_on_page_writeback_killable
This is the killable version of wait_on_page_writeback. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: kafs-testing@auristor.com cc: linux-afs@lists.infradead.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/20210320054104.1300774-3-willy@infradead.org
1 parent 39f985c commit e5dbd33

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

include/linux/pagemap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ static inline int wait_on_page_locked_killable(struct page *page)
682682

683683
int put_and_wait_on_page_locked(struct page *page, int state);
684684
void wait_on_page_writeback(struct page *page);
685+
int wait_on_page_writeback_killable(struct page *page);
685686
extern void end_page_writeback(struct page *page);
686687
void wait_for_stable_page(struct page *page);
687688

mm/page-writeback.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,22 @@ void wait_on_page_writeback(struct page *page)
28332833
}
28342834
EXPORT_SYMBOL_GPL(wait_on_page_writeback);
28352835

2836+
/*
2837+
* Wait for a page to complete writeback. Returns -EINTR if we get a
2838+
* fatal signal while waiting.
2839+
*/
2840+
int wait_on_page_writeback_killable(struct page *page)
2841+
{
2842+
while (PageWriteback(page)) {
2843+
trace_wait_on_page_writeback(page, page_mapping(page));
2844+
if (wait_on_page_bit_killable(page, PG_writeback))
2845+
return -EINTR;
2846+
}
2847+
2848+
return 0;
2849+
}
2850+
EXPORT_SYMBOL_GPL(wait_on_page_writeback_killable);
2851+
28362852
/**
28372853
* wait_for_stable_page() - wait for writeback to finish, if necessary.
28382854
* @page: The page to wait on.

0 commit comments

Comments
 (0)