Re: [PATCH v3 2/5] block: Introduce bio_needs_zone_write_plugging()

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

 



On 6/25/25 4:38 PM, Damien Le Moal wrote:
On 6/26/25 00:48, Bart Van Assche wrote:
On 6/25/25 2:33 AM, Damien Le Moal wrote:
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4806b867e37d..0c61492724d2 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3169,8 +3169,10 @@ void blk_mq_submit_bio(struct bio *bio)
   	if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
   		goto queue_exit;
- if (blk_queue_is_zoned(q) && blk_zone_plug_bio(bio, nr_segs))
-		goto queue_exit;
+	if (bio_needs_zone_write_plugging(bio)) {
+		if (blk_zone_plug_bio(bio, nr_segs))
+			goto queue_exit;
+	}

Why nested if-statements instead of keeping "&&"? I prefer "&&".

I did this because bio_needs_zone_write_plugging() is inline and
blk_zone_plug_bio() is not, so this ensures that we do not have the function
call for nothing. Though I may be overthinking this since normally, the
generated assembler will not test the second part of a && condition if the first
part is false already.

From a (draft version of) the C standard, section "6.5.14 Logical AND
operator": "If the first operand compares equal to 0, the second operand is not evaluated." I think that text was already present in the
K&R C book.

See also https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf.

Thanks,

Bart.




[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