Re: [PATCH 4/4] block: move plug rq alloc into helper and ensure queue match

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

 



On 11/4/21 3:17 AM, Christoph Hellwig wrote:
> On Wed, Nov 03, 2021 at 12:32:22PM -0600, Jens Axboe wrote:
>> +	if (plug && !rq_list_empty(plug->cached_rq)) {
>> +		rq = rq_list_peek(&plug->cached_rq);
> 
> No need for the empty check plus peek.  This could be simplified
> down to:
> 
> 	if (!plug)
> 		return NULL;
> 	rq = rq_list_peek(&plug->cached_rq);
> 	if (!rq || rq->q != q)
> 		return NULL;
> 
> 	rq_qos_throttle(q, bio);
> 	plug->cached_rq = rq_list_next(rq);
> 	INIT_LIST_HEAD(&rq->queuelist);
> 	return rq;

I tend to prefer having logic flow from the expected conditions. And
since we need to check if the plug is valid anyway, I prefer the current
logic.

-- 
Jens Axboe




[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