Thread (39 messages) read the whole thread 39 messages, 5 authors, 2022-01-19

Re: [PATCH 03/18] MM: use ->swap_rw for reads from SWP_FS_OPS swap-space

From: Mark Hemment <hidden>
Date: 2021-12-20 12:16:43
Also in: linux-nfs, lkml

On Thu, 16 Dec 2021 at 23:54, NeilBrown [off-list ref] wrote:
To submit an async read with ->swap_rw() we need to allocate
a structure to hold the kiocb and other details.  swap_readpage() cannot
handle transient failure, so create a mempool to provide the structures.

Signed-off-by: NeilBrown <redacted>
---
 mm/page_io.c  |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 mm/swap.h     |    1 +
 mm/swapfile.c |    5 +++++
 3 files changed, 58 insertions(+), 6 deletions(-)
...
quoted hunk ↗ jump to hunk
diff --git a/mm/swapfile.c b/mm/swapfile.c
index f23d9ff21cf8..43539be38e68 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2401,6 +2401,11 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
                if (ret < 0)
                        return ret;
                sis->flags |= SWP_ACTIVATED;
+               if ((sis->flags & SWP_FS_OPS) &&
+                   sio_pool_init() != 0) {
+                       destroy_swap_extents(sis);
+                       return -ENOMEM;
+               }
                return ret;
        }
This code is called before 'swapon_mutex' is taken in the swapon code
path, so possible for multiple swapons to race here creating two (or
more) memory pools.

Mark
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help