[PATCH v5 02/28] mm: Add wait_on_page_writeback_killable()
David Howells
dhowells at redhat.com
Tue Mar 23 22:17:52 GMT 2021
Add a function to wait killably on the PG_writeback page flag.
Signed-off-by: David Howells <dhowells at redhat.com>
cc: Matthew Wilcox (Oracle) <willy at infradead.org>
cc: Alexander Viro <viro at zeniv.linux.org.uk>
cc: Christoph Hellwig <hch at lst.de>
cc: linux-mm at kvack.org
cc: linux-cachefs at redhat.com
cc: linux-afs at lists.infradead.org
cc: linux-nfs at vger.kernel.org
cc: linux-cifs at vger.kernel.org
cc: ceph-devel at vger.kernel.org
cc: v9fs-developer at lists.sourceforge.net
cc: linux-fsdevel at vger.kernel.org
---
include/linux/pagemap.h | 1 +
mm/page-writeback.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 20225b067583..444155ae56c0 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -683,6 +683,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);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index eb34d204d4ee..b8bad275f94b 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2833,6 +2833,31 @@ void wait_on_page_writeback(struct page *page)
}
EXPORT_SYMBOL_GPL(wait_on_page_writeback);
+/**
+ * Wait for a page to complete writeback
+ * @page: The page to wait on
+ *
+ * Wait for the writeback status of a page to clear or a fatal signal to occur.
+ *
+ * Return:
+ * - 0 on success.
+ * - -EINTR if a fatal signal was encountered.
+ */
+int wait_on_page_writeback_killable(struct page *page)
+{
+ int ret = 0;
+
+ while (PageWriteback(page)) {
+ trace_wait_on_page_writeback(page, page_mapping(page));
+ ret = wait_on_page_bit_killable(page, PG_writeback);
+ if (ret < 0)
+ break;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(wait_on_page_writeback_killable);
+
/**
* wait_for_stable_page() - wait for writeback to finish, if necessary.
* @page: The page to wait on.
More information about the linux-afs
mailing list