Skip to content

Commit ac2b6f9

Browse files
author
Al Viro
committed
bdev: move ->bd_has_subit_bio to ->__bd_flags
In bdev_alloc() we have all flags initialized to false, so assignment to ->bh_has_submit_bio n there is a no-op unless we have partno != 0 and flag already set on entire device. In device_add_disk() we have just allocated the block_device in question and it had been a full-device one, so the flag is guaranteed to be still clear when we get to assignment. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 4c80105 commit ac2b6f9

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

block/bdev.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,8 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)
414414
atomic_set(&bdev->__bd_flags, partno);
415415
bdev->bd_inode = inode;
416416
bdev->bd_queue = disk->queue;
417-
if (partno)
418-
bdev->bd_has_submit_bio = disk->part0->bd_has_submit_bio;
419-
else
420-
bdev->bd_has_submit_bio = false;
417+
if (partno && bdev_test_flag(disk->part0, BD_HAS_SUBMIT_BIO))
418+
bdev_set_flag(bdev, BD_HAS_SUBMIT_BIO);
421419
bdev->bd_stats = alloc_percpu(struct disk_stats);
422420
if (!bdev->bd_stats) {
423421
iput(inode);

block/blk-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static void __submit_bio(struct bio *bio)
615615
if (unlikely(!blk_crypto_bio_prep(&bio)))
616616
return;
617617

618-
if (!bio->bi_bdev->bd_has_submit_bio) {
618+
if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO)) {
619619
blk_mq_submit_bio(bio);
620620
} else if (likely(bio_queue_enter(bio) == 0)) {
621621
struct gendisk *disk = bio->bi_bdev->bd_disk;
@@ -723,7 +723,7 @@ void submit_bio_noacct_nocheck(struct bio *bio)
723723
*/
724724
if (current->bio_list)
725725
bio_list_add(&current->bio_list[0], bio);
726-
else if (!bio->bi_bdev->bd_has_submit_bio)
726+
else if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO))
727727
__submit_bio_noacct_mq(bio);
728728
else
729729
__submit_bio_noacct(bio);

block/genhd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
413413
elevator_init_mq(disk->queue);
414414

415415
/* Mark bdev as having a submit_bio, if needed */
416-
disk->part0->bd_has_submit_bio = disk->fops->submit_bio != NULL;
416+
if (disk->fops->submit_bio)
417+
bdev_set_flag(disk->part0, BD_HAS_SUBMIT_BIO);
417418

418419
/*
419420
* If the driver provides an explicit major number it also must provide

include/linux/blk_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct block_device {
4949
#define BD_PARTNO 255 // lower 8 bits; assign-once
5050
#define BD_READ_ONLY (1u<<8) // read-only policy
5151
#define BD_WRITE_HOLDER (1u<<9)
52-
bool bd_has_submit_bio;
52+
#define BD_HAS_SUBMIT_BIO (1u<<10)
5353
dev_t bd_dev;
5454
struct inode *bd_inode; /* will die */
5555

0 commit comments

Comments
 (0)