aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
authorJavier González <javier@cnexlabs.com>2018-01-05 08:16:17 -0500
committerJens Axboe <axboe@kernel.dk>2018-01-05 10:50:12 -0500
commitcc4f5ba1fb6ebe977fb44293abebb79af77556f0 (patch)
treea705d8c9a929b4e38444c3145ae67494800a30ad /drivers/lightnvm/pblk-init.c
parent8f554597e00abe04fd1f37c351b38aff33c37fc9 (diff)
lightnvm: pblk: ensure kthread alloc. before kicking it
When creating the write thread, ensure that the kthread has been created before initializing the timer responsible from kicking it. Otherwise, if the kthread creation fails or gets killed from used space, we risk kicking an empty thread structure. Also, since the kthread creation can be interrupted form user space, adapt the error path to not report an error when this happens, since it is intentional that the instance creation is aborted. Signed-off-by: Javier González <javier@cnexlabs.com> Updated source to reflect the new timer_setup API. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 533f6908e238..7e11926830db 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -883,15 +883,19 @@ fail:
883 883
884static int pblk_writer_init(struct pblk *pblk) 884static int pblk_writer_init(struct pblk *pblk)
885{ 885{
886 timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0);
887 mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100));
888
889 pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t"); 886 pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t");
890 if (IS_ERR(pblk->writer_ts)) { 887 if (IS_ERR(pblk->writer_ts)) {
891 pr_err("pblk: could not allocate writer kthread\n"); 888 int err = PTR_ERR(pblk->writer_ts);
892 return PTR_ERR(pblk->writer_ts); 889
890 if (err != -EINTR)
891 pr_err("pblk: could not allocate writer kthread (%d)\n",
892 err);
893 return err;
893 } 894 }
894 895
896 timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0);
897 mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100));
898
895 return 0; 899 return 0;
896} 900}
897 901
@@ -1042,7 +1046,8 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
1042 1046
1043 ret = pblk_writer_init(pblk); 1047 ret = pblk_writer_init(pblk);
1044 if (ret) { 1048 if (ret) {
1045 pr_err("pblk: could not initialize write thread\n"); 1049 if (ret != -EINTR)
1050 pr_err("pblk: could not initialize write thread\n");
1046 goto fail_free_lines; 1051 goto fail_free_lines;
1047 } 1052 }
1048 1053