On 4/26/21 9:12 PM, Changheun Lee wrote:
Actually I checked "bio->bi_disk" at first as below. It works well.
Agreed that the bi_disk pointer needs to be checked.
I think "bi_bdev->bd_disk" checking might be needed too.
bio_max_size() occurs in the hot path. Since if-tests have a runtime
cost I'd like to keep the number of if-tests inside bio_max_size() to a
minimum.
I only found one bd_disk assignment in the kernel tree, namely inside
bdev_alloc(). The two bdev_alloc() calls I found inside the kernel tree
pass a valid disk pointer to bdev_alloc(). So I think it is not
necessary to check the disk pointer inside bio_max_size().
Thanks,
Bart.