From patchwork Thu Dec 3 13:27:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 7759861 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4016C9F30B for ; Thu, 3 Dec 2015 13:27:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DE5C20494 for ; Thu, 3 Dec 2015 13:27:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BDB3A20489 for ; Thu, 3 Dec 2015 13:27:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760046AbbLCN1s (ORCPT ); Thu, 3 Dec 2015 08:27:48 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36510 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759991AbbLCN1r (ORCPT ); Thu, 3 Dec 2015 08:27:47 -0500 Received: by pacdm15 with SMTP id dm15so69159269pac.3; Thu, 03 Dec 2015 05:27:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=vMWbrgnEC3axgaGesAbVmtgvD8fVKOGh3tYhycErXrU=; b=oreOp2W0MZDT2O+tG9VUza8Qlc+nLzCVbnhGWvBQ+bq3WzAtDykeSB2/sN8PbGixeY 5bwWVPHZ8chfaYLEhCur8+qfNs1tQYziEHoLATabyw4drTe1gOJENeaGacFchUU1PAr1 Qh4X6ASYGZxjQfOvDSqAYUpD2BfYXKnyZy14y0LuIklqqBHG02k+Abb8rOSISqxahuc7 CcarX2dqEiRPy+7vevcXeFMtCxGxxo4rbL2OlkRX1Q4YmOrzaqswnxBrMm60Nj9vltRp E3bWeNRew1AiBlo02G1ZcGVVY3wQEzwj3iE29Tp7pWGCu1vpaXnAa/qJQLvisO2t/wyv FQ9Q== X-Received: by 10.66.140.79 with SMTP id re15mr12697854pab.127.1449149266781; Thu, 03 Dec 2015 05:27:46 -0800 (PST) Received: from localhost.localdomain ([114.250.96.29]) by smtp.gmail.com with ESMTPSA id ww5sm4235084pac.35.2015.12.03.05.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 05:27:46 -0800 (PST) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] lightnvm: put blks when luns configure failed Date: Thu, 3 Dec 2015 21:27:28 +0800 Message-Id: <1449149248-3336-1-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 2.5.1.windows.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP put the allocated blks back to the free list when the luns configure failed, to make these blks useable to others. Signed-off-by: Wenwei Tao --- drivers/lightnvm/rrpc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 75e59c3..1bb2f97 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -202,6 +202,20 @@ static void rrpc_put_blk(struct rrpc *rrpc, struct rrpc_block *rblk) nvm_put_blk(rrpc->dev, rblk->parent); } +static void rrpc_put_blks(struct rrpc *rrpc) +{ + struct rrpc_lun *rlun; + int i; + + for (i = 0; i < rrpc->nr_luns; i++) { + rlun = &rrpc->luns[i]; + if (rlun->cur) + rrpc_put_blk(rrpc, rlun->cur); + if (rlun->gc_cur) + rrpc_put_blk(rrpc, rlun->gc_cur); + } +} + static struct rrpc_lun *get_next_lun(struct rrpc *rrpc) { int next = atomic_inc_return(&rrpc->next_lun); @@ -1224,18 +1238,21 @@ static int rrpc_luns_configure(struct rrpc *rrpc) rblk = rrpc_get_blk(rrpc, rlun, 0); if (!rblk) - return -EINVAL; + goto err; rrpc_set_lun_cur(rlun, rblk); /* Emergency gc block */ rblk = rrpc_get_blk(rrpc, rlun, 1); if (!rblk) - return -EINVAL; + goto err; rlun->gc_cur = rblk; } return 0; +err: + rrpc_put_blks(rrpc); + return -EINVAL; } static struct nvm_tgt_type tt_rrpc;