Pull block fixes from Jens Axboe: "Not a lot here, which is great, basically just three small bcache fixes from Coly, and four NVMe fixes via Keith" * tag 'block-5.6-2020-02-16' of git://git.kernel.dk/linux-block: nvme: fix the parameter order for nvme_get_log in nvme_get_fw_slot_info nvme/pci: move cqe check after device shutdown nvme: prevent warning triggered by nvme_stop_keep_alive nvme/tcp: fix bug on double requeue when send fails bcache: remove macro nr_to_fifo_front() bcache: Revert "bcache: shrink btree node cache after bch_btree_check()" bcache: ignore pending signals when creating gc and allocator thread
Unified · Split
| @@ -67,6 +67,7 @@ · 66 unmodified lines | ||
| 67 | 67 | #include <linux/blkdev.h> |
| 68 | 68 | #include <linux/kthread.h> |
| 69 | 69 | #include <linux/random.h> |
| 70 | +#include <linux/sched/signal.h> | |
| 70 | 71 | #include <trace/events/bcache.h> |
| 71 | 72 | |
| 72 | 73 | #define MAX_OPEN_BUCKETS 128 |
| @@ -733,8 +734,21 @@ int bch_open_buckets_alloc(struct cache_set *c) · 660 unmodified lines | ||
| 733 | 734 | |
| 734 | 735 | int bch_cache_allocator_start(struct cache *ca) |
| 735 | 736 | { |
| 736 | − struct task_struct *k = kthread_run(bch_allocator_thread, | |
| 737 | − ca, "bcache_allocator"); | |
| 737 | + struct task_struct *k; | |
| 738 | + | |
| 739 | + /* | |
| 740 | + * In case previous btree check operation occupies too many | |
| 741 | + * system memory for bcache btree node cache, and the | |
| 742 | + * registering process is selected by OOM killer. Here just | |
| 743 | + * ignore the SIGKILL sent by OOM killer if there is, to | |
| 744 | + * avoid kthread_run() being failed by pending signals. The | |
| 745 | + * bcache registering process will exit after the registration | |
| 746 | + * done. | |
| 747 | + */ | |
| 748 | + if (signal_pending(current)) | |
| 749 | + flush_signals(current); | |
| 750 | + | |
| 751 | + k = kthread_run(bch_allocator_thread, ca, "bcache_allocator"); | |
| 738 | 752 | if (IS_ERR(k)) |
| 739 | 753 | return PTR_ERR(k); |
| 740 | 754 | |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include <linux/random.h> |
| 35 | 35 | #include <linux/rcupdate.h> |
| 36 | 36 | #include <linux/sched/clock.h> |
| 37 | +#include <linux/sched/signal.h> | |
| 37 | 38 | #include <linux/rculist.h> |
| 38 | 39 | #include <linux/delay.h> |
| 39 | 40 | #include <trace/events/bcache.h> |
| @@ -1913,6 +1914,18 @@ static int bch_gc_thread(void *arg) · 1873 unmodified lines | ||
| 1913 | 1914 | |
| 1914 | 1915 | int bch_gc_thread_start(struct cache_set *c) |
| 1915 | 1916 | { |
| 1917 | + /* | |
| 1918 | + * In case previous btree check operation occupies too many | |
| 1919 | + * system memory for bcache btree node cache, and the | |
| 1920 | + * registering process is selected by OOM killer. Here just | |
| 1921 | + * ignore the SIGKILL sent by OOM killer if there is, to | |
| 1922 | + * avoid kthread_run() being failed by pending signals. The | |
| 1923 | + * bcache registering process will exit after the registration | |
| 1924 | + * done. | |
| 1925 | + */ | |
| 1926 | + if (signal_pending(current)) | |
| 1927 | + flush_signals(current); | |
| 1928 | + | |
| 1916 | 1929 | c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc"); |
| 1917 | 1930 | return PTR_ERR_OR_ZERO(c->gc_thread); |
| 1918 | 1931 | } |
| @@ -417,8 +417,6 @@ err: · 416 unmodified lines | ||
| 417 | 417 | |
| 418 | 418 | /* Journalling */ |
| 419 | 419 | |
| 420 | −#define nr_to_fifo_front(p, front_p, mask) (((p) - (front_p)) & (mask)) | |
| 421 | − | |
| 422 | 420 | static void btree_flush_write(struct cache_set *c) |
| 423 | 421 | { |
| 424 | 422 | struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR]; |
| @@ -510,9 +508,8 @@ static void btree_flush_write(struct cache_set *c) · 85 unmodified lines | ||
| 510 | 508 | * journal entry can be reclaimed). These selected nodes |
| 511 | 509 | * will be ignored and skipped in the folowing for-loop. |
| 512 | 510 | */ |
| 513 | − if (nr_to_fifo_front(btree_current_write(b)->journal, | |
| 514 | − fifo_front_p, | |
| 515 | − mask) != 0) { | |
| 511 | + if (((btree_current_write(b)->journal - fifo_front_p) & | |
| 512 | + mask) != 0) { | |
| 516 | 513 | mutex_unlock(&b->write_lock); |
| 517 | 514 | continue; |
| 518 | 515 | } |
| @@ -1917,23 +1917,6 @@ static int run_cache_set(struct cache_set *c) · 1916 unmodified lines | ||
| 1917 | 1917 | if (bch_btree_check(c)) |
| 1918 | 1918 | goto err; |
| 1919 | 1919 | |
| 1920 | − /* | |
| 1921 | − * bch_btree_check() may occupy too much system memory which | |
| 1922 | − * has negative effects to user space application (e.g. data | |
| 1923 | − * base) performance. Shrink the mca cache memory proactively | |
| 1924 | − * here to avoid competing memory with user space workloads.. | |
| 1925 | − */ | |
| 1926 | − if (!c->shrinker_disabled) { | |
| 1927 | − struct shrink_control sc; | |
| 1928 | − | |
| 1929 | − sc.gfp_mask = GFP_KERNEL; | |
| 1930 | − sc.nr_to_scan = c->btree_cache_used * c->btree_pages; | |
| 1931 | − /* first run to clear b->accessed tag */ | |
| 1932 | − c->shrink.scan_objects(&c->shrink, &sc); | |
| 1933 | − /* second run to reap non-accessed nodes */ | |
| 1934 | − c->shrink.scan_objects(&c->shrink, &sc); | |
| 1935 | − } | |
| 1936 | − | |
| 1937 | 1920 | bch_journal_mark(c, &journal); |
| 1938 | 1921 | bch_initial_gc_finish(c); |
| 1939 | 1922 | pr_debug("btree_check() done"); |
| @@ -66,8 +66,8 @@ MODULE_PARM_DESC(streams, "turn on support for Streams write directives"); · 65 unmodified lines | ||
| 66 | 66 | * nvme_reset_wq - hosts nvme reset works |
| 67 | 67 | * nvme_delete_wq - hosts nvme delete works |
| 68 | 68 | * |
| 69 | − * nvme_wq will host works such are scan, aen handling, fw activation, | |
| 70 | − * keep-alive error recovery, periodic reconnects etc. nvme_reset_wq | |
| 69 | + * nvme_wq will host works such as scan, aen handling, fw activation, | |
| 70 | + * keep-alive, periodic reconnects etc. nvme_reset_wq | |
| 71 | 71 | * runs reset works which also flush works hosted on nvme_wq for |
| 72 | 72 | * serialization purposes. nvme_delete_wq host controller deletion |
| 73 | 73 | * works which flush reset works for serialization. |
| @@ -976,7 +976,7 @@ static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status) · 902 unmodified lines | ||
| 976 | 976 | startka = true; |
| 977 | 977 | spin_unlock_irqrestore(&ctrl->lock, flags); |
| 978 | 978 | if (startka) |
| 979 | − schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); | |
| 979 | + queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ); | |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | static int nvme_keep_alive(struct nvme_ctrl *ctrl) |
| @@ -1006,7 +1006,7 @@ static void nvme_keep_alive_work(struct work_struct *work) · 23 unmodified lines | ||
| 1006 | 1006 | dev_dbg(ctrl->device, |
| 1007 | 1007 | "reschedule traffic based keep-alive timer\n"); |
| 1008 | 1008 | ctrl->comp_seen = false; |
| 1009 | − schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); | |
| 1009 | + queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ); | |
| 1010 | 1010 | return; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| @@ -1023,7 +1023,7 @@ static void nvme_start_keep_alive(struct nvme_ctrl *ctrl) · 10 unmodified lines | ||
| 1023 | 1023 | if (unlikely(ctrl->kato == 0)) |
| 1024 | 1024 | return; |
| 1025 | 1025 | |
| 1026 | − schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); | |
| 1026 | + queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ); | |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | void nvme_stop_keep_alive(struct nvme_ctrl *ctrl) |
| @@ -3867,7 +3867,7 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl) · 2837 unmodified lines | ||
| 3867 | 3867 | if (!log) |
| 3868 | 3868 | return; |
| 3869 | 3869 | |
| 3870 | − if (nvme_get_log(ctrl, NVME_NSID_ALL, 0, NVME_LOG_FW_SLOT, log, | |
| 3870 | + if (nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_FW_SLOT, 0, log, | |
| 3871 | 3871 | sizeof(*log), 0)) |
| 3872 | 3872 | dev_warn(ctrl->device, "Get FW SLOT INFO log error\n"); |
| 3873 | 3873 | kfree(log); |
| @@ -1401,6 +1401,23 @@ static void nvme_disable_admin_queue(struct nvme_dev *dev, bool shutdown) · 1400 unmodified lines | ||
| 1401 | 1401 | nvme_poll_irqdisable(nvmeq, -1); |
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | +/* | |
| 1405 | + * Called only on a device that has been disabled and after all other threads | |
| 1406 | + * that can check this device's completion queues have synced. This is the | |
| 1407 | + * last chance for the driver to see a natural completion before | |
| 1408 | + * nvme_cancel_request() terminates all incomplete requests. | |
| 1409 | + */ | |
| 1410 | +static void nvme_reap_pending_cqes(struct nvme_dev *dev) | |
| 1411 | +{ | |
| 1412 | + u16 start, end; | |
| 1413 | + int i; | |
| 1414 | + | |
| 1415 | + for (i = dev->ctrl.queue_count - 1; i > 0; i--) { | |
| 1416 | + nvme_process_cq(&dev->queues[i], &start, &end, -1); | |
| 1417 | + nvme_complete_cqes(&dev->queues[i], start, end); | |
| 1418 | + } | |
| 1419 | +} | |
| 1420 | + | |
| 1404 | 1421 | static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues, |
| 1405 | 1422 | int entry_size) |
| 1406 | 1423 | { |
| @@ -2235,11 +2252,6 @@ static bool __nvme_disable_io_queues(struct nvme_dev *dev, u8 opcode) · 828 unmodified lines | ||
| 2235 | 2252 | if (timeout == 0) |
| 2236 | 2253 | return false; |
| 2237 | 2254 | |
| 2238 | − /* handle any remaining CQEs */ | |
| 2239 | − if (opcode == nvme_admin_delete_cq && | |
| 2240 | − !test_bit(NVMEQ_DELETE_ERROR, &nvmeq->flags)) | |
| 2241 | − nvme_poll_irqdisable(nvmeq, -1); | |
| 2242 | − | |
| 2243 | 2255 | sent--; |
| 2244 | 2256 | if (nr_queues) |
| 2245 | 2257 | goto retry; |
| @@ -2428,6 +2440,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) · 182 unmodified lines | ||
| 2428 | 2440 | nvme_suspend_io_queues(dev); |
| 2429 | 2441 | nvme_suspend_queue(&dev->queues[0]); |
| 2430 | 2442 | nvme_pci_disable(dev); |
| 2443 | + nvme_reap_pending_cqes(dev); | |
| 2431 | 2444 | |
| 2432 | 2445 | blk_mq_tagset_busy_iter(&dev->tagset, nvme_cancel_request, &dev->ctrl); |
| 2433 | 2446 | blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_request, &dev->ctrl); |
| @@ -1088,7 +1088,7 @@ static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) · 1087 unmodified lines | ||
| 1088 | 1088 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) |
| 1089 | 1089 | return; |
| 1090 | 1090 | |
| 1091 | − queue_work(nvme_wq, &ctrl->err_work); | |
| 1091 | + queue_work(nvme_reset_wq, &ctrl->err_work); | |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | static void nvme_rdma_wr_error(struct ib_cq *cq, struct ib_wc *wc, |
| @@ -422,7 +422,7 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) · 421 unmodified lines | ||
| 422 | 422 | if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) |
| 423 | 423 | return; |
| 424 | 424 | |
| 425 | − queue_work(nvme_wq, &to_tcp_ctrl(ctrl)->err_work); | |
| 425 | + queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); | |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, |
| @@ -1054,7 +1054,12 @@ static void nvme_tcp_io_work(struct work_struct *w) · 625 unmodified lines | ||
| 1054 | 1054 | } else if (unlikely(result < 0)) { |
| 1055 | 1055 | dev_err(queue->ctrl->ctrl.device, |
| 1056 | 1056 | "failed to send request %d\n", result); |
| 1057 | − if (result != -EPIPE) | |
| 1057 | + | |
| 1058 | + /* | |
| 1059 | + * Fail the request unless peer closed the connection, | |
| 1060 | + * in which case error recovery flow will complete all. | |
| 1061 | + */ | |
| 1062 | + if ((result != -EPIPE) && (result != -ECONNRESET)) | |
| 1058 | 1063 | nvme_tcp_fail_request(queue->request); |
| 1059 | 1064 | nvme_tcp_done_send_req(queue); |
| 1060 | 1065 | return; |