[dm-devel] [PATCH v4.9] dm: interlock pending dm_io and dm_wait_for_bios_completion

Greg Kroah-Hartman gregkh at linuxfoundation.org
Tue May 10 11:47:58 UTC 2022


On Tue, May 03, 2022 at 04:35:44PM -0400, Mikulas Patocka wrote:
> This is backport of the patch 9f6dc6337610 ("dm: interlock pending dm_io
> and dm_wait_for_bios_completion") for the kernel 4.9.
> 
> The bugs fixed by this patch can cause random crashing when reloading dm
> table, so it is eligible for stable backport.
> 
> Note that the kernel 4.9 uses md->pending to count the number of
> in-progress I/Os and md->pending is decremented after dm_stats_account_io,
> so the race condition doesn't really exist there (except for missing
> smp_rmb()).
> 
> The percpu variable md->pending_io is not needed in the stable kernels,
> because md->pending counts the same value, so it is not backported.
> 
> Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
> Reviewed-by: Mike Snitzer <snitzer at kernel.org>
> 
> ---
>  drivers/md/dm.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> Index: linux-stable/drivers/md/dm.c
> ===================================================================
> --- linux-stable.orig/drivers/md/dm.c	2022-04-30 19:03:08.000000000 +0200
> +++ linux-stable/drivers/md/dm.c	2022-04-30 19:03:46.000000000 +0200
> @@ -2027,6 +2027,8 @@ static int dm_wait_for_completion(struct
>  	}
>  	finish_wait(&md->wait, &wait);
>  
> +	smp_rmb(); /* paired with atomic_dec_return in end_io_acct */
> +
>  	return r;
>  }
>  
> 

All now queued up, thanks.

gre gk-h



More information about the dm-devel mailing list