lkml.org 
[lkml]   [2021]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 03/18] MM: use ->swap_rw for reads from SWP_FS_OPS swap-space
On Thu, 16 Dec 2021 at 23:54, NeilBrown <neilb@suse.de> 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 <neilb@suse.de>
> ---
> mm/page_io.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------
> mm/swap.h | 1 +
> mm/swapfile.c | 5 +++++
> 3 files changed, 58 insertions(+), 6 deletions(-)
...
> 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

\
 
 \ /
  Last update: 2021-12-20 13:17    [W:0.252 / U:1.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site