Re: [PATCH] block: Fix a deadlock related freezing zoned storage devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/23/25 10:10, Damien Le Moal wrote:
> What about this patch, completely untested...
> 
>  diff --git a/block/blk-core.c b/block/blk-core.c
> index e8cc270a453f..3d2dec088a54 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -621,6 +621,32 @@ static inline blk_status_t blk_check_zone_append(struct
> request_queue *q,
>         return BLK_STS_OK;
>  }
> 
> +static inline void disk_submit_bio(struct bio *bio)
> +{
> +       struct gendisk *disk = bio->bi_bdev->bd_disk;
> +       bool need_queue_enter = !bio_zone_write_plugging(bio);
> +
> +       /*
> +        * BIOs that are issued from a zone write plug already hold a reference
> +        * on the device queue usage counter.
> +        */
> +       if (need_queue_enter) {
> +               if (unlikely(bio_queue_enter(bio)))
> +                       return;
> +       }
> +
> +       if ((bio->bi_opf & REQ_POLLED) &&
> +           !(disk->queue->limits.features & BLK_FEAT_POLL)) {
> +               bio->bi_status = BLK_STS_NOTSUPP;
> +               bio_endio(bio);
> +       } else {
> +               disk->fops->submit_bio(bio);
> +       }
> +
> +       if (need_queue_enter)
> +               blk_queue_exit(disk->queue);
> +}
> +
>  static void __submit_bio(struct bio *bio)
>  {
>         /* If plug is not used, add new plug here to cache nsecs time. */
> @@ -631,20 +657,10 @@ static void __submit_bio(struct bio *bio)
> 
>         blk_start_plug(&plug);
> 
> -       if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO)) {
> +       if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO))
>                 blk_mq_submit_bio(bio);
> -       } else if (likely(bio_queue_enter(bio) == 0)) {
> -               struct gendisk *disk = bio->bi_bdev->bd_disk;
> -
> -               if ((bio->bi_opf & REQ_POLLED) &&
> -                   !(disk->queue->limits.features & BLK_FEAT_POLL)) {
> -                       bio->bi_status = BLK_STS_NOTSUPP;
> -                       bio_endio(bio);
> -               } else {
> -                       disk->fops->submit_bio(bio);
> -               }
> -               blk_queue_exit(disk->queue);
> -       }
> +       else
> +               disk_submit_bio(bio)

Missing ";" here.
> 
>         blk_finish_plug(&plug);
>  }

Looking into this deeper, the regular mq path actually likely has the same issue
since it will call blk_queue_enter() if we do not have a cached request. So this
solution is only partial and not good enough. We need something else.

-- 
Damien Le Moal
Western Digital Research




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux