On 25.06.25 11:44, Damien Le Moal wrote:
> static inline bool bio_needs_zone_write_plugging(struct bio *bio)
> +{
> + enum req_op op = bio_op(bio);
> +
> + /*
> + * Only zoned block devices have a zone write plug hash table. But not
> + * all of them have one (e.g. DM devices may not need one).
> + */
> + if (!bio->bi_bdev->bd_disk->zone_wplugs_hash)
> + return false;
> +
> + /* Only write operations need zone write plugging. */
> + if (!op_is_write(op))
> + return false;
> +
> + /* Ignore empty flush */
> + if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
> + return false;
> +
> + /* Ignore BIOs that already have been handled by zone write plugging. */
> + if (bio_flagged(bio, BIO_ZONE_WRITE_PLUGGING))
> + return false;
> +
> + /*
> + * All zone write operations must be handled through zone write plugging
> + * using blk_zone_plug_bio().
> + */
> + switch (op) {
> + case REQ_OP_ZONE_APPEND:
> + case REQ_OP_WRITE:
> + case REQ_OP_WRITE_ZEROES:
> + case REQ_OP_ZONE_FINISH:
> + case REQ_OP_ZONE_RESET:
> + case REQ_OP_ZONE_RESET_ALL:
> + return true;
> + default:
> + return false;
> + }
Maybe this is bikeshedding territory here but I'd move the long pointer
chase 'bio->bi_bdev->bd_disk->zone_wplugs_hash' later into the function.
At least after the op_is_write() check, so that reads don't get the
pointer chase.