[Devel] [PATCH RH9] dm-ploop: Fix usage of bio_vec on stack

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Tue Oct 26 16:51:48 MSK 2021


With this applied, the crash while creating ubuntu-20.04 template can be no longer reproduced.

Tested-By: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>

> Previously, writing BAT page was synchronous, so
> we could use on-stack bio_vec for that.
> But after it became asynchronous, we can't do that.
> Strange, this has not fired earlier.
> 
> https://jira.sw.ru/browse/PSBM-135137
> Fixes: bfc5eaaba897 "ploop: Async md writeback"
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>   drivers/md/dm-ploop-map.c |   12 ++++++------
>   drivers/md/dm-ploop.h     |    1 +
>   2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
> index 4cadf6e45b4d..a558445a1bec 100644
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -1595,17 +1595,17 @@ void ploop_index_wb_submit(struct ploop *ploop, struct ploop_index_wb *piwb)
>   {
>   	loff_t pos = (loff_t)piwb->page_id << PAGE_SHIFT;
>   	struct pio *pio = piwb->pio;
> -	struct bio_vec bvec = {
> -		.bv_page = piwb->bat_page,
> -		.bv_len = PAGE_SIZE,
> -		.bv_offset = 0,
> -	};
> +	struct bio_vec *bvec = &piwb->aux_bvec;
> +
> +	bvec->bv_page = piwb->bat_page;
> +	bvec->bv_len = PAGE_SIZE;
> +	bvec->bv_offset = 0;
>   
>   	pio->bi_iter.bi_sector = to_sector(pos);
>   	pio->bi_iter.bi_size = PAGE_SIZE;
>   	pio->bi_iter.bi_idx = 0;
>   	pio->bi_iter.bi_bvec_done = 0;
> -	pio->bi_io_vec = &bvec;
> +	pio->bi_io_vec = bvec;
>   	pio->level = top_level(ploop);
>   	pio->endio_cb = md_write_endio;
>   	pio->endio_cb_data = piwb;
> diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
> index a7ca942c4670..0a4c6b78e20e 100644
> --- a/drivers/md/dm-ploop.h
> +++ b/drivers/md/dm-ploop.h
> @@ -106,6 +106,7 @@ struct ploop_index_wb {
>   	bool completed;
>   	blk_status_t bi_status;
>   	u32 page_id;
> +	struct bio_vec aux_bvec;
>   };
>   
>   /* Metadata page */
> 
> 



More information about the Devel mailing list