From patchwork Fri Jan 5 13:16:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 10146491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A3FEA60244 for ; Fri, 5 Jan 2018 13:18:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 941BF1FFEB for ; Fri, 5 Jan 2018 13:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88CDB288BA; Fri, 5 Jan 2018 13:18:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1061C1FFEB for ; Fri, 5 Jan 2018 13:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751892AbeAENS2 (ORCPT ); Fri, 5 Jan 2018 08:18:28 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:44504 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbeAENRC (ORCPT ); Fri, 5 Jan 2018 08:17:02 -0500 Received: by mail-wm0-f68.google.com with SMTP id t8so2391632wmc.3 for ; Fri, 05 Jan 2018 05:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4/cZhGAh+st4IJlemlCbivOmQbMYOuXdWkUFhPrjkKg=; b=R60iGuyHpE0f1zz24I+wnUpErlX9SbmMsXKYgWTarpCgEogXZ+VqMNDkW2YY1cRJWI pJ8qA7A6xOWy/niMxAJ1u6J5NPHoQ12EelP6oo4/595KxyLshHUWjyWl3OUl/Wk1YVOg 6JeE7t5V3cCw1HYtu/FhjN2XIrtwUX7nRtQGo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4/cZhGAh+st4IJlemlCbivOmQbMYOuXdWkUFhPrjkKg=; b=bDb6WlIz2XHAQnea+W1jtIedM04LInH9YucS+PJWNoVJ1Jv+n9Fw6YTw6Hk2/21yLf LVZHgTAwj+fWrcLyZYs3Z0Or3IBRfRzpECaIUcPjZ8OdAASYB82XbERi3NxYLDPlz072 N1FDPKcXNW1esrCqcOjSYASU2KUI07H1YmPAkOum/RKRysYHi+R3Ioi/Dde02HUqZ8NV YAMliPTF0xE4rY00xlWC7tCdqC1c2jTupUXf3XNsQdT7RF4vNZtEo6Iu8IHNnOBpVBT/ lsRuXAVwv7GE2rJ1aoGIs7nO1Qlz5N9PJnH0FjpQwagvMVm+Vg+kNLrYEEuvTY6Cnnf7 GSXw== X-Gm-Message-State: AKGB3mKY9TbBQAtj1TOFoncUfRq7m1gBkUie97jDxn0pFq0OOR/vsjjy lhNHxBURTVcDq8Mb6IVPzkWOKQ== X-Google-Smtp-Source: ACJfBosbIKpaYuNQ3Y3Hak26/2VHnCaPUQ4AULB70tCscEINSI61+1vU58adli9xEQ1iyAMCLof1sQ== X-Received: by 10.80.137.164 with SMTP id g33mr4055054edg.29.1515158221401; Fri, 05 Jan 2018 05:17:01 -0800 (PST) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id e46sm4228940edb.93.2018.01.05.05.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 05:17:00 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 21/25] lightnvm: pblk: ensure kthread alloc. before kicking it Date: Fri, 5 Jan 2018 14:16:17 +0100 Message-Id: <20180105131621.20808-22-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180105131621.20808-1-m@bjorling.me> References: <20180105131621.20808-1-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier González 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 Updated source to reflect the new timer_setup API. Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-init.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 533f690..7e11926 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -883,15 +883,19 @@ static int pblk_lines_init(struct pblk *pblk) static int pblk_writer_init(struct pblk *pblk) { - timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0); - mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100)); - pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t"); if (IS_ERR(pblk->writer_ts)) { - pr_err("pblk: could not allocate writer kthread\n"); - return PTR_ERR(pblk->writer_ts); + int err = PTR_ERR(pblk->writer_ts); + + if (err != -EINTR) + pr_err("pblk: could not allocate writer kthread (%d)\n", + err); + return err; } + timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0); + mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100)); + return 0; } @@ -1042,7 +1046,8 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, ret = pblk_writer_init(pblk); if (ret) { - pr_err("pblk: could not initialize write thread\n"); + if (ret != -EINTR) + pr_err("pblk: could not initialize write thread\n"); goto fail_free_lines; }