Re: [PATCH 2/2] block: store bdev->bd_disk->fops->submit_bio state in bdev

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

 



On 4/14/23 8:43?PM, Damien Le Moal wrote:
> On 4/14/23 22:48, Jens Axboe wrote:
>> We have a long chain of memory dereferencing just to whether or not
>> this disk has a special submit_bio helper. As that's not necessarily
>> the common case, add a bd_submit_bio state in the bdev to avoid
>> traversing this memory dependency chain if we don't need to.
>>
>> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
>> ---
>>  block/bdev.c              | 1 +
>>  block/blk-core.c          | 8 ++++----
>>  block/genhd.c             | 4 ++++
>>  include/linux/blk_types.h | 1 +
>>  4 files changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/block/bdev.c b/block/bdev.c
>> index 1795c7d4b99e..31a5d25b2b44 100644
>> --- a/block/bdev.c
>> +++ b/block/bdev.c
>> @@ -419,6 +419,7 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)
>>  	bdev->bd_inode = inode;
>>  	bdev->bd_queue = disk->queue;
>>  	bdev->bd_stats = alloc_percpu(struct disk_stats);
>> +	bdev->bd_submit_bio = 0;
> 
> "= false;" would be better to match bd_submit_bio type.

Done

>> diff --git a/block/genhd.c b/block/genhd.c
>> index 02d9cfb9e077..07736c5db988 100644
>> --- a/block/genhd.c
>> +++ b/block/genhd.c
>> @@ -420,6 +420,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
>>  	 */
>>  	elevator_init_mq(disk->queue);
>>  
>> +	/* Mark bdev as having a submit_bio, if needed */
>> +	if (disk->fops->submit_bio)
>> +		disk->part0->bd_submit_bio = 1;
> 
> "= true;" would be better to match the type.
> 
> Note that this could also be:
> 
> disk->part0->bd_submit_bio = disk->fops->submit_bio;
> 
> thus removing the if.

I made it:

disk->part0->bd_submit_bio = disk->fops->submit_bio != NULL;

instead to make it explicit, I don't think that assignment would be
happy otherwise.

-- 
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