From patchwork Wed Dec 20 17:22:01 2017 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: 10125993 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 E583160245 for ; Wed, 20 Dec 2017 17:23:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAAD8294B5 for ; Wed, 20 Dec 2017 17:23:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C971029718; Wed, 20 Dec 2017 17:23:16 +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=ham 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 748B5296DD for ; Wed, 20 Dec 2017 17:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756016AbdLTRXO (ORCPT ); Wed, 20 Dec 2017 12:23:14 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39680 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755895AbdLTRWg (ORCPT ); Wed, 20 Dec 2017 12:22:36 -0500 Received: by mail-wm0-f65.google.com with SMTP id i11so11131844wmf.4 for ; Wed, 20 Dec 2017 09:22:35 -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=DuHL7sVvbtwRwZHda7bTBjEsEwe+edJiFeoWfJlqXs0=; b=w9HlpLhEumQff9TXG/jl1Miys/uOwSSNV+a0XApuTZtZ3qFQj13mHUDbVK1lCF79yF lgtehEGfaLGyB5N1uBRa9MLzIVLdnc+PEKsAnV4gR9wiRZwRQsArdLkwTIhaV159bpHr l3IkDHBtDjy+tytRq3XpRgzT74LOAisKni7lg= 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=DuHL7sVvbtwRwZHda7bTBjEsEwe+edJiFeoWfJlqXs0=; b=dNdGLzmFhweJwpGZcBaRQf5DojYN6r0ka+2aHI8OIgGlXeAV9UaA+GYU/zKUfk5wBL flTvHe5mgjsyMnrVUQ+d+7raWHDiXOIRhpSIqcDTEBfW73Bx/3uET3sS/smM9m/ZdfGu AnDCKEa5H5mCIQA6E+EGjockcmp/+IsLiRtd3s+fbbbFdKjFhBTw4dA/oCsA5E+xtFS+ tSD1XJayN4v5m8c0Y+mBW9mk0bcZ3qgNfnRHTYbA7gR/JicgFzoO4/3xAgyBwt8eK2Gb XiQPpuViY5Ec+g5KSgkptMvzbRsAZcv/CkYJM4uUAMY7+hQNZBXSXsF4ztVMhqMiGPmw u+hg== X-Gm-Message-State: AKGB3mL3nWClVuRKyS9+NMWyPzlItE6Lv9z+cxOLkREeryWa3lBawyQa AqNQYximaHp8kE+5M/qXTYk1UQUe X-Google-Smtp-Source: ACJfBotE9ERACPg53AOXlQotHPDJ1/WHu+/qBjICc2nNPeOvG0YhYFKJOqWqDWmVSmdgc63fob/FMg== X-Received: by 10.80.224.198 with SMTP id j6mr6441730edl.0.1513790554717; Wed, 20 Dec 2017 09:22:34 -0800 (PST) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 26sm15339120eds.67.2017.12.20.09.22.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 09:22:34 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 21/25] lightnvm: pblk: ensure kthread alloc. before kicking it Date: Wed, 20 Dec 2017 18:22:01 +0100 Message-Id: <20171220172205.26464-22-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171220172205.26464-1-m@bjorling.me> References: <20171220172205.26464-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 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 30ea592..3150b8f 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) { - setup_timer(&pblk->wtimer, pblk_write_timer_fn, (unsigned long)pblk); - 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; } + setup_timer(&pblk->wtimer, pblk_write_timer_fn, (unsigned long)pblk); + 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; }