Skip to content

Commit 10f36b1

Browse files
committed
Merge tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block
Pull block updates from Jens Axboe: - Online capacity resizing (Balbir) - Number of hardware queue change fixes (Bart) - null_blk fault injection addition (Bart) - Cleanup of queue allocation, unifying the node/no-node API (Christoph) - Cleanup of genhd, moving code to where it makes sense (Christoph) - Cleanup of the partition handling code (Christoph) - disk stat fixes/improvements (Konstantin) - BFQ improvements (Paolo) - Various fixes and improvements * tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block: (72 commits) block: return NULL in blk_alloc_queue() on error block: move bio_map_* to blk-map.c Revert "blkdev: check for valid request queue before issuing flush" block: simplify queue allocation bcache: pass the make_request methods to blk_queue_make_request null_blk: use blk_mq_init_queue_data block: add a blk_mq_init_queue_data helper block: move the ->devnode callback to struct block_device_operations block: move the part_stat* helpers from genhd.h to a new header block: move block layer internals out of include/linux/genhd.h block: move guard_bio_eod to bio.c block: unexport get_gendisk block: unexport disk_map_sector_rcu block: unexport disk_get_part block: mark part_in_flight and part_in_flight_rw static block: mark block_depr static block: factor out requeue handling from dispatch code block/diskstats: replace time_in_queue with sum of request times block/diskstats: accumulate all per-cpu counters in one pass block/diskstats: more accurate approximation of io_ticks for slow disks ...
2 parents 3a0eb19 + 654a366 commit 10f36b1

111 files changed

Lines changed: 1950 additions & 2039 deletions

Some content is hidden

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

‎Documentation/admin-guide/iostats.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Field 10 -- # of milliseconds spent doing I/Os (unsigned int)
100100

101101
Since 5.0 this field counts jiffies when at least one request was
102102
started or completed. If request runs more than 2 jiffies then some
103-
I/O time will not be accounted unless there are other requests.
103+
I/O time might be not accounted in case of concurrent requests.
104104

105105
Field 11 -- weighted # of milliseconds spent doing I/Os (unsigned int)
106106
This field is incremented at each I/O start, I/O completion, I/O
@@ -143,6 +143,9 @@ are summed (possibly overflowing the unsigned long variable they are
143143
summed to) and the result given to the user. There is no convenient
144144
user interface for accessing the per-CPU counters themselves.
145145

146+
Since 4.19 request times are measured with nanoseconds precision and
147+
truncated to milliseconds before showing in this interface.
148+
146149
Disks vs Partitions
147150
-------------------
148151

‎Documentation/block/capability.rst‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
Generic Block Device Capability
33
===============================
44

5-
This file documents the sysfs file block/<disk>/capability
5+
This file documents the sysfs file ``block/<disk>/capability``.
66

7-
capability is a hex word indicating which capabilities a specific disk
8-
supports. For more information on bits not listed here, see
9-
include/linux/genhd.h
7+
``capability`` is a bitfield, printed in hexadecimal, indicating which
8+
capabilities a specific block device supports:
109

11-
GENHD_FL_MEDIA_CHANGE_NOTIFY
12-
----------------------------
13-
14-
Value: 4
15-
16-
When this bit is set, the disk supports Asynchronous Notification
17-
of media change events. These events will be broadcast to user
18-
space via kernel uevent.
10+
.. kernel-doc:: include/linux/genhd.h

‎Documentation/scsi/scsi_mid_low_api.txt‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ Summary:
299299
scsi_host_alloc - return a new scsi_host instance whose refcount==1
300300
scsi_host_get - increments Scsi_Host instance's refcount
301301
scsi_host_put - decrements Scsi_Host instance's refcount (free if 0)
302-
scsi_partsize - parse partition table into cylinders, heads + sectors
303302
scsi_register - create and register a scsi host adapter instance.
304303
scsi_remove_device - detach and remove a SCSI device
305304
scsi_remove_host - detach and remove all SCSI devices owned by host
@@ -472,26 +471,6 @@ void scsi_host_get(struct Scsi_Host *shost)
472471
void scsi_host_put(struct Scsi_Host *shost)
473472

474473

475-
/**
476-
* scsi_partsize - parse partition table into cylinders, heads + sectors
477-
* @buf: pointer to partition table
478-
* @capacity: size of (total) disk in 512 byte sectors
479-
* @cyls: outputs number of cylinders calculated via this pointer
480-
* @hds: outputs number of heads calculated via this pointer
481-
* @secs: outputs number of sectors calculated via this pointer
482-
*
483-
* Returns 0 on success, -1 on failure
484-
*
485-
* Might block: no
486-
*
487-
* Notes: Caller owns memory returned (free with kfree() )
488-
*
489-
* Defined in: drivers/scsi/scsicam.c
490-
**/
491-
int scsi_partsize(unsigned char *buf, unsigned long capacity,
492-
unsigned int *cyls, unsigned int *hds, unsigned int *secs)
493-
494-
495474
/**
496475
* scsi_register - create and register a scsi host adapter instance.
497476
* @sht: pointer to scsi host template

‎arch/m68k/emu/nfblock.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize)
118118
dev->bsize = bsize;
119119
dev->bshift = ffs(bsize) - 10;
120120

121-
dev->queue = blk_alloc_queue(GFP_KERNEL);
121+
dev->queue = blk_alloc_queue(nfhd_make_request, NUMA_NO_NODE);
122122
if (dev->queue == NULL)
123123
goto free_dev;
124124

125125
dev->queue->queuedata = dev;
126-
blk_queue_make_request(dev->queue, nfhd_make_request);
127126
blk_queue_logical_block_size(dev->queue, bsize);
128127

129128
dev->disk = alloc_disk(16);

‎arch/xtensa/platforms/iss/simdisk.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,12 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
267267
spin_lock_init(&dev->lock);
268268
dev->users = 0;
269269

270-
dev->queue = blk_alloc_queue(GFP_KERNEL);
270+
dev->queue = blk_alloc_queue(simdisk_make_request, NUMA_NO_NODE);
271271
if (dev->queue == NULL) {
272272
pr_err("blk_alloc_queue failed\n");
273273
goto out_alloc_queue;
274274
}
275275

276-
blk_queue_make_request(dev->queue, simdisk_make_request);
277276
dev->queue->queuedata = dev;
278277

279278
dev->gd = alloc_disk(SIMDISK_MINORS);

‎block/Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \
88
blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \
99
blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \
1010
blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \
11-
genhd.o partition-generic.o ioprio.o \
12-
badblocks.o partitions/ blk-rq-qos.o
11+
genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o
1312

1413
obj-$(CONFIG_BOUNCE) += bounce.o
1514
obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o

‎block/bfq-cgroup.c‎

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,12 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
642642
{
643643
struct bfq_entity *entity = &bfqq->entity;
644644

645+
/*
646+
* Get extra reference to prevent bfqq from being freed in
647+
* next possible expire or deactivate.
648+
*/
649+
bfqq->ref++;
650+
645651
/* If bfqq is empty, then bfq_bfqq_expire also invokes
646652
* bfq_del_bfqq_busy, thereby removing bfqq and its entity
647653
* from data structures related to current group. Otherwise we
@@ -652,12 +658,6 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
652658
bfq_bfqq_expire(bfqd, bfqd->in_service_queue,
653659
false, BFQQE_PREEMPTED);
654660

655-
/*
656-
* get extra reference to prevent bfqq from being freed in
657-
* next possible deactivate
658-
*/
659-
bfqq->ref++;
660-
661661
if (bfq_bfqq_busy(bfqq))
662662
bfq_deactivate_bfqq(bfqd, bfqq, false, false);
663663
else if (entity->on_st_or_in_serv)
@@ -677,7 +677,7 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
677677

678678
if (!bfqd->in_service_queue && !bfqd->rq_in_driver)
679679
bfq_schedule_dispatch(bfqd);
680-
/* release extra ref taken above */
680+
/* release extra ref taken above, bfqq may happen to be freed now */
681681
bfq_put_queue(bfqq);
682682
}
683683

@@ -714,10 +714,7 @@ static struct bfq_group *__bfq_bic_change_cgroup(struct bfq_data *bfqd,
714714

715715
if (entity->sched_data != &bfqg->sched_data) {
716716
bic_set_bfqq(bic, NULL, 0);
717-
bfq_log_bfqq(bfqd, async_bfqq,
718-
"bic_change_group: %p %d",
719-
async_bfqq, async_bfqq->ref);
720-
bfq_put_queue(async_bfqq);
717+
bfq_release_process_ref(bfqd, async_bfqq);
721718
}
722719
}
723720

@@ -818,39 +815,53 @@ static void bfq_flush_idle_tree(struct bfq_service_tree *st)
818815
/**
819816
* bfq_reparent_leaf_entity - move leaf entity to the root_group.
820817
* @bfqd: the device data structure with the root group.
821-
* @entity: the entity to move.
818+
* @entity: the entity to move, if entity is a leaf; or the parent entity
819+
* of an active leaf entity to move, if entity is not a leaf.
822820
*/
823821
static void bfq_reparent_leaf_entity(struct bfq_data *bfqd,
824-
struct bfq_entity *entity)
822+
struct bfq_entity *entity,
823+
int ioprio_class)
825824
{
826-
struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity);
825+
struct bfq_queue *bfqq;
826+
struct bfq_entity *child_entity = entity;
827827

828+
while (child_entity->my_sched_data) { /* leaf not reached yet */
829+
struct bfq_sched_data *child_sd = child_entity->my_sched_data;
830+
struct bfq_service_tree *child_st = child_sd->service_tree +
831+
ioprio_class;
832+
struct rb_root *child_active = &child_st->active;
833+
834+
child_entity = bfq_entity_of(rb_first(child_active));
835+
836+
if (!child_entity)
837+
child_entity = child_sd->in_service_entity;
838+
}
839+
840+
bfqq = bfq_entity_to_bfqq(child_entity);
828841
bfq_bfqq_move(bfqd, bfqq, bfqd->root_group);
829842
}
830843

831844
/**
832-
* bfq_reparent_active_entities - move to the root group all active
833-
* entities.
845+
* bfq_reparent_active_queues - move to the root group all active queues.
834846
* @bfqd: the device data structure with the root group.
835847
* @bfqg: the group to move from.
836-
* @st: the service tree with the entities.
848+
* @st: the service tree to start the search from.
837849
*/
838-
static void bfq_reparent_active_entities(struct bfq_data *bfqd,
839-
struct bfq_group *bfqg,
840-
struct bfq_service_tree *st)
850+
static void bfq_reparent_active_queues(struct bfq_data *bfqd,
851+
struct bfq_group *bfqg,
852+
struct bfq_service_tree *st,
853+
int ioprio_class)
841854
{
842855
struct rb_root *active = &st->active;
843-
struct bfq_entity *entity = NULL;
844-
845-
if (!RB_EMPTY_ROOT(&st->active))
846-
entity = bfq_entity_of(rb_first(active));
856+
struct bfq_entity *entity;
847857

848-
for (; entity ; entity = bfq_entity_of(rb_first(active)))
849-
bfq_reparent_leaf_entity(bfqd, entity);
858+
while ((entity = bfq_entity_of(rb_first(active))))
859+
bfq_reparent_leaf_entity(bfqd, entity, ioprio_class);
850860

851861
if (bfqg->sched_data.in_service_entity)
852862
bfq_reparent_leaf_entity(bfqd,
853-
bfqg->sched_data.in_service_entity);
863+
bfqg->sched_data.in_service_entity,
864+
ioprio_class);
854865
}
855866

856867
/**
@@ -882,13 +893,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
882893
for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) {
883894
st = bfqg->sched_data.service_tree + i;
884895

885-
/*
886-
* The idle tree may still contain bfq_queues belonging
887-
* to exited task because they never migrated to a different
888-
* cgroup from the one being destroyed now.
889-
*/
890-
bfq_flush_idle_tree(st);
891-
892896
/*
893897
* It may happen that some queues are still active
894898
* (busy) upon group destruction (if the corresponding
@@ -901,7 +905,20 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
901905
* There is no need to put the sync queues, as the
902906
* scheduler has taken no reference.
903907
*/
904-
bfq_reparent_active_entities(bfqd, bfqg, st);
908+
bfq_reparent_active_queues(bfqd, bfqg, st, i);
909+
910+
/*
911+
* The idle tree may still contain bfq_queues
912+
* belonging to exited task because they never
913+
* migrated to a different cgroup from the one being
914+
* destroyed now. In addition, even
915+
* bfq_reparent_active_queues() may happen to add some
916+
* entities to the idle tree. It happens if, in some
917+
* of the calls to bfq_bfqq_move() performed by
918+
* bfq_reparent_active_queues(), the queue to move is
919+
* empty and gets expired.
920+
*/
921+
bfq_flush_idle_tree(st);
905922
}
906923

907924
__bfq_deactivate_entity(entity, false);

‎block/bfq-iosched.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,8 +2716,6 @@ static void bfq_bfqq_save_state(struct bfq_queue *bfqq)
27162716
}
27172717
}
27182718

2719-
2720-
static
27212719
void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq)
27222720
{
27232721
/*
@@ -6215,20 +6213,28 @@ static struct bfq_queue *bfq_init_rq(struct request *rq)
62156213
return bfqq;
62166214
}
62176215

6218-
static void bfq_idle_slice_timer_body(struct bfq_queue *bfqq)
6216+
static void
6217+
bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq)
62196218
{
6220-
struct bfq_data *bfqd = bfqq->bfqd;
62216219
enum bfqq_expiration reason;
62226220
unsigned long flags;
62236221

62246222
spin_lock_irqsave(&bfqd->lock, flags);
6225-
bfq_clear_bfqq_wait_request(bfqq);
62266223

6224+
/*
6225+
* Considering that bfqq may be in race, we should firstly check
6226+
* whether bfqq is in service before doing something on it. If
6227+
* the bfqq in race is not in service, it has already been expired
6228+
* through __bfq_bfqq_expire func and its wait_request flags has
6229+
* been cleared in __bfq_bfqd_reset_in_service func.
6230+
*/
62276231
if (bfqq != bfqd->in_service_queue) {
62286232
spin_unlock_irqrestore(&bfqd->lock, flags);
62296233
return;
62306234
}
62316235

6236+
bfq_clear_bfqq_wait_request(bfqq);
6237+
62326238
if (bfq_bfqq_budget_timeout(bfqq))
62336239
/*
62346240
* Also here the queue can be safely expired
@@ -6273,7 +6279,7 @@ static enum hrtimer_restart bfq_idle_slice_timer(struct hrtimer *timer)
62736279
* early.
62746280
*/
62756281
if (bfqq)
6276-
bfq_idle_slice_timer_body(bfqq);
6282+
bfq_idle_slice_timer_body(bfqd, bfqq);
62776283

62786284
return HRTIMER_NORESTART;
62796285
}

‎block/bfq-iosched.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq,
955955
bool compensate, enum bfqq_expiration reason);
956956
void bfq_put_queue(struct bfq_queue *bfqq);
957957
void bfq_end_wr_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg);
958+
void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq);
958959
void bfq_schedule_dispatch(struct bfq_data *bfqd);
959960
void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg);
960961

0 commit comments

Comments
 (0)