Skip to content

Commit ed535f2

Browse files
committed
Merge tag 'block-5.6-2020-02-05' of git://git.kernel.dk/linux-block
Pull more block updates from Jens Axboe: "Some later arrivals, but all fixes at this point: - bcache fix series (Coly) - Series of BFQ fixes (Paolo) - NVMe pull request from Keith with a few minor NVMe fixes - Various little tweaks" * tag 'block-5.6-2020-02-05' of git://git.kernel.dk/linux-block: (23 commits) nvmet: update AEN list and array at one place nvmet: Fix controller use after free nvmet: Fix error print message at nvmet_install_queue function brd: check and limit max_part par nvme-pci: remove nvmeq->tags nvmet: fix dsm failure when payload does not match sgl descriptor nvmet: Pass lockdep expression to RCU lists block, bfq: clarify the goal of bfq_split_bfqq() block, bfq: get a ref to a group when adding it to a service tree block, bfq: remove ifdefs from around gets/puts of bfq groups block, bfq: extend incomplete name of field on_st block, bfq: get extra ref to prevent a queue from being freed during a group move block, bfq: do not insert oom queue into position tree block, bfq: do not plug I/O for bfq_queues with no proc refs bcache: check return value of prio_read() bcache: fix incorrect data type usage in btree_flush_write() bcache: add readahead cache policy options via sysfs interface bcache: explicity type cast in bset_bkey_last() bcache: fix memory corruption in bch_cache_accounting_clear() xen/blkfront: limit allocated memory size to actual use case ...
2 parents 0384066 + b74e58c commit ed535f2

25 files changed

+230
-94
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14947,8 +14947,8 @@ S: Maintained
1494714947
F: drivers/mmc/host/sdhci-omap.c
1494814948

1494914949
SECURE ENCRYPTING DEVICE (SED) OPAL DRIVER
14950-
M: Scott Bauer <[email protected]>
1495114950
M: Jonathan Derrick <[email protected]>
14951+
M: Revanth Rajashekar <[email protected]>
1495214952
1495314953
S: Supported
1495414954
F: block/sed*

block/bfq-cgroup.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static void bfqg_put(struct bfq_group *bfqg)
332332
kfree(bfqg);
333333
}
334334

335-
static void bfqg_and_blkg_get(struct bfq_group *bfqg)
335+
void bfqg_and_blkg_get(struct bfq_group *bfqg)
336336
{
337337
/* see comments in bfq_bic_update_cgroup for why refcounting bfqg */
338338
bfqg_get(bfqg);
@@ -651,9 +651,15 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
651651
bfq_bfqq_expire(bfqd, bfqd->in_service_queue,
652652
false, BFQQE_PREEMPTED);
653653

654+
/*
655+
* get extra reference to prevent bfqq from being freed in
656+
* next possible deactivate
657+
*/
658+
bfqq->ref++;
659+
654660
if (bfq_bfqq_busy(bfqq))
655661
bfq_deactivate_bfqq(bfqd, bfqq, false, false);
656-
else if (entity->on_st)
662+
else if (entity->on_st_or_in_serv)
657663
bfq_put_idle_entity(bfq_entity_service_tree(entity), entity);
658664
bfqg_and_blkg_put(bfqq_group(bfqq));
659665

@@ -670,6 +676,8 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
670676

671677
if (!bfqd->in_service_queue && !bfqd->rq_in_driver)
672678
bfq_schedule_dispatch(bfqd);
679+
/* release extra ref taken above */
680+
bfq_put_queue(bfqq);
673681
}
674682

675683
/**
@@ -1398,6 +1406,10 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
13981406
return bfqq->bfqd->root_group;
13991407
}
14001408

1409+
void bfqg_and_blkg_get(struct bfq_group *bfqg) {}
1410+
1411+
void bfqg_and_blkg_put(struct bfq_group *bfqg) {}
1412+
14011413
struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node)
14021414
{
14031415
struct bfq_group *bfqg;

block/bfq-iosched.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq)
613613
bfqq->pos_root = NULL;
614614
}
615615

616+
/* oom_bfqq does not participate in queue merging */
617+
if (bfqq == &bfqd->oom_bfqq)
618+
return;
619+
616620
/*
617621
* bfqq cannot be merged any longer (see comments in
618622
* bfq_setup_cooperator): no point in adding bfqq into the
@@ -1055,7 +1059,7 @@ bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd,
10551059

10561060
static int bfqq_process_refs(struct bfq_queue *bfqq)
10571061
{
1058-
return bfqq->ref - bfqq->allocated - bfqq->entity.on_st -
1062+
return bfqq->ref - bfqq->allocated - bfqq->entity.on_st_or_in_serv -
10591063
(bfqq->weight_counter != NULL);
10601064
}
10611065

@@ -3443,6 +3447,10 @@ static void bfq_dispatch_remove(struct request_queue *q, struct request *rq)
34433447
static bool idling_needed_for_service_guarantees(struct bfq_data *bfqd,
34443448
struct bfq_queue *bfqq)
34453449
{
3450+
/* No point in idling for bfqq if it won't get requests any longer */
3451+
if (unlikely(!bfqq_process_refs(bfqq)))
3452+
return false;
3453+
34463454
return (bfqq->wr_coeff > 1 &&
34473455
(bfqd->wr_busy_queues <
34483456
bfq_tot_busy_queues(bfqd) ||
@@ -4076,6 +4084,10 @@ static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd,
40764084
bfqq_sequential_and_IO_bound,
40774085
idling_boosts_thr;
40784086

4087+
/* No point in idling for bfqq if it won't get requests any longer */
4088+
if (unlikely(!bfqq_process_refs(bfqq)))
4089+
return false;
4090+
40794091
bfqq_sequential_and_IO_bound = !BFQQ_SEEKY(bfqq) &&
40804092
bfq_bfqq_IO_bound(bfqq) && bfq_bfqq_has_short_ttime(bfqq);
40814093

@@ -4169,6 +4181,10 @@ static bool bfq_better_to_idle(struct bfq_queue *bfqq)
41694181
struct bfq_data *bfqd = bfqq->bfqd;
41704182
bool idling_boosts_thr_with_no_issue, idling_needed_for_service_guar;
41714183

4184+
/* No point in idling for bfqq if it won't get requests any longer */
4185+
if (unlikely(!bfqq_process_refs(bfqq)))
4186+
return false;
4187+
41724188
if (unlikely(bfqd->strict_guarantees))
41734189
return true;
41744190

@@ -4809,9 +4825,7 @@ void bfq_put_queue(struct bfq_queue *bfqq)
48094825
{
48104826
struct bfq_queue *item;
48114827
struct hlist_node *n;
4812-
#ifdef CONFIG_BFQ_GROUP_IOSCHED
48134828
struct bfq_group *bfqg = bfqq_group(bfqq);
4814-
#endif
48154829

48164830
if (bfqq->bfqd)
48174831
bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p %d",
@@ -4884,9 +4898,7 @@ void bfq_put_queue(struct bfq_queue *bfqq)
48844898
bfqq->bfqd->last_completed_rq_bfqq = NULL;
48854899

48864900
kmem_cache_free(bfq_pool, bfqq);
4887-
#ifdef CONFIG_BFQ_GROUP_IOSCHED
48884901
bfqg_and_blkg_put(bfqg);
4889-
#endif
48904902
}
48914903

48924904
static void bfq_put_cooperator(struct bfq_queue *bfqq)
@@ -5967,6 +5979,8 @@ static void bfq_finish_requeue_request(struct request *rq)
59675979
}
59685980

59695981
/*
5982+
* Removes the association between the current task and bfqq, assuming
5983+
* that bic points to the bfq iocontext of the task.
59705984
* Returns NULL if a new bfqq should be allocated, or the old bfqq if this
59715985
* was the last process referring to that bfqq.
59725986
*/
@@ -6374,10 +6388,10 @@ static void bfq_exit_queue(struct elevator_queue *e)
63746388

63756389
hrtimer_cancel(&bfqd->idle_slice_timer);
63766390

6377-
#ifdef CONFIG_BFQ_GROUP_IOSCHED
63786391
/* release oom-queue reference to root group */
63796392
bfqg_and_blkg_put(bfqd->root_group);
63806393

6394+
#ifdef CONFIG_BFQ_GROUP_IOSCHED
63816395
blkcg_deactivate_policy(bfqd->queue, &blkcg_policy_bfq);
63826396
#else
63836397
spin_lock_irq(&bfqd->lock);

block/bfq-iosched.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct bfq_entity {
150150
* Flag, true if the entity is on a tree (either the active or
151151
* the idle one of its service_tree) or is in service.
152152
*/
153-
bool on_st;
153+
bool on_st_or_in_serv;
154154

155155
/* B-WF2Q+ start and finish timestamps [sectors/weight] */
156156
u64 start, finish;
@@ -921,6 +921,7 @@ struct bfq_group {
921921

922922
#else
923923
struct bfq_group {
924+
struct bfq_entity entity;
924925
struct bfq_sched_data sched_data;
925926

926927
struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR];
@@ -984,6 +985,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
984985
struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg);
985986
struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
986987
struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node);
988+
void bfqg_and_blkg_get(struct bfq_group *bfqg);
987989
void bfqg_and_blkg_put(struct bfq_group *bfqg);
988990

989991
#ifdef CONFIG_BFQ_GROUP_IOSCHED

block/bfq-wf2q.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ static void bfq_get_entity(struct bfq_entity *entity)
533533
bfqq->ref++;
534534
bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d",
535535
bfqq, bfqq->ref);
536-
}
536+
} else
537+
bfqg_and_blkg_get(container_of(entity, struct bfq_group,
538+
entity));
537539
}
538540

539541
/**
@@ -645,10 +647,16 @@ static void bfq_forget_entity(struct bfq_service_tree *st,
645647
{
646648
struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity);
647649

648-
entity->on_st = false;
650+
entity->on_st_or_in_serv = false;
649651
st->wsum -= entity->weight;
650-
if (bfqq && !is_in_service)
652+
if (is_in_service)
653+
return;
654+
655+
if (bfqq)
651656
bfq_put_queue(bfqq);
657+
else
658+
bfqg_and_blkg_put(container_of(entity, struct bfq_group,
659+
entity));
652660
}
653661

654662
/**
@@ -999,7 +1007,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
9991007
*/
10001008
bfq_get_entity(entity);
10011009

1002-
entity->on_st = true;
1010+
entity->on_st_or_in_serv = true;
10031011
}
10041012

10051013
#ifdef CONFIG_BFQ_GROUP_IOSCHED
@@ -1165,7 +1173,10 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree)
11651173
struct bfq_service_tree *st;
11661174
bool is_in_service;
11671175

1168-
if (!entity->on_st) /* entity never activated, or already inactive */
1176+
if (!entity->on_st_or_in_serv) /*
1177+
* entity never activated, or
1178+
* already inactive
1179+
*/
11691180
return false;
11701181

11711182
/*
@@ -1620,7 +1631,7 @@ bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd)
16201631
* service tree either, then release the service reference to
16211632
* the queue it represents (taken with bfq_get_entity).
16221633
*/
1623-
if (!in_serv_entity->on_st) {
1634+
if (!in_serv_entity->on_st_or_in_serv) {
16241635
/*
16251636
* If no process is referencing in_serv_bfqq any
16261637
* longer, then the service reference may be the only

drivers/block/brd.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,25 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
473473
return kobj;
474474
}
475475

476+
static inline void brd_check_and_reset_par(void)
477+
{
478+
if (unlikely(!max_part))
479+
max_part = 1;
480+
481+
/*
482+
* make sure 'max_part' can be divided exactly by (1U << MINORBITS),
483+
* otherwise, it is possiable to get same dev_t when adding partitions.
484+
*/
485+
if ((1U << MINORBITS) % max_part != 0)
486+
max_part = 1UL << fls(max_part);
487+
488+
if (max_part > DISK_MAX_PARTS) {
489+
pr_info("brd: max_part can't be larger than %d, reset max_part = %d.\n",
490+
DISK_MAX_PARTS, DISK_MAX_PARTS);
491+
max_part = DISK_MAX_PARTS;
492+
}
493+
}
494+
476495
static int __init brd_init(void)
477496
{
478497
struct brd_device *brd, *next;
@@ -496,8 +515,7 @@ static int __init brd_init(void)
496515
if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
497516
return -EIO;
498517

499-
if (unlikely(!max_part))
500-
max_part = 1;
518+
brd_check_and_reset_par();
501519

502520
for (i = 0; i < rd_nr; i++) {
503521
brd = brd_alloc(i);

drivers/block/drbd/drbd_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ struct fifo_buffer {
622622
int total; /* sum of all values */
623623
int values[0];
624624
};
625-
extern struct fifo_buffer *fifo_alloc(int fifo_size);
625+
extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size);
626626

627627
/* flag bits per connection */
628628
enum {

drivers/block/drbd/drbd_nl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,8 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
15751575
struct drbd_device *device;
15761576
struct disk_conf *new_disk_conf, *old_disk_conf;
15771577
struct fifo_buffer *old_plan = NULL, *new_plan = NULL;
1578-
int err, fifo_size;
1578+
int err;
1579+
unsigned int fifo_size;
15791580

15801581
retcode = drbd_adm_prepare(&adm_ctx, skb, info, DRBD_ADM_NEED_MINOR);
15811582
if (!adm_ctx.reply_skb)

drivers/block/drbd/drbd_receiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,7 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i
38873887
struct disk_conf *old_disk_conf = NULL, *new_disk_conf = NULL;
38883888
const int apv = connection->agreed_pro_version;
38893889
struct fifo_buffer *old_plan = NULL, *new_plan = NULL;
3890-
int fifo_size = 0;
3890+
unsigned int fifo_size = 0;
38913891
int err;
38923892

38933893
peer_device = conn_peer_device(connection, pi->vnr);

drivers/block/drbd/drbd_worker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ static void fifo_add_val(struct fifo_buffer *fb, int value)
482482
fb->values[i] += value;
483483
}
484484

485-
struct fifo_buffer *fifo_alloc(int fifo_size)
485+
struct fifo_buffer *fifo_alloc(unsigned int fifo_size)
486486
{
487487
struct fifo_buffer *fb;
488488

489-
fb = kzalloc(sizeof(struct fifo_buffer) + sizeof(int) * fifo_size, GFP_NOIO);
489+
fb = kzalloc(struct_size(fb, values, fifo_size), GFP_NOIO);
490490
if (!fb)
491491
return NULL;
492492

0 commit comments

Comments
 (0)