Pull block fixes from Jens Axboe: - NVMe pull request from Christoph, fixing namespace locking when dealing with the effects log, and a rapid add/remove issue (Keith) - blktrace tweak, ensuring requests with -1 sectors are shown (Jan) - link power management quirk for a Smasung SSD (Hans) - m68k nfblock dynamic major number fix (Chengguang) - series fixing blk-iolatency inflight counter issue (Liu) - ensure that we clear ->private when setting up the aio kiocb (Mike) - __find_get_block_slow() rate limit print (Tetsuo) * tag 'for-linus-20190209' of git://git.kernel.dk/linux-block: blk-mq: remove duplicated definition of blk_mq_freeze_queue Blk-iolatency: warn on negative inflight IO counter blk-iolatency: fix IO hang due to negative inflight counter blktrace: Show requests without sector fs: ratelimit __find_get_block_slow() failure message. m68k: set proper major_num when specifying module param major_num libata: Add NOLPM quirk for SAMSUNG MZ7TE512HMHP-000L1 SSD nvme-pci: fix rapid add remove sequence nvme: lock NS list changes while handling command effects aio: initialize kiocb private in case any filesystems expect it.
Unified · Split
| @@ -155,18 +155,22 @@ out: · 154 unmodified lines | ||
| 155 | 155 | static int __init nfhd_init(void) |
| 156 | 156 | { |
| 157 | 157 | u32 blocks, bsize; |
| 158 | + int ret; | |
| 158 | 159 | int i; |
| 159 | 160 | |
| 160 | 161 | nfhd_id = nf_get_id("XHDI"); |
| 161 | 162 | if (!nfhd_id) |
| 162 | 163 | return -ENODEV; |
| 163 | 164 | |
| 164 | − major_num = register_blkdev(major_num, "nfhd"); | |
| 165 | − if (major_num <= 0) { | |
| 165 | + ret = register_blkdev(major_num, "nfhd"); | |
| 166 | + if (ret < 0) { | |
| 166 | 167 | pr_warn("nfhd: unable to get major number\n"); |
| 167 | − return major_num; | |
| 168 | + return ret; | |
| 168 | 169 | } |
| 169 | 170 | |
| 171 | + if (!major_num) | |
| 172 | + major_num = ret; | |
| 173 | + | |
| 170 | 174 | for (i = NFHD_DEV_OFFSET; i < 24; i++) { |
| 171 | 175 | if (nfhd_get_capacity(i, 0, &blocks, &bsize)) |
| 172 | 176 | continue; |
| @@ -72,6 +72,7 @@ · 71 unmodified lines | ||
| 72 | 72 | #include <linux/sched/loadavg.h> |
| 73 | 73 | #include <linux/sched/signal.h> |
| 74 | 74 | #include <trace/events/block.h> |
| 75 | +#include <linux/blk-mq.h> | |
| 75 | 76 | #include "blk-rq-qos.h" |
| 76 | 77 | #include "blk-stat.h" |
| 77 | 78 | |
| @@ -591,6 +592,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) · 513 unmodified lines | ||
| 591 | 592 | u64 now = ktime_to_ns(ktime_get()); |
| 592 | 593 | bool issue_as_root = bio_issue_as_root_blkg(bio); |
| 593 | 594 | bool enabled = false; |
| 595 | + int inflight = 0; | |
| 594 | 596 | |
| 595 | 597 | blkg = bio->bi_blkg; |
| 596 | 598 | if (!blkg || !bio_flagged(bio, BIO_TRACKED)) |
| @@ -601,6 +603,9 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) · 4 unmodified lines | ||
| 601 | 603 | return; |
| 602 | 604 | |
| 603 | 605 | enabled = blk_iolatency_enabled(iolat->blkiolat); |
| 606 | + if (!enabled) | |
| 607 | + return; | |
| 608 | + | |
| 604 | 609 | while (blkg && blkg->parent) { |
| 605 | 610 | iolat = blkg_to_lat(blkg); |
| 606 | 611 | if (!iolat) { |
| @@ -609,8 +614,9 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) · 2 unmodified lines | ||
| 609 | 614 | } |
| 610 | 615 | rqw = &iolat->rq_wait; |
| 611 | 616 | |
| 612 | − atomic_dec(&rqw->inflight); | |
| 613 | − if (!enabled || iolat->min_lat_nsec == 0) | |
| 617 | + inflight = atomic_dec_return(&rqw->inflight); | |
| 618 | + WARN_ON_ONCE(inflight < 0); | |
| 619 | + if (iolat->min_lat_nsec == 0) | |
| 614 | 620 | goto next; |
| 615 | 621 | iolatency_record_time(iolat, &bio->bi_issue, now, |
| 616 | 622 | issue_as_root); |
| @@ -754,10 +760,13 @@ int blk_iolatency_init(struct request_queue *q) · 137 unmodified lines | ||
| 754 | 760 | return 0; |
| 755 | 761 | } |
| 756 | 762 | |
| 757 | −static void iolatency_set_min_lat_nsec(struct blkcg_gq *blkg, u64 val) | |
| 763 | +/* | |
| 764 | + * return 1 for enabling iolatency, return -1 for disabling iolatency, otherwise | |
| 765 | + * return 0. | |
| 766 | + */ | |
| 767 | +static int iolatency_set_min_lat_nsec(struct blkcg_gq *blkg, u64 val) | |
| 758 | 768 | { |
| 759 | 769 | struct iolatency_grp *iolat = blkg_to_lat(blkg); |
| 760 | − struct blk_iolatency *blkiolat = iolat->blkiolat; | |
| 761 | 770 | u64 oldval = iolat->min_lat_nsec; |
| 762 | 771 | |
| 763 | 772 | iolat->min_lat_nsec = val; |
| @@ -766,9 +775,10 @@ static void iolatency_set_min_lat_nsec(struct blkcg_gq *blkg, u64 val) · 2 unmodified lines | ||
| 766 | 775 | BLKIOLATENCY_MAX_WIN_SIZE); |
| 767 | 776 | |
| 768 | 777 | if (!oldval && val) |
| 769 | − atomic_inc(&blkiolat->enabled); | |
| 778 | + return 1; | |
| 770 | 779 | if (oldval && !val) |
| 771 | − atomic_dec(&blkiolat->enabled); | |
| 780 | + return -1; | |
| 781 | + return 0; | |
| 772 | 782 | } |
| 773 | 783 | |
| 774 | 784 | static void iolatency_clear_scaling(struct blkcg_gq *blkg) |
| @@ -800,6 +810,7 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, · 25 unmodified lines | ||
| 800 | 810 | u64 lat_val = 0; |
| 801 | 811 | u64 oldval; |
| 802 | 812 | int ret; |
| 813 | + int enable = 0; | |
| 803 | 814 | |
| 804 | 815 | ret = blkg_conf_prep(blkcg, &blkcg_policy_iolatency, buf, &ctx); |
| 805 | 816 | if (ret) |
| @@ -834,7 +845,12 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, · 28 unmodified lines | ||
| 834 | 845 | blkg = ctx.blkg; |
| 835 | 846 | oldval = iolat->min_lat_nsec; |
| 836 | 847 | |
| 837 | − iolatency_set_min_lat_nsec(blkg, lat_val); | |
| 848 | + enable = iolatency_set_min_lat_nsec(blkg, lat_val); | |
| 849 | + if (enable) { | |
| 850 | + WARN_ON_ONCE(!blk_get_queue(blkg->q)); | |
| 851 | + blkg_get(blkg); | |
| 852 | + } | |
| 853 | + | |
| 838 | 854 | if (oldval != iolat->min_lat_nsec) { |
| 839 | 855 | iolatency_clear_scaling(blkg); |
| 840 | 856 | } |
| @@ -842,6 +858,24 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, · 1 unmodified line | ||
| 842 | 858 | ret = 0; |
| 843 | 859 | out: |
| 844 | 860 | blkg_conf_finish(&ctx); |
| 861 | + if (ret == 0 && enable) { | |
| 862 | + struct iolatency_grp *tmp = blkg_to_lat(blkg); | |
| 863 | + struct blk_iolatency *blkiolat = tmp->blkiolat; | |
| 864 | + | |
| 865 | + blk_mq_freeze_queue(blkg->q); | |
| 866 | + | |
| 867 | + if (enable == 1) | |
| 868 | + atomic_inc(&blkiolat->enabled); | |
| 869 | + else if (enable == -1) | |
| 870 | + atomic_dec(&blkiolat->enabled); | |
| 871 | + else | |
| 872 | + WARN_ON_ONCE(1); | |
| 873 | + | |
| 874 | + blk_mq_unfreeze_queue(blkg->q); | |
| 875 | + | |
| 876 | + blkg_put(blkg); | |
| 877 | + blk_put_queue(blkg->q); | |
| 878 | + } | |
| 845 | 879 | return ret ?: nbytes; |
| 846 | 880 | } |
| 847 | 881 | |
| @@ -977,8 +1011,14 @@ static void iolatency_pd_offline(struct blkg_policy_data *pd) · 129 unmodified lines | ||
| 977 | 1011 | { |
| 978 | 1012 | struct iolatency_grp *iolat = pd_to_lat(pd); |
| 979 | 1013 | struct blkcg_gq *blkg = lat_to_blkg(iolat); |
| 1014 | + struct blk_iolatency *blkiolat = iolat->blkiolat; | |
| 1015 | + int ret; | |
| 980 | 1016 | |
| 981 | − iolatency_set_min_lat_nsec(blkg, 0); | |
| 1017 | + ret = iolatency_set_min_lat_nsec(blkg, 0); | |
| 1018 | + if (ret == 1) | |
| 1019 | + atomic_inc(&blkiolat->enabled); | |
| 1020 | + if (ret == -1) | |
| 1021 | + atomic_dec(&blkiolat->enabled); | |
| 982 | 1022 | iolatency_clear_scaling(blkg); |
| 983 | 1023 | } |
| 984 | 1024 | |
| @@ -36,7 +36,6 @@ struct blk_mq_ctx { · 35 unmodified lines | ||
| 36 | 36 | struct kobject kobj; |
| 37 | 37 | } ____cacheline_aligned_in_smp; |
| 38 | 38 | |
| 39 | −void blk_mq_freeze_queue(struct request_queue *q); | |
| 40 | 39 | void blk_mq_free_queue(struct request_queue *q); |
| 41 | 40 | int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr); |
| 42 | 41 | void blk_mq_wake_waiters(struct request_queue *q); |
| @@ -4554,6 +4554,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { · 4553 unmodified lines | ||
| 4554 | 4554 | { "SAMSUNG MZMPC128HBFU-000MV", "CXM14M1Q", ATA_HORKAGE_NOLPM, }, |
| 4555 | 4555 | { "SAMSUNG SSD PM830 mSATA *", "CXM13D1Q", ATA_HORKAGE_NOLPM, }, |
| 4556 | 4556 | { "SAMSUNG MZ7TD256HAFV-000L9", NULL, ATA_HORKAGE_NOLPM, }, |
| 4557 | + { "SAMSUNG MZ7TE512HMHP-000L1", "EXT06L0Q", ATA_HORKAGE_NOLPM, }, | |
| 4557 | 4558 | |
| 4558 | 4559 | /* devices that don't properly handle queued TRIM commands */ |
| 4559 | 4560 | { "Micron_M500IT_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | |
| @@ -1253,6 +1253,7 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, · 1252 unmodified lines | ||
| 1253 | 1253 | * effects say only one namespace is affected. |
| 1254 | 1254 | */ |
| 1255 | 1255 | if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) { |
| 1256 | + mutex_lock(&ctrl->scan_lock); | |
| 1256 | 1257 | nvme_start_freeze(ctrl); |
| 1257 | 1258 | nvme_wait_freeze(ctrl); |
| 1258 | 1259 | } |
| @@ -1281,8 +1282,10 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) · 22 unmodified lines | ||
| 1281 | 1282 | */ |
| 1282 | 1283 | if (effects & NVME_CMD_EFFECTS_LBCC) |
| 1283 | 1284 | nvme_update_formats(ctrl); |
| 1284 | − if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) | |
| 1285 | + if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) { | |
| 1285 | 1286 | nvme_unfreeze(ctrl); |
| 1287 | + mutex_unlock(&ctrl->scan_lock); | |
| 1288 | + } | |
| 1286 | 1289 | if (effects & NVME_CMD_EFFECTS_CCC) |
| 1287 | 1290 | nvme_init_identify(ctrl); |
| 1288 | 1291 | if (effects & (NVME_CMD_EFFECTS_NIC | NVME_CMD_EFFECTS_NCC)) |
| @@ -3401,6 +3404,7 @@ static void nvme_scan_work(struct work_struct *work) · 2112 unmodified lines | ||
| 3401 | 3404 | if (nvme_identify_ctrl(ctrl, &id)) |
| 3402 | 3405 | return; |
| 3403 | 3406 | |
| 3407 | + mutex_lock(&ctrl->scan_lock); | |
| 3404 | 3408 | nn = le32_to_cpu(id->nn); |
| 3405 | 3409 | if (ctrl->vs >= NVME_VS(1, 1, 0) && |
| 3406 | 3410 | !(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS)) { |
| @@ -3409,6 +3413,7 @@ static void nvme_scan_work(struct work_struct *work) · 2 unmodified lines | ||
| 3409 | 3413 | } |
| 3410 | 3414 | nvme_scan_ns_sequential(ctrl, nn); |
| 3411 | 3415 | out_free_id: |
| 3416 | + mutex_unlock(&ctrl->scan_lock); | |
| 3412 | 3417 | kfree(id); |
| 3413 | 3418 | down_write(&ctrl->namespaces_rwsem); |
| 3414 | 3419 | list_sort(NULL, &ctrl->namespaces, ns_cmp); |
| @@ -3652,6 +3657,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, · 237 unmodified lines | ||
| 3652 | 3657 | |
| 3653 | 3658 | ctrl->state = NVME_CTRL_NEW; |
| 3654 | 3659 | spin_lock_init(&ctrl->lock); |
| 3660 | + mutex_init(&ctrl->scan_lock); | |
| 3655 | 3661 | INIT_LIST_HEAD(&ctrl->namespaces); |
| 3656 | 3662 | init_rwsem(&ctrl->namespaces_rwsem); |
| 3657 | 3663 | ctrl->dev = dev; |
| @@ -154,6 +154,7 @@ struct nvme_ctrl { · 153 unmodified lines | ||
| 154 | 154 | enum nvme_ctrl_state state; |
| 155 | 155 | bool identified; |
| 156 | 156 | spinlock_t lock; |
| 157 | + struct mutex scan_lock; | |
| 157 | 158 | const struct nvme_ctrl_ops *ops; |
| 158 | 159 | struct request_queue *admin_q; |
| 159 | 160 | struct request_queue *connect_q; |
| @@ -2557,16 +2557,7 @@ static void nvme_reset_work(struct work_struct *work) · 2556 unmodified lines | ||
| 2557 | 2557 | if (dev->ctrl.ctrl_config & NVME_CC_ENABLE) |
| 2558 | 2558 | nvme_dev_disable(dev, false); |
| 2559 | 2559 | |
| 2560 | − /* | |
| 2561 | − * Introduce CONNECTING state from nvme-fc/rdma transports to mark the | |
| 2562 | − * initializing procedure here. | |
| 2563 | − */ | |
| 2564 | − if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_CONNECTING)) { | |
| 2565 | − dev_warn(dev->ctrl.device, | |
| 2566 | − "failed to mark controller CONNECTING\n"); | |
| 2567 | − goto out; | |
| 2568 | − } | |
| 2569 | − | |
| 2560 | + mutex_lock(&dev->shutdown_lock); | |
| 2570 | 2561 | result = nvme_pci_enable(dev); |
| 2571 | 2562 | if (result) |
| 2572 | 2563 | goto out; |
| @@ -2585,6 +2576,17 @@ static void nvme_reset_work(struct work_struct *work) · 12 unmodified lines | ||
| 2585 | 2576 | */ |
| 2586 | 2577 | dev->ctrl.max_hw_sectors = NVME_MAX_KB_SZ << 1; |
| 2587 | 2578 | dev->ctrl.max_segments = NVME_MAX_SEGS; |
| 2579 | + mutex_unlock(&dev->shutdown_lock); | |
| 2580 | + | |
| 2581 | + /* | |
| 2582 | + * Introduce CONNECTING state from nvme-fc/rdma transports to mark the | |
| 2583 | + * initializing procedure here. | |
| 2584 | + */ | |
| 2585 | + if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_CONNECTING)) { | |
| 2586 | + dev_warn(dev->ctrl.device, | |
| 2587 | + "failed to mark controller CONNECTING\n"); | |
| 2588 | + goto out; | |
| 2589 | + } | |
| 2588 | 2590 | |
| 2589 | 2591 | result = nvme_init_identify(&dev->ctrl); |
| 2590 | 2592 | if (result) |
| @@ -1436,6 +1436,7 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb) · 1435 unmodified lines | ||
| 1436 | 1436 | if (unlikely(!req->ki_filp)) |
| 1437 | 1437 | return -EBADF; |
| 1438 | 1438 | req->ki_complete = aio_complete_rw; |
| 1439 | + req->private = NULL; | |
| 1439 | 1440 | req->ki_pos = iocb->aio_offset; |
| 1440 | 1441 | req->ki_flags = iocb_flags(req->ki_filp); |
| 1441 | 1442 | if (iocb->aio_flags & IOCB_FLAG_RESFD) |
| @@ -200,6 +200,7 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) · 199 unmodified lines | ||
| 200 | 200 | struct buffer_head *head; |
| 201 | 201 | struct page *page; |
| 202 | 202 | int all_mapped = 1; |
| 203 | + static DEFINE_RATELIMIT_STATE(last_warned, HZ, 1); | |
| 203 | 204 | |
| 204 | 205 | index = block >> (PAGE_SHIFT - bd_inode->i_blkbits); |
| 205 | 206 | page = find_get_page_flags(bd_mapping, index, FGP_ACCESSED); |
| @@ -227,15 +228,15 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) · 21 unmodified lines | ||
| 227 | 228 | * file io on the block device and getblk. It gets dealt with |
| 228 | 229 | * elsewhere, don't buffer_error if we had some unmapped buffers |
| 229 | 230 | */ |
| 230 | − if (all_mapped) { | |
| 231 | − printk("__find_get_block_slow() failed. " | |
| 232 | − "block=%llu, b_blocknr=%llu\n", | |
| 233 | − (unsigned long long)block, | |
| 234 | − (unsigned long long)bh->b_blocknr); | |
| 235 | − printk("b_state=0x%08lx, b_size=%zu\n", | |
| 236 | − bh->b_state, bh->b_size); | |
| 237 | − printk("device %pg blocksize: %d\n", bdev, | |
| 238 | − 1 << bd_inode->i_blkbits); | |
| 231 | + ratelimit_set_flags(&last_warned, RATELIMIT_MSG_ON_RELEASE); | |
| 232 | + if (all_mapped && __ratelimit(&last_warned)) { | |
| 233 | + printk("__find_get_block_slow() failed. block=%llu, " | |
| 234 | + "b_blocknr=%llu, b_state=0x%08lx, b_size=%zu, " | |
| 235 | + "device %pg blocksize: %d\n", | |
| 236 | + (unsigned long long)block, | |
| 237 | + (unsigned long long)bh->b_blocknr, | |
| 238 | + bh->b_state, bh->b_size, bdev, | |
| 239 | + 1 << bd_inode->i_blkbits); | |
| 239 | 240 | } |
| 240 | 241 | out_unlock: |
| 241 | 242 | spin_unlock(&bd_mapping->private_lock); |
| @@ -116,7 +116,13 @@ extern void blk_fill_rwbs(char *rwbs, unsigned int op, int bytes); · 115 unmodified lines | ||
| 116 | 116 | |
| 117 | 117 | static inline sector_t blk_rq_trace_sector(struct request *rq) |
| 118 | 118 | { |
| 119 | − return blk_rq_is_passthrough(rq) ? 0 : blk_rq_pos(rq); | |
| 119 | + /* | |
| 120 | + * Tracing should ignore starting sector for passthrough requests and | |
| 121 | + * requests where starting sector didn't get set. | |
| 122 | + */ | |
| 123 | + if (blk_rq_is_passthrough(rq) || blk_rq_pos(rq) == (sector_t)-1) | |
| 124 | + return 0; | |
| 125 | + return blk_rq_pos(rq); | |
| 120 | 126 | } |
| 121 | 127 | |
| 122 | 128 | static inline unsigned int blk_rq_trace_nr_sectors(struct request *rq) |