From patchwork Sat Apr 15 18:55:42 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: 9682397 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 17E4560138 for ; Sat, 15 Apr 2017 18:59:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AED525223 for ; Sat, 15 Apr 2017 18:59:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2C4028305; Sat, 15 Apr 2017 18:59: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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 9AB5525223 for ; Sat, 15 Apr 2017 18:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753773AbdDOS4e (ORCPT ); Sat, 15 Apr 2017 14:56:34 -0400 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:38016 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754712AbdDOS4a (ORCPT ); Sat, 15 Apr 2017 14:56:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cnexlabs.onmicrosoft.com; s=selector1-cnexlabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8wvKoprQyi6mmjTPpHs3EQY+ciswdjJNKQAdNnvzQPo=; b=fYXSOk2o7ZhQudj7sjkNxJRLmBY27qCSIVqy9doLopR2lIJRASzWrnv/l4ZkI+NnTFKo8LySDTKpiJdOOPQ84w2zshGpEhdj1pVt/IOJ8eaIwA9z1DYTLccGiL1p+YQ/LU+f2Y/0hIqSPmNsCYfmtde6i7knTuhFQ7b/OxM9VxQ= Authentication-Results: fb.com; dkim=none (message not signed) header.d=none; fb.com; dmarc=none action=none header.from=cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Sat, 15 Apr 2017 18:56:23 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 08/19] lightnvm: double-clear of dev->lun_map on target init error Date: Sat, 15 Apr 2017 20:55:42 +0200 Message-ID: <20170415185553.16098-9-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170415185553.16098-1-matias@cnexlabs.com> References: <20170415185553.16098-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: AM5PR0701CA0069.eurprd07.prod.outlook.com (10.169.145.159) To CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) X-MS-Office365-Filtering-Correlation-Id: 81579b69-7315-4083-dc35-08d484311d1a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 3:svQiYVz8AKCmk59mVLG6x0ytaBIZWc0kfQTuWlB1a4kCBP4OWejShBumScun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lA9LHLC219/NJq7FWGmQX85+OU7JNQlvBFyl11fx/ya65AM6Sq9ghU4EBiEVnImK4eFO0+HnEQJ3Fw8sND+QIaLDfDyvBlv8InGtHgTZrGqZrmswhvgF+FyBWDJ094z3TJwhemLZQKYAeVqTSkD/NJT+fi+Ts= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201703061421075)(20161123555025)(6072148); SRVR:CY4PR06MB2774; BCL:0; PCL:0; RULEID:; SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 4:93tCi7dQoByuxLMcnXJ52EoB51d8pNXEtj8tVhfDJrQdIyA987WHu1AiUVnhGdgUCSgMjMI5fliiD/4DZLIdIQtIHPVp5bg6eDujaF0k8ekyO+8/egjkNKbiM6os2PSklxAk8k4wxL1ThFQCPucmL/uINcZozi8oS2FczW2Ls/xkXjLbt2HE8kz0WF7U/Lk6vMypA6C6Cl7HkaaBx+WbJ+ZWhcmzgqNai+QYMd1htwMkI3O1QuO5ASTe8jPWF1QVobcQc7SdCl+GSPoShS9LctQiP0B7LfRwt/aNduMSxfq9PnPAVr90MhtGYNRDmnDl2uWm6YibzpCE6CTAKzxE8gzcnqtfzjqjojS8TdGXy7TZQspLQDcC8FzPqkZy1psjIPBSm05KD/lADTsOdTjiKewmhBAgf+RpWDjKAr8lg5OssUiYWtEei+CRFPG5D5m+tFwgJY9sUCaW2xBOC8o35ceoxUKPH+SJBpoRr1zFkrCot5R9WaNCKqgIQ44fGmUHkUHMhQW2zWktkbGFylbLBXsS+U+oqqRco+Fsg+ocm1wKCJ1VknhRWDFqb8sYB4CST0Vvw6TveTEWNuCD1j7yv9N6OyJtNCooBfQMFJUztGPEYTqbLhuQ61eV97Il9/k9Oh3fEQ57Fkzs7HTeFY4h3ypBAuC9v6dFRp2WGObMMRn7DcIBLP0bUSiXJ1VPcaI5 X-Forefront-PRVS: 02788FF38E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39450400003)(51234002)(86362001)(305945005)(1076002)(6916009)(6666003)(25786009)(2950100002)(6486002)(2906002)(3846002)(6116002)(2870700001)(54906002)(189998001)(53936002)(53416004)(107886003)(110136004)(5660300001)(38730400002)(50986999)(76176999)(2351001)(4326008)(66066001)(5820100001)(23676002)(81166006)(47776003)(42186005)(36756003)(33646002)(50226002)(8676002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR06MB2774; H:skyninja.cnexlabs.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA2TUIyNzc0OzIzOnJnNFBoY2lmSlFQRWVlZ05SOVRyYWtBT3pQ?= =?utf-8?B?blVEKzRFRG94RFE4Vm9YVWhzcVR4YkI1aFQzNUpqNks0akZEbmRlNDNTUTBx?= =?utf-8?B?NmtpYjRPODFkTk1ad1UyT0JKQ3cwQXNsWWF5bFMvMXd5NnM5d1hXNGVrNFg3?= =?utf-8?B?ZjI2SXo4cHlCak43eWZVT2hzRnE5TmZ2bjJFUTBjdWoxaDlSWUJYNkIyYldn?= =?utf-8?B?UHZVeEc2NG80MFJXdXlIVmFQdEFidGdsVytUbWx3bkpYb3ltdmZSVUNBWnlk?= =?utf-8?B?NTBkR1B0STFiNkVTK05LeFRYMXJWNEFRRExqTWo3RFZTaW43cWhkcW9kYzdN?= =?utf-8?B?UGhjRDZCMUlEaTd4QUxrYnZlRWZnVWdJTkVqMW81ZHhLd0d6c2RtV0UxNVZm?= =?utf-8?B?ZjBIMENXcG1iWjJ2ZEpZalpFbElPSmVjU0d1VndtTWg1WjFJVTR1a080ZU1B?= =?utf-8?B?QVJ1MWlHL1RiOWQydVJDbEk1NGp5eEFOaUx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CPoqX1YZKlL87LJ22RVmhMcPl2AHs1i/aqXYTyGovjUF4iRXoFhrhEWIiS2X69gytpXq1oaNp7yozPHhdw7w0SW8OsmmFQQcovx4xFqVMjbvJF/mVgm8w3j98Za85g== X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2017 18:56:23.0906 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2774 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 The dev->lun_map bits are cleared twice if an target init error occurs. First in the target clean routine, and then next in the nvm_tgt_create error function. Make sure that it is only cleared once by extending nvm_remove_tgt_devi() with a clear bit, such that clearing of bits can ignored when cleaning up a successful initialized target. Signed-off-by: Javier González Fix style. Signed-off-by: Matias Bjørling Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index a14c52c..5eea3d5 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -89,7 +89,7 @@ static void nvm_release_luns_err(struct nvm_dev *dev, int lun_begin, WARN_ON(!test_and_clear_bit(i, dev->lun_map)); } -static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev) +static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev, int clear) { struct nvm_dev *dev = tgt_dev->parent; struct nvm_dev_map *dev_map = tgt_dev->map; @@ -100,11 +100,14 @@ static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev) int *lun_offs = ch_map->lun_offs; int ch = i + ch_map->ch_off; - for (j = 0; j < ch_map->nr_luns; j++) { - int lun = j + lun_offs[j]; - int lunid = (ch * dev->geo.luns_per_chnl) + lun; + if (clear) { + for (j = 0; j < ch_map->nr_luns; j++) { + int lun = j + lun_offs[j]; + int lunid = (ch * dev->geo.luns_per_chnl) + lun; - WARN_ON(!test_and_clear_bit(lunid, dev->lun_map)); + WARN_ON(!test_and_clear_bit(lunid, + dev->lun_map)); + } } kfree(ch_map->lun_offs); @@ -309,7 +312,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) err_queue: blk_cleanup_queue(tqueue); err_dev: - nvm_remove_tgt_dev(tgt_dev); + nvm_remove_tgt_dev(tgt_dev, 0); err_t: kfree(t); err_reserve: @@ -332,7 +335,7 @@ static void __nvm_remove_target(struct nvm_target *t) if (tt->exit) tt->exit(tdisk->private_data); - nvm_remove_tgt_dev(t->dev); + nvm_remove_tgt_dev(t->dev, 1); put_disk(tdisk); list_del(&t->list);