Skip to content

Commit ac7ac46

Browse files
committed
Merge tag 'for-5.11/block-2020-12-14' of git://git.kernel.dk/linux-block
Pull block updates from Jens Axboe: "Another series of killing more code than what is being added, again thanks to Christoph's relentless cleanups and tech debt tackling. This contains: - blk-iocost improvements (Baolin Wang) - part0 iostat fix (Jeffle Xu) - Disable iopoll for split bios (Jeffle Xu) - block tracepoint cleanups (Christoph Hellwig) - Merging of struct block_device and hd_struct (Christoph Hellwig) - Rework/cleanup of how block device sizes are updated (Christoph Hellwig) - Simplification of gendisk lookup and removal of block device aliasing (Christoph Hellwig) - Block device ioctl cleanups (Christoph Hellwig) - Removal of bdget()/blkdev_get() as exported API (Christoph Hellwig) - Disk change rework, avoid ->revalidate_disk() (Christoph Hellwig) - sbitmap improvements (Pavel Begunkov) - Hybrid polling fix (Pavel Begunkov) - bvec iteration improvements (Pavel Begunkov) - Zone revalidation fixes (Damien Le Moal) - blk-throttle limit fix (Yu Kuai) - Various little fixes" * tag 'for-5.11/block-2020-12-14' of git://git.kernel.dk/linux-block: (126 commits) blk-mq: fix msec comment from micro to milli seconds blk-mq: update arg in comment of blk_mq_map_queue blk-mq: add helper allocating tagset->tags Revert "block: Fix a lockdep complaint triggered by request queue flushing" nvme-loop: use blk_mq_hctx_set_fq_lock_class to set loop's lock class blk-mq: add new API of blk_mq_hctx_set_fq_lock_class block: disable iopoll for split bio block: Improve blk_revalidate_disk_zones() checks sbitmap: simplify wrap check sbitmap: replace CAS with atomic and sbitmap: remove swap_lock sbitmap: optimise sbitmap_deferred_clear() blk-mq: skip hybrid polling if iopoll doesn't spin blk-iocost: Factor out the base vrate change into a separate function blk-iocost: Factor out the active iocgs' state check into a separate function blk-iocost: Move the usage ratio calculation to the correct place blk-iocost: Remove unnecessary advance declaration blk-iocost: Fix some typos in comments blktrace: fix up a kerneldoc comment block: remove the request_queue to argument request based tracepoints ...
2 parents 48aba79 + fa94ba8 commit ac7ac46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2111
-3334
lines changed

block/bio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,13 @@ void bio_truncate(struct bio *bio, unsigned new_size)
608608
void guard_bio_eod(struct bio *bio)
609609
{
610610
sector_t maxsector;
611-
struct hd_struct *part;
611+
struct block_device *part;
612612

613613
rcu_read_lock();
614614
part = __disk_get_part(bio->bi_disk, bio->bi_partno);
615615
if (part)
616-
maxsector = part_nr_sects_read(part);
617-
else
616+
maxsector = bdev_nr_sectors(part);
617+
else
618618
maxsector = get_capacity(bio->bi_disk);
619619
rcu_read_unlock();
620620

@@ -1212,8 +1212,8 @@ void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
12121212

12131213
flush_dcache_page(dst_bv.bv_page);
12141214

1215-
bio_advance_iter(src, src_iter, bytes);
1216-
bio_advance_iter(dst, dst_iter, bytes);
1215+
bio_advance_iter_single(src, src_iter, bytes);
1216+
bio_advance_iter_single(dst, dst_iter, bytes);
12171217
}
12181218
}
12191219
EXPORT_SYMBOL(bio_copy_data_iter);

block/blk-cgroup.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -556,22 +556,22 @@ static struct blkcg_gq *blkg_lookup_check(struct blkcg *blkcg,
556556
}
557557

558558
/**
559-
* blkg_conf_prep - parse and prepare for per-blkg config update
559+
* blkcg_conf_open_bdev - parse and open bdev for per-blkg config update
560560
* @inputp: input string pointer
561561
*
562562
* Parse the device node prefix part, MAJ:MIN, of per-blkg config update
563-
* from @input and get and return the matching gendisk. *@inputp is
563+
* from @input and get and return the matching bdev. *@inputp is
564564
* updated to point past the device node prefix. Returns an ERR_PTR()
565565
* value on error.
566566
*
567567
* Use this function iff blkg_conf_prep() can't be used for some reason.
568568
*/
569-
struct gendisk *blkcg_conf_get_disk(char **inputp)
569+
struct block_device *blkcg_conf_open_bdev(char **inputp)
570570
{
571571
char *input = *inputp;
572572
unsigned int major, minor;
573-
struct gendisk *disk;
574-
int key_len, part;
573+
struct block_device *bdev;
574+
int key_len;
575575

576576
if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
577577
return ERR_PTR(-EINVAL);
@@ -581,16 +581,16 @@ struct gendisk *blkcg_conf_get_disk(char **inputp)
581581
return ERR_PTR(-EINVAL);
582582
input = skip_spaces(input);
583583

584-
disk = get_gendisk(MKDEV(major, minor), &part);
585-
if (!disk)
584+
bdev = blkdev_get_no_open(MKDEV(major, minor));
585+
if (!bdev)
586586
return ERR_PTR(-ENODEV);
587-
if (part) {
588-
put_disk_and_module(disk);
587+
if (bdev_is_partition(bdev)) {
588+
blkdev_put_no_open(bdev);
589589
return ERR_PTR(-ENODEV);
590590
}
591591

592592
*inputp = input;
593-
return disk;
593+
return bdev;
594594
}
595595

596596
/**
@@ -607,18 +607,18 @@ struct gendisk *blkcg_conf_get_disk(char **inputp)
607607
*/
608608
int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
609609
char *input, struct blkg_conf_ctx *ctx)
610-
__acquires(rcu) __acquires(&disk->queue->queue_lock)
610+
__acquires(rcu) __acquires(&bdev->bd_disk->queue->queue_lock)
611611
{
612-
struct gendisk *disk;
612+
struct block_device *bdev;
613613
struct request_queue *q;
614614
struct blkcg_gq *blkg;
615615
int ret;
616616

617-
disk = blkcg_conf_get_disk(&input);
618-
if (IS_ERR(disk))
619-
return PTR_ERR(disk);
617+
bdev = blkcg_conf_open_bdev(&input);
618+
if (IS_ERR(bdev))
619+
return PTR_ERR(bdev);
620620

621-
q = disk->queue;
621+
q = bdev->bd_disk->queue;
622622

623623
rcu_read_lock();
624624
spin_lock_irq(&q->queue_lock);
@@ -689,7 +689,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
689689
goto success;
690690
}
691691
success:
692-
ctx->disk = disk;
692+
ctx->bdev = bdev;
693693
ctx->blkg = blkg;
694694
ctx->body = input;
695695
return 0;
@@ -700,7 +700,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
700700
spin_unlock_irq(&q->queue_lock);
701701
rcu_read_unlock();
702702
fail:
703-
put_disk_and_module(disk);
703+
blkdev_put_no_open(bdev);
704704
/*
705705
* If queue was bypassing, we should retry. Do so after a
706706
* short msleep(). It isn't strictly necessary but queue
@@ -723,11 +723,11 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep);
723723
* with blkg_conf_prep().
724724
*/
725725
void blkg_conf_finish(struct blkg_conf_ctx *ctx)
726-
__releases(&ctx->disk->queue->queue_lock) __releases(rcu)
726+
__releases(&ctx->bdev->bd_disk->queue->queue_lock) __releases(rcu)
727727
{
728-
spin_unlock_irq(&ctx->disk->queue->queue_lock);
728+
spin_unlock_irq(&ctx->bdev->bd_disk->queue->queue_lock);
729729
rcu_read_unlock();
730-
put_disk_and_module(ctx->disk);
730+
blkdev_put_no_open(ctx->bdev);
731731
}
732732
EXPORT_SYMBOL_GPL(blkg_conf_finish);
733733

@@ -820,17 +820,17 @@ static void blkcg_fill_root_iostats(void)
820820

821821
class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
822822
while ((dev = class_dev_iter_next(&iter))) {
823-
struct gendisk *disk = dev_to_disk(dev);
824-
struct hd_struct *part = disk_get_part(disk, 0);
825-
struct blkcg_gq *blkg = blk_queue_root_blkg(disk->queue);
823+
struct block_device *bdev = dev_to_bdev(dev);
824+
struct blkcg_gq *blkg =
825+
blk_queue_root_blkg(bdev->bd_disk->queue);
826826
struct blkg_iostat tmp;
827827
int cpu;
828828

829829
memset(&tmp, 0, sizeof(tmp));
830830
for_each_possible_cpu(cpu) {
831831
struct disk_stats *cpu_dkstats;
832832

833-
cpu_dkstats = per_cpu_ptr(part->dkstats, cpu);
833+
cpu_dkstats = per_cpu_ptr(bdev->bd_stats, cpu);
834834
tmp.ios[BLKG_IOSTAT_READ] +=
835835
cpu_dkstats->ios[STAT_READ];
836836
tmp.ios[BLKG_IOSTAT_WRITE] +=
@@ -849,7 +849,6 @@ static void blkcg_fill_root_iostats(void)
849849
blkg_iostat_set(&blkg->iostat.cur, &tmp);
850850
u64_stats_update_end(&blkg->iostat.sync);
851851
}
852-
disk_put_part(part);
853852
}
854853
}
855854

block/blk-core.c

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,9 @@ static int __init setup_fail_make_request(char *str)
666666
}
667667
__setup("fail_make_request=", setup_fail_make_request);
668668

669-
static bool should_fail_request(struct hd_struct *part, unsigned int bytes)
669+
static bool should_fail_request(struct block_device *part, unsigned int bytes)
670670
{
671-
return part->make_it_fail && should_fail(&fail_make_request, bytes);
671+
return part->bd_make_it_fail && should_fail(&fail_make_request, bytes);
672672
}
673673

674674
static int __init fail_make_request_debugfs(void)
@@ -683,27 +683,27 @@ late_initcall(fail_make_request_debugfs);
683683

684684
#else /* CONFIG_FAIL_MAKE_REQUEST */
685685

686-
static inline bool should_fail_request(struct hd_struct *part,
686+
static inline bool should_fail_request(struct block_device *part,
687687
unsigned int bytes)
688688
{
689689
return false;
690690
}
691691

692692
#endif /* CONFIG_FAIL_MAKE_REQUEST */
693693

694-
static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
694+
static inline bool bio_check_ro(struct bio *bio, struct block_device *part)
695695
{
696696
const int op = bio_op(bio);
697697

698-
if (part->policy && op_is_write(op)) {
698+
if (part->bd_read_only && op_is_write(op)) {
699699
char b[BDEVNAME_SIZE];
700700

701701
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
702702
return false;
703703

704704
WARN_ONCE(1,
705705
"Trying to write to read-only block-device %s (partno %d)\n",
706-
bio_devname(bio, b), part->partno);
706+
bio_devname(bio, b), part->bd_partno);
707707
/* Older lvm-tools actually trigger this */
708708
return false;
709709
}
@@ -713,7 +713,7 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
713713

714714
static noinline int should_fail_bio(struct bio *bio)
715715
{
716-
if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
716+
if (should_fail_request(bio->bi_disk->part0, bio->bi_iter.bi_size))
717717
return -EIO;
718718
return 0;
719719
}
@@ -742,7 +742,7 @@ static inline int bio_check_eod(struct bio *bio, sector_t maxsector)
742742
*/
743743
static inline int blk_partition_remap(struct bio *bio)
744744
{
745-
struct hd_struct *p;
745+
struct block_device *p;
746746
int ret = -EIO;
747747

748748
rcu_read_lock();
@@ -755,11 +755,12 @@ static inline int blk_partition_remap(struct bio *bio)
755755
goto out;
756756

757757
if (bio_sectors(bio)) {
758-
if (bio_check_eod(bio, part_nr_sects_read(p)))
758+
if (bio_check_eod(bio, bdev_nr_sectors(p)))
759759
goto out;
760-
bio->bi_iter.bi_sector += p->start_sect;
761-
trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
762-
bio->bi_iter.bi_sector - p->start_sect);
760+
bio->bi_iter.bi_sector += p->bd_start_sect;
761+
trace_block_bio_remap(bio, p->bd_dev,
762+
bio->bi_iter.bi_sector -
763+
p->bd_start_sect);
763764
}
764765
bio->bi_partno = 0;
765766
ret = 0;
@@ -829,7 +830,7 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
829830
if (unlikely(blk_partition_remap(bio)))
830831
goto end_io;
831832
} else {
832-
if (unlikely(bio_check_ro(bio, &bio->bi_disk->part0)))
833+
if (unlikely(bio_check_ro(bio, bio->bi_disk->part0)))
833834
goto end_io;
834835
if (unlikely(bio_check_eod(bio, get_capacity(bio->bi_disk))))
835836
goto end_io;
@@ -906,7 +907,7 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
906907
blkcg_bio_issue_init(bio);
907908

908909
if (!bio_flagged(bio, BIO_TRACE_COMPLETION)) {
909-
trace_block_bio_queue(q, bio);
910+
trace_block_bio_queue(bio);
910911
/* Now that enqueuing has been traced, we need to trace
911912
* completion as well.
912913
*/
@@ -1201,7 +1202,7 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *
12011202
return ret;
12021203

12031204
if (rq->rq_disk &&
1204-
should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
1205+
should_fail_request(rq->rq_disk->part0, blk_rq_bytes(rq)))
12051206
return BLK_STS_IOERR;
12061207

12071208
if (blk_crypto_insert_cloned_request(rq))
@@ -1260,17 +1261,18 @@ unsigned int blk_rq_err_bytes(const struct request *rq)
12601261
}
12611262
EXPORT_SYMBOL_GPL(blk_rq_err_bytes);
12621263

1263-
static void update_io_ticks(struct hd_struct *part, unsigned long now, bool end)
1264+
static void update_io_ticks(struct block_device *part, unsigned long now,
1265+
bool end)
12641266
{
12651267
unsigned long stamp;
12661268
again:
1267-
stamp = READ_ONCE(part->stamp);
1269+
stamp = READ_ONCE(part->bd_stamp);
12681270
if (unlikely(stamp != now)) {
1269-
if (likely(cmpxchg(&part->stamp, stamp, now) == stamp))
1271+
if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp))
12701272
__part_stat_add(part, io_ticks, end ? now - stamp : 1);
12711273
}
1272-
if (part->partno) {
1273-
part = &part_to_disk(part)->part0;
1274+
if (part->bd_partno) {
1275+
part = bdev_whole(part);
12741276
goto again;
12751277
}
12761278
}
@@ -1279,11 +1281,9 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes)
12791281
{
12801282
if (req->part && blk_do_io_stat(req)) {
12811283
const int sgrp = op_stat_group(req_op(req));
1282-
struct hd_struct *part;
12831284

12841285
part_stat_lock();
1285-
part = req->part;
1286-
part_stat_add(part, sectors[sgrp], bytes >> 9);
1286+
part_stat_add(req->part, sectors[sgrp], bytes >> 9);
12871287
part_stat_unlock();
12881288
}
12891289
}
@@ -1298,17 +1298,12 @@ void blk_account_io_done(struct request *req, u64 now)
12981298
if (req->part && blk_do_io_stat(req) &&
12991299
!(req->rq_flags & RQF_FLUSH_SEQ)) {
13001300
const int sgrp = op_stat_group(req_op(req));
1301-
struct hd_struct *part;
13021301

13031302
part_stat_lock();
1304-
part = req->part;
1305-
1306-
update_io_ticks(part, jiffies, true);
1307-
part_stat_inc(part, ios[sgrp]);
1308-
part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
1303+
update_io_ticks(req->part, jiffies, true);
1304+
part_stat_inc(req->part, ios[sgrp]);
1305+
part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns);
13091306
part_stat_unlock();
1310-
1311-
hd_struct_put(part);
13121307
}
13131308
}
13141309

@@ -1324,7 +1319,7 @@ void blk_account_io_start(struct request *rq)
13241319
part_stat_unlock();
13251320
}
13261321

1327-
static unsigned long __part_start_io_acct(struct hd_struct *part,
1322+
static unsigned long __part_start_io_acct(struct block_device *part,
13281323
unsigned int sectors, unsigned int op)
13291324
{
13301325
const int sgrp = op_stat_group(op);
@@ -1340,7 +1335,7 @@ static unsigned long __part_start_io_acct(struct hd_struct *part,
13401335
return now;
13411336
}
13421337

1343-
unsigned long part_start_io_acct(struct gendisk *disk, struct hd_struct **part,
1338+
unsigned long part_start_io_acct(struct gendisk *disk, struct block_device **part,
13441339
struct bio *bio)
13451340
{
13461341
*part = disk_map_sector_rcu(disk, bio->bi_iter.bi_sector);
@@ -1352,11 +1347,11 @@ EXPORT_SYMBOL_GPL(part_start_io_acct);
13521347
unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
13531348
unsigned int op)
13541349
{
1355-
return __part_start_io_acct(&disk->part0, sectors, op);
1350+
return __part_start_io_acct(disk->part0, sectors, op);
13561351
}
13571352
EXPORT_SYMBOL(disk_start_io_acct);
13581353

1359-
static void __part_end_io_acct(struct hd_struct *part, unsigned int op,
1354+
static void __part_end_io_acct(struct block_device *part, unsigned int op,
13601355
unsigned long start_time)
13611356
{
13621357
const int sgrp = op_stat_group(op);
@@ -1370,18 +1365,17 @@ static void __part_end_io_acct(struct hd_struct *part, unsigned int op,
13701365
part_stat_unlock();
13711366
}
13721367

1373-
void part_end_io_acct(struct hd_struct *part, struct bio *bio,
1368+
void part_end_io_acct(struct block_device *part, struct bio *bio,
13741369
unsigned long start_time)
13751370
{
13761371
__part_end_io_acct(part, bio_op(bio), start_time);
1377-
hd_struct_put(part);
13781372
}
13791373
EXPORT_SYMBOL_GPL(part_end_io_acct);
13801374

13811375
void disk_end_io_acct(struct gendisk *disk, unsigned int op,
13821376
unsigned long start_time)
13831377
{
1384-
__part_end_io_acct(&disk->part0, op, start_time);
1378+
__part_end_io_acct(disk->part0, op, start_time);
13851379
}
13861380
EXPORT_SYMBOL(disk_end_io_acct);
13871381

0 commit comments

Comments
 (0)