Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit b4d88a6

Browse files
committed
Merge tag 'block-6.10-20240523' of git://git.kernel.dk/linux
Pull more block updates from Jens Axboe: "Followup block updates, mostly due to NVMe being a bit late to the party. But nothing major in there, so not a big deal. In detail, this contains: - NVMe pull request via Keith: - Fabrics connection retries (Daniel, Hannes) - Fabrics logging enhancements (Tokunori) - RDMA delete optimization (Sagi) - ublk DMA alignment fix (me) - null_blk sparse warning fixes (Bart) - Discard support for brd (Keith) - blk-cgroup list corruption fixes (Ming) - blk-cgroup stat propagation fix (Waiman) - Regression fix for plugging stall with md (Yu) - Misc fixes or cleanups (David, Jeff, Justin)" * tag 'block-6.10-20240523' of git://git.kernel.dk/linux: (24 commits) null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues' blk-throttle: remove unused struct 'avg_latency_bucket' block: fix lost bio for plug enabled bio based device block: t10-pi: add MODULE_DESCRIPTION() blk-mq: add helper for checking if one CPU is mapped to specified hctx blk-cgroup: Properly propagate the iostat update up the hierarchy blk-cgroup: fix list corruption from reorder of WRITE ->lqueued blk-cgroup: fix list corruption from resetting io stat cdrom: rearrange last_media_change check to avoid unintentional overflow nbd: Fix signal handling nbd: Remove a local variable from nbd_send_cmd() nbd: Improve the documentation of the locking assumptions nbd: Remove superfluous casts nbd: Use NULL to represent a pointer brd: implement discard support null_blk: Fix two sparse warnings ublk_drv: set DMA alignment mask to 3 nvme-rdma, nvme-tcp: include max reconnects for reconnect logging nvmet-rdma: Avoid o(n^2) loop in delete_ctrl nvme: do not retry authentication failures ...
2 parents 483a351 + a2db328 commit b4d88a6

File tree

26 files changed

+314
-186
lines changed

26 files changed

+314
-186
lines changed

block/blk-cgroup.c

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk,
322322
blkg->q = disk->queue;
323323
INIT_LIST_HEAD(&blkg->q_node);
324324
blkg->blkcg = blkcg;
325+
blkg->iostat.blkg = blkg;
325326
#ifdef CONFIG_BLK_CGROUP_PUNT_BIO
326327
spin_lock_init(&blkg->async_bio_lock);
327328
bio_list_init(&blkg->async_bios);
@@ -618,12 +619,45 @@ static void blkg_destroy_all(struct gendisk *disk)
618619
spin_unlock_irq(&q->queue_lock);
619620
}
620621

622+
static void blkg_iostat_set(struct blkg_iostat *dst, struct blkg_iostat *src)
623+
{
624+
int i;
625+
626+
for (i = 0; i < BLKG_IOSTAT_NR; i++) {
627+
dst->bytes[i] = src->bytes[i];
628+
dst->ios[i] = src->ios[i];
629+
}
630+
}
631+
632+
static void __blkg_clear_stat(struct blkg_iostat_set *bis)
633+
{
634+
struct blkg_iostat cur = {0};
635+
unsigned long flags;
636+
637+
flags = u64_stats_update_begin_irqsave(&bis->sync);
638+
blkg_iostat_set(&bis->cur, &cur);
639+
blkg_iostat_set(&bis->last, &cur);
640+
u64_stats_update_end_irqrestore(&bis->sync, flags);
641+
}
642+
643+
static void blkg_clear_stat(struct blkcg_gq *blkg)
644+
{
645+
int cpu;
646+
647+
for_each_possible_cpu(cpu) {
648+
struct blkg_iostat_set *s = per_cpu_ptr(blkg->iostat_cpu, cpu);
649+
650+
__blkg_clear_stat(s);
651+
}
652+
__blkg_clear_stat(&blkg->iostat);
653+
}
654+
621655
static int blkcg_reset_stats(struct cgroup_subsys_state *css,
622656
struct cftype *cftype, u64 val)
623657
{
624658
struct blkcg *blkcg = css_to_blkcg(css);
625659
struct blkcg_gq *blkg;
626-
int i, cpu;
660+
int i;
627661

628662
mutex_lock(&blkcg_pol_mutex);
629663
spin_lock_irq(&blkcg->lock);
@@ -634,18 +668,7 @@ static int blkcg_reset_stats(struct cgroup_subsys_state *css,
634668
* anyway. If you get hit by a race, retry.
635669
*/
636670
hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) {
637-
for_each_possible_cpu(cpu) {
638-
struct blkg_iostat_set *bis =
639-
per_cpu_ptr(blkg->iostat_cpu, cpu);
640-
memset(bis, 0, sizeof(*bis));
641-
642-
/* Re-initialize the cleared blkg_iostat_set */
643-
u64_stats_init(&bis->sync);
644-
bis->blkg = blkg;
645-
}
646-
memset(&blkg->iostat, 0, sizeof(blkg->iostat));
647-
u64_stats_init(&blkg->iostat.sync);
648-
671+
blkg_clear_stat(blkg);
649672
for (i = 0; i < BLKCG_MAX_POLS; i++) {
650673
struct blkcg_policy *pol = blkcg_policy[i];
651674

@@ -948,16 +971,6 @@ void blkg_conf_exit(struct blkg_conf_ctx *ctx)
948971
}
949972
EXPORT_SYMBOL_GPL(blkg_conf_exit);
950973

951-
static void blkg_iostat_set(struct blkg_iostat *dst, struct blkg_iostat *src)
952-
{
953-
int i;
954-
955-
for (i = 0; i < BLKG_IOSTAT_NR; i++) {
956-
dst->bytes[i] = src->bytes[i];
957-
dst->ios[i] = src->ios[i];
958-
}
959-
}
960-
961974
static void blkg_iostat_add(struct blkg_iostat *dst, struct blkg_iostat *src)
962975
{
963976
int i;
@@ -1023,7 +1036,19 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
10231036
struct blkg_iostat cur;
10241037
unsigned int seq;
10251038

1039+
/*
1040+
* Order assignment of `next_bisc` from `bisc->lnode.next` in
1041+
* llist_for_each_entry_safe and clearing `bisc->lqueued` for
1042+
* avoiding to assign `next_bisc` with new next pointer added
1043+
* in blk_cgroup_bio_start() in case of re-ordering.
1044+
*
1045+
* The pair barrier is implied in llist_add() in blk_cgroup_bio_start().
1046+
*/
1047+
smp_mb();
1048+
10261049
WRITE_ONCE(bisc->lqueued, false);
1050+
if (bisc == &blkg->iostat)
1051+
goto propagate_up; /* propagate up to parent only */
10271052

10281053
/* fetch the current per-cpu values */
10291054
do {
@@ -1033,10 +1058,24 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
10331058

10341059
blkcg_iostat_update(blkg, &cur, &bisc->last);
10351060

1061+
propagate_up:
10361062
/* propagate global delta to parent (unless that's root) */
1037-
if (parent && parent->parent)
1063+
if (parent && parent->parent) {
10381064
blkcg_iostat_update(parent, &blkg->iostat.cur,
10391065
&blkg->iostat.last);
1066+
/*
1067+
* Queue parent->iostat to its blkcg's lockless
1068+
* list to propagate up to the grandparent if the
1069+
* iostat hasn't been queued yet.
1070+
*/
1071+
if (!parent->iostat.lqueued) {
1072+
struct llist_head *plhead;
1073+
1074+
plhead = per_cpu_ptr(parent->blkcg->lhead, cpu);
1075+
llist_add(&parent->iostat.lnode, plhead);
1076+
parent->iostat.lqueued = true;
1077+
}
1078+
}
10401079
}
10411080
raw_spin_unlock_irqrestore(&blkg_stat_lock, flags);
10421081
out:

block/blk-core.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,14 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
615615

616616
static void __submit_bio(struct bio *bio)
617617
{
618+
/* If plug is not used, add new plug here to cache nsecs time. */
619+
struct blk_plug plug;
620+
618621
if (unlikely(!blk_crypto_bio_prep(&bio)))
619622
return;
620623

624+
blk_start_plug(&plug);
625+
621626
if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO)) {
622627
blk_mq_submit_bio(bio);
623628
} else if (likely(bio_queue_enter(bio) == 0)) {
@@ -626,6 +631,8 @@ static void __submit_bio(struct bio *bio)
626631
disk->fops->submit_bio(bio);
627632
blk_queue_exit(disk->queue);
628633
}
634+
635+
blk_finish_plug(&plug);
629636
}
630637

631638
/*
@@ -650,13 +657,11 @@ static void __submit_bio(struct bio *bio)
650657
static void __submit_bio_noacct(struct bio *bio)
651658
{
652659
struct bio_list bio_list_on_stack[2];
653-
struct blk_plug plug;
654660

655661
BUG_ON(bio->bi_next);
656662

657663
bio_list_init(&bio_list_on_stack[0]);
658664
current->bio_list = bio_list_on_stack;
659-
blk_start_plug(&plug);
660665

661666
do {
662667
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
@@ -690,23 +695,19 @@ static void __submit_bio_noacct(struct bio *bio)
690695
bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]);
691696
} while ((bio = bio_list_pop(&bio_list_on_stack[0])));
692697

693-
blk_finish_plug(&plug);
694698
current->bio_list = NULL;
695699
}
696700

697701
static void __submit_bio_noacct_mq(struct bio *bio)
698702
{
699703
struct bio_list bio_list[2] = { };
700-
struct blk_plug plug;
701704

702705
current->bio_list = bio_list;
703-
blk_start_plug(&plug);
704706

705707
do {
706708
__submit_bio(bio);
707709
} while ((bio = bio_list_pop(&bio_list[0])));
708710

709-
blk_finish_plug(&plug);
710711
current->bio_list = NULL;
711712
}
712713

block/blk-mq.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,12 +3545,28 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node)
35453545
return 0;
35463546
}
35473547

3548+
/*
3549+
* Check if one CPU is mapped to the specified hctx
3550+
*
3551+
* Isolated CPUs have been ruled out from hctx->cpumask, which is supposed
3552+
* to be used for scheduling kworker only. For other usage, please call this
3553+
* helper for checking if one CPU belongs to the specified hctx
3554+
*/
3555+
static bool blk_mq_cpu_mapped_to_hctx(unsigned int cpu,
3556+
const struct blk_mq_hw_ctx *hctx)
3557+
{
3558+
struct blk_mq_hw_ctx *mapped_hctx = blk_mq_map_queue_type(hctx->queue,
3559+
hctx->type, cpu);
3560+
3561+
return mapped_hctx == hctx;
3562+
}
3563+
35483564
static int blk_mq_hctx_notify_online(unsigned int cpu, struct hlist_node *node)
35493565
{
35503566
struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node,
35513567
struct blk_mq_hw_ctx, cpuhp_online);
35523568

3553-
if (cpumask_test_cpu(cpu, hctx->cpumask))
3569+
if (blk_mq_cpu_mapped_to_hctx(cpu, hctx))
35543570
clear_bit(BLK_MQ_S_INACTIVE, &hctx->state);
35553571
return 0;
35563572
}
@@ -3568,7 +3584,7 @@ static int blk_mq_hctx_notify_dead(unsigned int cpu, struct hlist_node *node)
35683584
enum hctx_type type;
35693585

35703586
hctx = hlist_entry_safe(node, struct blk_mq_hw_ctx, cpuhp_dead);
3571-
if (!cpumask_test_cpu(cpu, hctx->cpumask))
3587+
if (!blk_mq_cpu_mapped_to_hctx(cpu, hctx))
35723588
return 0;
35733589

35743590
ctx = __blk_mq_get_ctx(hctx->queue, cpu);

block/blk-throttle.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ struct latency_bucket {
3939
int samples;
4040
};
4141

42-
struct avg_latency_bucket {
43-
unsigned long latency; /* ns / 1024 */
44-
bool valid;
45-
};
46-
4742
struct throtl_data
4843
{
4944
/* service tree for active throtl groups */

block/t10-pi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,5 +495,5 @@ const struct blk_integrity_profile ext_pi_type3_crc64 = {
495495
};
496496
EXPORT_SYMBOL_GPL(ext_pi_type3_crc64);
497497

498-
MODULE_LICENSE("GPL");
498+
MODULE_DESCRIPTION("T10 Protection Information module");
499499
MODULE_LICENSE("GPL");

drivers/block/brd.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,36 @@ static int brd_do_bvec(struct brd_device *brd, struct page *page,
222222
return err;
223223
}
224224

225+
static void brd_do_discard(struct brd_device *brd, sector_t sector, u32 size)
226+
{
227+
sector_t aligned_sector = (sector + PAGE_SECTORS) & ~PAGE_SECTORS;
228+
struct page *page;
229+
230+
size -= (aligned_sector - sector) * SECTOR_SIZE;
231+
xa_lock(&brd->brd_pages);
232+
while (size >= PAGE_SIZE && aligned_sector < rd_size * 2) {
233+
page = __xa_erase(&brd->brd_pages, aligned_sector >> PAGE_SECTORS_SHIFT);
234+
if (page)
235+
__free_page(page);
236+
aligned_sector += PAGE_SECTORS;
237+
size -= PAGE_SIZE;
238+
}
239+
xa_unlock(&brd->brd_pages);
240+
}
241+
225242
static void brd_submit_bio(struct bio *bio)
226243
{
227244
struct brd_device *brd = bio->bi_bdev->bd_disk->private_data;
228245
sector_t sector = bio->bi_iter.bi_sector;
229246
struct bio_vec bvec;
230247
struct bvec_iter iter;
231248

249+
if (unlikely(op_is_discard(bio->bi_opf))) {
250+
brd_do_discard(brd, sector, bio->bi_iter.bi_size);
251+
bio_endio(bio);
252+
return;
253+
}
254+
232255
bio_for_each_segment(bvec, bio, iter) {
233256
unsigned int len = bvec.bv_len;
234257
int err;
@@ -309,6 +332,9 @@ static int brd_alloc(int i)
309332
* is harmless)
310333
*/
311334
.physical_block_size = PAGE_SIZE,
335+
.max_hw_discard_sectors = UINT_MAX,
336+
.max_discard_segments = 1,
337+
.discard_granularity = PAGE_SIZE,
312338
};
313339

314340
list_for_each_entry(brd, &brd_devices, brd_list)

0 commit comments

Comments
 (0)