[PATCH 4/8] mm: drop mmap_sem for swap read IO submission

From: Josef Bacik
Date: Tue Sep 25 2018 - 11:30:27 EST


From: Johannes Weiner <jweiner@xxxxxx>

We don't need to hold the mmap_sem while we're doing the IO, simply drop
it and retry appropriately.

Signed-off-by: Johannes Weiner <jweiner@xxxxxx>
Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
mm/page_io.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/mm/page_io.c b/mm/page_io.c
index aafd19ec1db4..bf21b56a964e 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -365,6 +365,20 @@ int swap_readpage(struct page *page, bool synchronous)
goto out;
}

+ /*
+ * XXX:
+ *
+ * Propagate mm->mmap_sem into this function. Then:
+ *
+ * get_file(sis->swap_file)
+ * up_read(mm->mmap_sem)
+ * submit io request
+ * fput
+ *
+ * After mmap_sem is dropped, sis is no longer valid. Go
+ * through swap_file->blah->bdev.
+ */
+
if (sis->flags & SWP_FILE) {
struct file *swap_file = sis->swap_file;
struct address_space *mapping = swap_file->f_mapping;
--
2.14.3