From patchwork Fri Mar 22 14:48:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Konopko X-Patchwork-Id: 10865971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18F6B139A for ; Fri, 22 Mar 2019 14:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3DD929FBE for ; Fri, 22 Mar 2019 14:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E837A2A86C; Fri, 22 Mar 2019 14:51:31 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 7D24629FBE for ; Fri, 22 Mar 2019 14:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728336AbfCVOvb (ORCPT ); Fri, 22 Mar 2019 10:51:31 -0400 Received: from mga07.intel.com ([134.134.136.100]:13975 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728072AbfCVOva (ORCPT ); Fri, 22 Mar 2019 10:51:30 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2019 07:51:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="216593160" Received: from gklab-107-059.igk.intel.com ([10.102.107.59]) by orsmga001.jf.intel.com with ESMTP; 22 Mar 2019 07:51:28 -0700 From: Igor Konopko To: mb@lightnvm.io, javier@javigon.com, hans.holmberg@cnexlabs.com Cc: linux-block@vger.kernel.org, igor.j.konopko@intel.com Subject: [PATCH v2 01/16] lightnvm: pblk: warn when there are opened chunks Date: Fri, 22 Mar 2019 15:48:28 +0100 Message-Id: <20190322144843.9602-2-igor.j.konopko@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190322144843.9602-1-igor.j.konopko@intel.com> References: <20190322144843.9602-1-igor.j.konopko@intel.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 In case of factory pblk init, we might have a situation when there are some opened chunks. Based on OCSSD spec we are not allowed to transform chunks from the open state directly to the free state, so such a reset can lead to IO error (even that most of the controller will allow for for such a operation anyway), so we would like to warn users about such a situation at least. Signed-off-by: Igor Konopko Reviewed-by: Javier González --- drivers/lightnvm/pblk-init.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 1e227a0..e2e1193 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -712,7 +712,7 @@ static int pblk_set_provision(struct pblk *pblk, int nr_free_chks) } static int pblk_setup_line_meta_chk(struct pblk *pblk, struct pblk_line *line, - struct nvm_chk_meta *meta) + struct nvm_chk_meta *meta, int *opened) { struct nvm_tgt_dev *dev = pblk->dev; struct nvm_geo *geo = &dev->geo; @@ -748,6 +748,9 @@ static int pblk_setup_line_meta_chk(struct pblk *pblk, struct pblk_line *line, continue; } + if (chunk->state & NVM_CHK_ST_OPEN) + (*opened)++; + if (!(chunk->state & NVM_CHK_ST_OFFLINE)) continue; @@ -759,7 +762,7 @@ static int pblk_setup_line_meta_chk(struct pblk *pblk, struct pblk_line *line, } static long pblk_setup_line_meta(struct pblk *pblk, struct pblk_line *line, - void *chunk_meta, int line_id) + void *chunk_meta, int line_id, int *opened) { struct pblk_line_mgmt *l_mg = &pblk->l_mg; struct pblk_line_meta *lm = &pblk->lm; @@ -773,7 +776,7 @@ static long pblk_setup_line_meta(struct pblk *pblk, struct pblk_line *line, line->vsc = &l_mg->vsc_list[line_id]; spin_lock_init(&line->lock); - nr_bad_chks = pblk_setup_line_meta_chk(pblk, line, chunk_meta); + nr_bad_chks = pblk_setup_line_meta_chk(pblk, line, chunk_meta, opened); chk_in_line = lm->blk_per_line - nr_bad_chks; if (nr_bad_chks < 0 || nr_bad_chks > lm->blk_per_line || @@ -1019,12 +1022,12 @@ static int pblk_line_meta_init(struct pblk *pblk) return 0; } -static int pblk_lines_init(struct pblk *pblk) +static int pblk_lines_init(struct pblk *pblk, bool factory) { struct pblk_line_mgmt *l_mg = &pblk->l_mg; struct pblk_line *line; void *chunk_meta; - int nr_free_chks = 0; + int nr_free_chks = 0, nr_opened_chks = 0; int i, ret; ret = pblk_line_meta_init(pblk); @@ -1059,7 +1062,8 @@ static int pblk_lines_init(struct pblk *pblk) if (ret) goto fail_free_lines; - nr_free_chks += pblk_setup_line_meta(pblk, line, chunk_meta, i); + nr_free_chks += pblk_setup_line_meta(pblk, line, chunk_meta, i, + &nr_opened_chks); trace_pblk_line_state(pblk_disk_name(pblk), line->id, line->state); @@ -1071,6 +1075,10 @@ static int pblk_lines_init(struct pblk *pblk) goto fail_free_lines; } + if (factory && nr_opened_chks) + pblk_warn(pblk, "%d opened chunks during factory creation\n", + nr_opened_chks); + ret = pblk_set_provision(pblk, nr_free_chks); if (ret) goto fail_free_lines; @@ -1235,7 +1243,7 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, goto fail; } - ret = pblk_lines_init(pblk); + ret = pblk_lines_init(pblk, flags & NVM_TARGET_FACTORY); if (ret) { pblk_err(pblk, "could not initialize lines\n"); goto fail_free_core;