Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"It's been a few weeks, so here's a small collection of fixes that
should go into the current series.

This contains:

- NVMe pull request from Christoph, with a few important fixes.

- kyber hang fix from Omar.

- A blk-throttl fix from Shaohua, fixing a case where we double
charge a bio.

- Two call_single_data alignment fixes from me, fixing up some
unfortunate changes that went into 4.14 without being properly
reviewed on the block side (since nobody was CC'ed on the
patch...).

- A bounce buffer fix in two parts, one from me and one from Ming.

- Revert bdi debug error handling patch. It's causing boot issues for
some folks, and a week down the line, we're still no closer to a
fix. Revert this patch for now until it's figured out, then we can
retry for 4.16"

* 'for-linus' of git://git.kernel.dk/linux-block:
Revert "bdi: add error handle for bdi_debug_register"
null_blk: unalign call_single_data
block: unalign call_single_data in struct request
block-throttle: avoid double charge
block: fix blk_rq_append_bio
block: don't let passthrough IO go into .make_request_fn()
nvme: setup streams after initializing namespace head
nvme: check hw sectors before setting chunk sectors
nvme: call blk_integrity_unregister after queue is cleaned up
nvme-fc: remove double put reference if admin connect fails
nvme: set discard_alignment to zero
kyber: fix another domain token wait queue hang

+95 -63
+2
block/bio.c
··· 599 599 bio->bi_disk = bio_src->bi_disk; 600 600 bio->bi_partno = bio_src->bi_partno; 601 601 bio_set_flag(bio, BIO_CLONED); 602 + if (bio_flagged(bio_src, BIO_THROTTLED)) 603 + bio_set_flag(bio, BIO_THROTTLED); 602 604 bio->bi_opf = bio_src->bi_opf; 603 605 bio->bi_write_hint = bio_src->bi_write_hint; 604 606 bio->bi_iter = bio_src->bi_iter;
+22 -16
block/blk-map.c
··· 12 12 #include "blk.h" 13 13 14 14 /* 15 - * Append a bio to a passthrough request. Only works can be merged into 16 - * the request based on the driver constraints. 15 + * Append a bio to a passthrough request. Only works if the bio can be merged 16 + * into the request based on the driver constraints. 17 17 */ 18 - int blk_rq_append_bio(struct request *rq, struct bio *bio) 18 + int blk_rq_append_bio(struct request *rq, struct bio **bio) 19 19 { 20 - blk_queue_bounce(rq->q, &bio); 20 + struct bio *orig_bio = *bio; 21 + 22 + blk_queue_bounce(rq->q, bio); 21 23 22 24 if (!rq->bio) { 23 - blk_rq_bio_prep(rq->q, rq, bio); 25 + blk_rq_bio_prep(rq->q, rq, *bio); 24 26 } else { 25 - if (!ll_back_merge_fn(rq->q, rq, bio)) 27 + if (!ll_back_merge_fn(rq->q, rq, *bio)) { 28 + if (orig_bio != *bio) { 29 + bio_put(*bio); 30 + *bio = orig_bio; 31 + } 26 32 return -EINVAL; 33 + } 27 34 28 - rq->biotail->bi_next = bio; 29 - rq->biotail = bio; 30 - rq->__data_len += bio->bi_iter.bi_size; 35 + rq->biotail->bi_next = *bio; 36 + rq->biotail = *bio; 37 + rq->__data_len += (*bio)->bi_iter.bi_size; 31 38 } 32 39 33 40 return 0; ··· 80 73 * We link the bounce buffer in and could have to traverse it 81 74 * later so we have to get a ref to prevent it from being freed 82 75 */ 83 - ret = blk_rq_append_bio(rq, bio); 84 - bio_get(bio); 76 + ret = blk_rq_append_bio(rq, &bio); 85 77 if (ret) { 86 - bio_endio(bio); 87 78 __blk_rq_unmap_user(orig_bio); 88 - bio_put(bio); 89 79 return ret; 90 80 } 81 + bio_get(bio); 91 82 92 83 return 0; 93 84 } ··· 218 213 int reading = rq_data_dir(rq) == READ; 219 214 unsigned long addr = (unsigned long) kbuf; 220 215 int do_copy = 0; 221 - struct bio *bio; 216 + struct bio *bio, *orig_bio; 222 217 int ret; 223 218 224 219 if (len > (queue_max_hw_sectors(q) << 9)) ··· 241 236 if (do_copy) 242 237 rq->rq_flags |= RQF_COPY_USER; 243 238 244 - ret = blk_rq_append_bio(rq, bio); 239 + orig_bio = bio; 240 + ret = blk_rq_append_bio(rq, &bio); 245 241 if (unlikely(ret)) { 246 242 /* request is too big */ 247 - bio_put(bio); 243 + bio_put(orig_bio); 248 244 return ret; 249 245 } 250 246
+1 -7
block/blk-throttle.c
··· 2226 2226 out_unlock: 2227 2227 spin_unlock_irq(q->queue_lock); 2228 2228 out: 2229 - /* 2230 - * As multiple blk-throtls may stack in the same issue path, we 2231 - * don't want bios to leave with the flag set. Clear the flag if 2232 - * being issued. 2233 - */ 2234 - if (!throttled) 2235 - bio_clear_flag(bio, BIO_THROTTLED); 2229 + bio_set_flag(bio, BIO_THROTTLED); 2236 2230 2237 2231 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW 2238 2232 if (throttled || !td->track_bio_latency)
+4 -2
block/bounce.c
··· 200 200 unsigned i = 0; 201 201 bool bounce = false; 202 202 int sectors = 0; 203 + bool passthrough = bio_is_passthrough(*bio_orig); 203 204 204 205 bio_for_each_segment(from, *bio_orig, iter) { 205 206 if (i++ < BIO_MAX_PAGES) ··· 211 210 if (!bounce) 212 211 return; 213 212 214 - if (sectors < bio_sectors(*bio_orig)) { 213 + if (!passthrough && sectors < bio_sectors(*bio_orig)) { 215 214 bio = bio_split(*bio_orig, sectors, GFP_NOIO, bounce_bio_split); 216 215 bio_chain(bio, *bio_orig); 217 216 generic_make_request(*bio_orig); 218 217 *bio_orig = bio; 219 218 } 220 - bio = bio_clone_bioset(*bio_orig, GFP_NOIO, bounce_bio_set); 219 + bio = bio_clone_bioset(*bio_orig, GFP_NOIO, passthrough ? NULL : 220 + bounce_bio_set); 221 221 222 222 bio_for_each_segment_all(to, bio, i) { 223 223 struct page *page = to->bv_page;
+25 -14
block/kyber-iosched.c
··· 100 100 unsigned int cur_domain; 101 101 unsigned int batching; 102 102 wait_queue_entry_t domain_wait[KYBER_NUM_DOMAINS]; 103 + struct sbq_wait_state *domain_ws[KYBER_NUM_DOMAINS]; 103 104 atomic_t wait_index[KYBER_NUM_DOMAINS]; 104 105 }; 106 + 107 + static int kyber_domain_wake(wait_queue_entry_t *wait, unsigned mode, int flags, 108 + void *key); 105 109 106 110 static int rq_sched_domain(const struct request *rq) 107 111 { ··· 389 385 390 386 for (i = 0; i < KYBER_NUM_DOMAINS; i++) { 391 387 INIT_LIST_HEAD(&khd->rqs[i]); 388 + init_waitqueue_func_entry(&khd->domain_wait[i], 389 + kyber_domain_wake); 390 + khd->domain_wait[i].private = hctx; 392 391 INIT_LIST_HEAD(&khd->domain_wait[i].entry); 393 392 atomic_set(&khd->wait_index[i], 0); 394 393 } ··· 531 524 int nr; 532 525 533 526 nr = __sbitmap_queue_get(domain_tokens); 534 - if (nr >= 0) 535 - return nr; 536 527 537 528 /* 538 529 * If we failed to get a domain token, make sure the hardware queue is 539 530 * run when one becomes available. Note that this is serialized on 540 531 * khd->lock, but we still need to be careful about the waker. 541 532 */ 542 - if (list_empty_careful(&wait->entry)) { 543 - init_waitqueue_func_entry(wait, kyber_domain_wake); 544 - wait->private = hctx; 533 + if (nr < 0 && list_empty_careful(&wait->entry)) { 545 534 ws = sbq_wait_ptr(domain_tokens, 546 535 &khd->wait_index[sched_domain]); 536 + khd->domain_ws[sched_domain] = ws; 547 537 add_wait_queue(&ws->wait, wait); 548 538 549 539 /* 550 540 * Try again in case a token was freed before we got on the wait 551 - * queue. The waker may have already removed the entry from the 552 - * wait queue, but list_del_init() is okay with that. 541 + * queue. 553 542 */ 554 543 nr = __sbitmap_queue_get(domain_tokens); 555 - if (nr >= 0) { 556 - unsigned long flags; 557 - 558 - spin_lock_irqsave(&ws->wait.lock, flags); 559 - list_del_init(&wait->entry); 560 - spin_unlock_irqrestore(&ws->wait.lock, flags); 561 - } 562 544 } 545 + 546 + /* 547 + * If we got a token while we were on the wait queue, remove ourselves 548 + * from the wait queue to ensure that all wake ups make forward 549 + * progress. It's possible that the waker already deleted the entry 550 + * between the !list_empty_careful() check and us grabbing the lock, but 551 + * list_del_init() is okay with that. 552 + */ 553 + if (nr >= 0 && !list_empty_careful(&wait->entry)) { 554 + ws = khd->domain_ws[sched_domain]; 555 + spin_lock_irq(&ws->wait.lock); 556 + list_del_init(&wait->entry); 557 + spin_unlock_irq(&ws->wait.lock); 558 + } 559 + 563 560 return nr; 564 561 } 565 562
+2 -2
drivers/block/null_blk.c
··· 35 35 struct nullb_cmd { 36 36 struct list_head list; 37 37 struct llist_node ll_list; 38 - call_single_data_t csd; 38 + struct __call_single_data csd; 39 39 struct request *rq; 40 40 struct bio *bio; 41 41 unsigned int tag; 42 + blk_status_t error; 42 43 struct nullb_queue *nq; 43 44 struct hrtimer timer; 44 - blk_status_t error; 45 45 }; 46 46 47 47 struct nullb_queue {
+6 -5
drivers/nvme/host/core.c
··· 1287 1287 BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) < 1288 1288 NVME_DSM_MAX_RANGES); 1289 1289 1290 - queue->limits.discard_alignment = size; 1290 + queue->limits.discard_alignment = 0; 1291 1291 queue->limits.discard_granularity = size; 1292 1292 1293 1293 blk_queue_max_discard_sectors(queue, UINT_MAX); ··· 1705 1705 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); 1706 1706 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX)); 1707 1707 } 1708 - if (ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) 1708 + if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && 1709 + is_power_of_2(ctrl->max_hw_sectors)) 1709 1710 blk_queue_chunk_sectors(q, ctrl->max_hw_sectors); 1710 1711 blk_queue_virt_boundary(q, ctrl->page_size - 1); 1711 1712 if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) ··· 2870 2869 2871 2870 blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift); 2872 2871 nvme_set_queue_limits(ctrl, ns->queue); 2873 - nvme_setup_streams_ns(ctrl, ns); 2874 2872 2875 2873 id = nvme_identify_ns(ctrl, nsid); 2876 2874 if (!id) ··· 2880 2880 2881 2881 if (nvme_init_ns_head(ns, nsid, id, &new)) 2882 2882 goto out_free_id; 2883 + nvme_setup_streams_ns(ctrl, ns); 2883 2884 2884 2885 #ifdef CONFIG_NVME_MULTIPATH 2885 2886 /* ··· 2966 2965 return; 2967 2966 2968 2967 if (ns->disk && ns->disk->flags & GENHD_FL_UP) { 2969 - if (blk_get_integrity(ns->disk)) 2970 - blk_integrity_unregister(ns->disk); 2971 2968 nvme_mpath_remove_disk_links(ns); 2972 2969 sysfs_remove_group(&disk_to_dev(ns->disk)->kobj, 2973 2970 &nvme_ns_id_attr_group); ··· 2973 2974 nvme_nvm_unregister_sysfs(ns); 2974 2975 del_gendisk(ns->disk); 2975 2976 blk_cleanup_queue(ns->queue); 2977 + if (blk_get_integrity(ns->disk)) 2978 + blk_integrity_unregister(ns->disk); 2976 2979 } 2977 2980 2978 2981 mutex_lock(&ns->ctrl->subsys->lock);
-1
drivers/nvme/host/fc.c
··· 3221 3221 3222 3222 /* initiate nvme ctrl ref counting teardown */ 3223 3223 nvme_uninit_ctrl(&ctrl->ctrl); 3224 - nvme_put_ctrl(&ctrl->ctrl); 3225 3224 3226 3225 /* Remove core ctrl ref. */ 3227 3226 nvme_put_ctrl(&ctrl->ctrl);
+3 -1
drivers/scsi/osd/osd_initiator.c
··· 1576 1576 return req; 1577 1577 1578 1578 for_each_bio(bio) { 1579 - ret = blk_rq_append_bio(req, bio); 1579 + struct bio *bounce_bio = bio; 1580 + 1581 + ret = blk_rq_append_bio(req, &bounce_bio); 1580 1582 if (ret) 1581 1583 return ERR_PTR(ret); 1582 1584 }
+2 -2
drivers/target/target_core_pscsi.c
··· 920 920 " %d i: %d bio: %p, allocating another" 921 921 " bio\n", bio->bi_vcnt, i, bio); 922 922 923 - rc = blk_rq_append_bio(req, bio); 923 + rc = blk_rq_append_bio(req, &bio); 924 924 if (rc) { 925 925 pr_err("pSCSI: failed to append bio\n"); 926 926 goto fail; ··· 938 938 } 939 939 940 940 if (bio) { 941 - rc = blk_rq_append_bio(req, bio); 941 + rc = blk_rq_append_bio(req, &bio); 942 942 if (rc) { 943 943 pr_err("pSCSI: failed to append bio\n"); 944 944 goto fail;
+2
include/linux/bio.h
··· 492 492 493 493 #define bio_set_dev(bio, bdev) \ 494 494 do { \ 495 + if ((bio)->bi_disk != (bdev)->bd_disk) \ 496 + bio_clear_flag(bio, BIO_THROTTLED);\ 495 497 (bio)->bi_disk = (bdev)->bd_disk; \ 496 498 (bio)->bi_partno = (bdev)->bd_partno; \ 497 499 } while (0)
+4 -5
include/linux/blk_types.h
··· 50 50 struct bio { 51 51 struct bio *bi_next; /* request queue link */ 52 52 struct gendisk *bi_disk; 53 - u8 bi_partno; 54 - blk_status_t bi_status; 55 53 unsigned int bi_opf; /* bottom bits req flags, 56 54 * top bits REQ_OP. Use 57 55 * accessors. ··· 57 59 unsigned short bi_flags; /* status, etc and bvec pool number */ 58 60 unsigned short bi_ioprio; 59 61 unsigned short bi_write_hint; 60 - 61 - struct bvec_iter bi_iter; 62 + blk_status_t bi_status; 63 + u8 bi_partno; 62 64 63 65 /* Number of segments in this BIO after 64 66 * physical address coalescing is performed. ··· 72 74 unsigned int bi_seg_front_size; 73 75 unsigned int bi_seg_back_size; 74 76 75 - atomic_t __bi_remaining; 77 + struct bvec_iter bi_iter; 76 78 79 + atomic_t __bi_remaining; 77 80 bio_end_io_t *bi_end_io; 78 81 79 82 void *bi_private;
+21 -4
include/linux/blkdev.h
··· 135 135 struct request { 136 136 struct list_head queuelist; 137 137 union { 138 - call_single_data_t csd; 138 + struct __call_single_data csd; 139 139 u64 fifo_time; 140 140 }; 141 141 ··· 241 241 struct request *next_rq; 242 242 }; 243 243 244 + static inline bool blk_op_is_scsi(unsigned int op) 245 + { 246 + return op == REQ_OP_SCSI_IN || op == REQ_OP_SCSI_OUT; 247 + } 248 + 249 + static inline bool blk_op_is_private(unsigned int op) 250 + { 251 + return op == REQ_OP_DRV_IN || op == REQ_OP_DRV_OUT; 252 + } 253 + 244 254 static inline bool blk_rq_is_scsi(struct request *rq) 245 255 { 246 - return req_op(rq) == REQ_OP_SCSI_IN || req_op(rq) == REQ_OP_SCSI_OUT; 256 + return blk_op_is_scsi(req_op(rq)); 247 257 } 248 258 249 259 static inline bool blk_rq_is_private(struct request *rq) 250 260 { 251 - return req_op(rq) == REQ_OP_DRV_IN || req_op(rq) == REQ_OP_DRV_OUT; 261 + return blk_op_is_private(req_op(rq)); 252 262 } 253 263 254 264 static inline bool blk_rq_is_passthrough(struct request *rq) 255 265 { 256 266 return blk_rq_is_scsi(rq) || blk_rq_is_private(rq); 267 + } 268 + 269 + static inline bool bio_is_passthrough(struct bio *bio) 270 + { 271 + unsigned op = bio_op(bio); 272 + 273 + return blk_op_is_scsi(op) || blk_op_is_private(op); 257 274 } 258 275 259 276 static inline unsigned short req_get_ioprio(struct request *req) ··· 965 948 extern void blk_rq_unprep_clone(struct request *rq); 966 949 extern blk_status_t blk_insert_cloned_request(struct request_queue *q, 967 950 struct request *rq); 968 - extern int blk_rq_append_bio(struct request *rq, struct bio *bio); 951 + extern int blk_rq_append_bio(struct request *rq, struct bio **bio); 969 952 extern void blk_delay_queue(struct request_queue *, unsigned long); 970 953 extern void blk_queue_split(struct request_queue *, struct bio **); 971 954 extern void blk_recount_segments(struct request_queue *, struct bio *);
+1 -4
mm/backing-dev.c
··· 882 882 if (IS_ERR(dev)) 883 883 return PTR_ERR(dev); 884 884 885 - if (bdi_debug_register(bdi, dev_name(dev))) { 886 - device_destroy(bdi_class, dev->devt); 887 - return -ENOMEM; 888 - } 889 885 cgwb_bdi_register(bdi); 890 886 bdi->dev = dev; 891 887 888 + bdi_debug_register(bdi, dev_name(dev)); 892 889 set_bit(WB_registered, &bdi->wb.state); 893 890 894 891 spin_lock_bh(&bdi_lock);