Skip to content

Commit e29c6a1

Browse files
committed
Merge tag 'block-5.6-2020-02-16' of git://git.kernel.dk/linux-block
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
2 parents 713db35 + f25372f commit e29c6a1

File tree

8 files changed

+63
-38
lines changed

8 files changed

+63
-38
lines changed

drivers/md/bcache/alloc.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include <linux/blkdev.h>
6868
#include <linux/kthread.h>
6969
#include <linux/random.h>
70+
#include <linux/sched/signal.h>
7071
#include <trace/events/bcache.h>
7172

7273
#define MAX_OPEN_BUCKETS 128
@@ -733,8 +734,21 @@ int bch_open_buckets_alloc(struct cache_set *c)
733734

734735
int bch_cache_allocator_start(struct cache *ca)
735736
{
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");
738752
if (IS_ERR(k))
739753
return PTR_ERR(k);
740754

drivers/md/bcache/btree.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/random.h>
3535
#include <linux/rcupdate.h>
3636
#include <linux/sched/clock.h>
37+
#include <linux/sched/signal.h>
3738
#include <linux/rculist.h>
3839
#include <linux/delay.h>
3940
#include <trace/events/bcache.h>
@@ -1913,6 +1914,18 @@ static int bch_gc_thread(void *arg)
19131914

19141915
int bch_gc_thread_start(struct cache_set *c)
19151916
{
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+
19161929
c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc");
19171930
return PTR_ERR_OR_ZERO(c->gc_thread);
19181931
}

drivers/md/bcache/journal.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,6 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
417417

418418
/* Journalling */
419419

420-
#define nr_to_fifo_front(p, front_p, mask) (((p) - (front_p)) & (mask))
421-
422420
static void btree_flush_write(struct cache_set *c)
423421
{
424422
struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR];
@@ -510,9 +508,8 @@ static void btree_flush_write(struct cache_set *c)
510508
* journal entry can be reclaimed). These selected nodes
511509
* will be ignored and skipped in the folowing for-loop.
512510
*/
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) {
516513
mutex_unlock(&b->write_lock);
517514
continue;
518515
}

drivers/md/bcache/super.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,23 +1917,6 @@ static int run_cache_set(struct cache_set *c)
19171917
if (bch_btree_check(c))
19181918
goto err;
19191919

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-
19371920
bch_journal_mark(c, &journal);
19381921
bch_initial_gc_finish(c);
19391922
pr_debug("btree_check() done");

drivers/nvme/host/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ MODULE_PARM_DESC(streams, "turn on support for Streams write directives");
6666
* nvme_reset_wq - hosts nvme reset works
6767
* nvme_delete_wq - hosts nvme delete works
6868
*
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
7171
* runs reset works which also flush works hosted on nvme_wq for
7272
* serialization purposes. nvme_delete_wq host controller deletion
7373
* 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)
976976
startka = true;
977977
spin_unlock_irqrestore(&ctrl->lock, flags);
978978
if (startka)
979-
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
979+
queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ);
980980
}
981981

982982
static int nvme_keep_alive(struct nvme_ctrl *ctrl)
@@ -1006,7 +1006,7 @@ static void nvme_keep_alive_work(struct work_struct *work)
10061006
dev_dbg(ctrl->device,
10071007
"reschedule traffic based keep-alive timer\n");
10081008
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);
10101010
return;
10111011
}
10121012

@@ -1023,7 +1023,7 @@ static void nvme_start_keep_alive(struct nvme_ctrl *ctrl)
10231023
if (unlikely(ctrl->kato == 0))
10241024
return;
10251025

1026-
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
1026+
queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ);
10271027
}
10281028

10291029
void nvme_stop_keep_alive(struct nvme_ctrl *ctrl)
@@ -3867,7 +3867,7 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
38673867
if (!log)
38683868
return;
38693869

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,
38713871
sizeof(*log), 0))
38723872
dev_warn(ctrl->device, "Get FW SLOT INFO log error\n");
38733873
kfree(log);

drivers/nvme/host/pci.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,23 @@ static void nvme_disable_admin_queue(struct nvme_dev *dev, bool shutdown)
14011401
nvme_poll_irqdisable(nvmeq, -1);
14021402
}
14031403

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+
14041421
static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues,
14051422
int entry_size)
14061423
{
@@ -2235,11 +2252,6 @@ static bool __nvme_disable_io_queues(struct nvme_dev *dev, u8 opcode)
22352252
if (timeout == 0)
22362253
return false;
22372254

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-
22432255
sent--;
22442256
if (nr_queues)
22452257
goto retry;
@@ -2428,6 +2440,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
24282440
nvme_suspend_io_queues(dev);
24292441
nvme_suspend_queue(&dev->queues[0]);
24302442
nvme_pci_disable(dev);
2443+
nvme_reap_pending_cqes(dev);
24312444

24322445
blk_mq_tagset_busy_iter(&dev->tagset, nvme_cancel_request, &dev->ctrl);
24332446
blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_request, &dev->ctrl);

drivers/nvme/host/rdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl)
10881088
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING))
10891089
return;
10901090

1091-
queue_work(nvme_wq, &ctrl->err_work);
1091+
queue_work(nvme_reset_wq, &ctrl->err_work);
10921092
}
10931093

10941094
static void nvme_rdma_wr_error(struct ib_cq *cq, struct ib_wc *wc,

drivers/nvme/host/tcp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl)
422422
if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING))
423423
return;
424424

425-
queue_work(nvme_wq, &to_tcp_ctrl(ctrl)->err_work);
425+
queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work);
426426
}
427427

428428
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)
10541054
} else if (unlikely(result < 0)) {
10551055
dev_err(queue->ctrl->ctrl.device,
10561056
"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))
10581063
nvme_tcp_fail_request(queue->request);
10591064
nvme_tcp_done_send_req(queue);
10601065
return;

0 commit comments

Comments
 (0)