From patchwork Tue Jun 27 08:39:50 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: 9811049 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 B00186020A for ; Tue, 27 Jun 2017 08:40:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A50C228437 for ; Tue, 27 Jun 2017 08:40:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9972428543; Tue, 27 Jun 2017 08:40:33 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 B9F12204BE for ; Tue, 27 Jun 2017 08:40:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752724AbdF0Ika (ORCPT ); Tue, 27 Jun 2017 04:40:30 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36620 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752698AbdF0IkR (ORCPT ); Tue, 27 Jun 2017 04:40:17 -0400 Received: by mail-wm0-f66.google.com with SMTP id y5so4411159wmh.3 for ; Tue, 27 Jun 2017 01:40:17 -0700 (PDT) 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=WiTelPHvyiUcsaq4S6wIUkRR2uvbFEdNWmGbn1FAv4s=; b=RNo51g3qy4SSRi2hHKOKuXUct0xe2QVsGeh8gVmWLWJr1H5EvsaD9ofA3ozry5FSo+ BWknRI0dycxVAN1YJpjhVkxzz/hczICuXw+o08ZXsCSzPa2ep/+QIPAb4x+M4PUWKKQL /PjcT0AGOGRnbai02OVzcfAulCDXt2B2hztwU= 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=WiTelPHvyiUcsaq4S6wIUkRR2uvbFEdNWmGbn1FAv4s=; b=DOfOtMJ6hf+BfJAtaWXrYNmu8dHo3wAuVM13eQr1KVZuBITHL3ZYzcTWli/9UCwwQa E5sLApSQG6PuV0QtiwUiD9h5ttLo6detq3u+yLArZkDrGD8CAH2appa9R0ewzTMiSNwv 9rLAvCtXc4A3cRu9IIAlBl20WzGQGJ3OIBey1xIW3e4t93Zjqx1rh+6KrIjn7/0XJPjC cArMehKfVSna1hz4WIRSV7cormm7VhfVs1tWCTZnXlCUifyNovlIhOFOSS+Zo7W03zhd KE3vCjVrcYoxAab2fPlujOZ+5drh6sV6yEJVR4FkysLNKY+ODUc9JkDhcKtXKyk1awCc E/ug== X-Gm-Message-State: AKS2vOw8qIyaGigXOXj3vBBhLFPtnkbNOBzCBFfFlA9uRF7dq4U0TP2t CJ+goBERpuUYnYDX X-Received: by 10.80.183.146 with SMTP id h18mr3195948ede.39.1498552815955; Tue, 27 Jun 2017 01:40:15 -0700 (PDT) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id w12sm1266126edd.21.2017.06.27.01.40.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 01:40:15 -0700 (PDT) From: "=?UTF-8?q?Matias=20Bj=C3=B8rling?=" X-Google-Original-From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Rakesh Pandit , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] ligtnvm: if LUNs are already allocated fix return Date: Tue, 27 Jun 2017 10:39:50 +0200 Message-Id: <20170627083950.11312-2-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170627083950.11312-1-matias@cnexlabs.com> References: <20170627083950.11312-1-matias@cnexlabs.com> 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: Rakesh Pandit While creating new device with NVM_DEV_CREATE if LUNs are already allocated ioctl would return -ENOMEM which is wrong. This patch propagates -EBUSY from nvm_reserve_luns which is correct response. Fixes: ade69e243 ("lightnvm: merge gennvm with core") Signed-off-by: Rakesh Pandit Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index b8f82f5..9ff348f 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -235,7 +235,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) struct nvm_target *t; struct nvm_tgt_dev *tgt_dev; void *targetdata; - int ret; + int ret = 0; tt = nvm_find_target_type(create->tgttype, 1); if (!tt) { @@ -252,8 +252,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) } mutex_unlock(&dev->mlock); - if (nvm_reserve_luns(dev, s->lun_begin, s->lun_end)) - return -ENOMEM; + ret = nvm_reserve_luns(dev, s->lun_begin, s->lun_end); + if (ret) + goto err; t = kmalloc(sizeof(struct nvm_target), GFP_KERNEL); if (!t) { @@ -314,8 +315,8 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) mutex_lock(&dev->mlock); list_add_tail(&t->list, &dev->targets); mutex_unlock(&dev->mlock); - - return 0; +err: + return ret; err_sysfs: if (tt->exit) tt->exit(targetdata);