Skip to content

Commit

Permalink
mm/writeback: Add wait_on_page_writeback_killable
Browse files Browse the repository at this point in the history
This is the killable version of wait_on_page_writeback.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: David Howells <[email protected]>
Tested-by: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Matthew Wilcox (Oracle) authored and dhowells committed Mar 23, 2021
1 parent 39f985c commit e5dbd33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/pagemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ static inline int wait_on_page_locked_killable(struct page *page)

int put_and_wait_on_page_locked(struct page *page, int state);
void wait_on_page_writeback(struct page *page);
int wait_on_page_writeback_killable(struct page *page);
extern void end_page_writeback(struct page *page);
void wait_for_stable_page(struct page *page);

Expand Down
16 changes: 16 additions & 0 deletions mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -2833,6 +2833,22 @@ void wait_on_page_writeback(struct page *page)
}
EXPORT_SYMBOL_GPL(wait_on_page_writeback);

/*
* Wait for a page to complete writeback. Returns -EINTR if we get a
* fatal signal while waiting.
*/
int wait_on_page_writeback_killable(struct page *page)
{
while (PageWriteback(page)) {
trace_wait_on_page_writeback(page, page_mapping(page));
if (wait_on_page_bit_killable(page, PG_writeback))
return -EINTR;
}

return 0;
}
EXPORT_SYMBOL_GPL(wait_on_page_writeback_killable);

/**
* wait_for_stable_page() - wait for writeback to finish, if necessary.
* @page: The page to wait on.
Expand Down

0 comments on commit e5dbd33

Please sign in to comment.