From patchwork Wed May 4 12:34:45 2016 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: 9013621 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 70E309F39D for ; Wed, 4 May 2016 12:35:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E2D9203A4 for ; Wed, 4 May 2016 12:35:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67A7F203A1 for ; Wed, 4 May 2016 12:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbcEDMfT (ORCPT ); Wed, 4 May 2016 08:35:19 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:34909 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753351AbcEDMez (ORCPT ); Wed, 4 May 2016 08:34:55 -0400 Received: by mail-wm0-f42.google.com with SMTP id e201so186000956wme.0 for ; Wed, 04 May 2016 05:34:54 -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=jzWs+VFkLhlig2fg72yqT/pXBkAQ2amV/eM8s+dWos8=; b=ka3itTqOFS3n9XCf4yhjKdU5/2olRXFODxv6+3CNjFCQ/IHWtG1vOC42ViuR7emO1Z k55LwJUai2RJS/ygqX3MDJcNNsH3sNFQ8h8znfL2p/tDQ0CLtqw8gPLf2RZrkfxL61A+ ir8+++CM0Wlb1kxecm+aXvNkzDnTaNgszYd38= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jzWs+VFkLhlig2fg72yqT/pXBkAQ2amV/eM8s+dWos8=; b=m900GxxzjmyKqwtrojJ0JpNXJqWK+nDE26ZuXKaicFm0NdwhmF2jeSJ+EvyR8Pqh1b buYWlfy6w0LTBIE88qLEe7/RNhgZ+JBMMGYvq1j9ptufKB4RTGfS3TohWUSu8ABKMScH BjKd5pAwDr8J7cxaQrH6lUVogQCp9ALm31UO+4V5JhNgCZp1UaQc1h641lXb/nMznN+W 6g8/1hcJSd8aI8pYR8sulYPv898e67qpz1Oe9wCcl0CKsmdf6n0ltW+NtrvcgmGLJMBP 6laQVmsvsA9rk6uEDN2sTOexCzIZ6acxmESyH8g6YEH2J2wwy8WztrufTYjDsCS3mXCT VWIg== X-Gm-Message-State: AOPr4FUU/zGtVw3q5aWbVbLPhbobwChHCCwUaEJjrhWUN/1+PJQe+XIsJC9TXhEF7+NFkQ== X-Received: by 10.194.138.37 with SMTP id qn5mr8444012wjb.108.1462365294040; Wed, 04 May 2016 05:34:54 -0700 (PDT) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id gr4sm3994024wjd.23.2016.05.04.05.34.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 05:34:53 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 2/2] lightnvm: expose gennvm_mark_blk to targets Date: Wed, 4 May 2016 14:34:45 +0200 Message-Id: <1462365285-627-2-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462365285-627-1-git-send-email-m@bjorling.me> References: <1462365285-627-1-git-send-email-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-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Targets can update a block state when having a reference to an in-memory virtual block. In the case that a target does not keep the block metadata in memory, it does not have a way to update this structure. Therefore, expose gennvm_mark_blk() through the media managers ->mark_blk() callback and let targets update the state structure through this callback. Signed-off-by: Matias Bjørling --- drivers/lightnvm/gennvm.c | 27 ++++++++++++++------------- include/linux/lightnvm.h | 4 ++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 61790ae..33a66d8c0 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -407,29 +407,28 @@ static void gennvm_put_blk(struct nvm_dev *dev, struct nvm_block *blk) spin_unlock(&vlun->lock); } -static void gennvm_blk_set_type(struct nvm_dev *dev, struct ppa_addr *ppa, - int type) +static void gennvm_mark_blk(struct nvm_dev *dev, struct ppa_addr ppa, int type) { struct gen_nvm *gn = dev->mp; struct gen_lun *lun; struct nvm_block *blk; pr_debug("gennvm: ppa (ch: %u lun: %u blk: %u pg: %u) -> %u\n", - ppa->g.ch, ppa->g.lun, ppa->g.blk, ppa->g.pg, type); + ppa.g.ch, ppa.g.lun, ppa.g.blk, ppa.g.pg, type); - if (unlikely(ppa->g.ch > dev->nr_chnls || - ppa->g.lun > dev->luns_per_chnl || - ppa->g.blk > dev->blks_per_lun)) { + if (unlikely(ppa.g.ch > dev->nr_chnls || + ppa.g.lun > dev->luns_per_chnl || + ppa.g.blk > dev->blks_per_lun)) { WARN_ON_ONCE(1); pr_err("gennvm: ppa broken (ch: %u > %u lun: %u > %u blk: %u > %u", - ppa->g.ch, dev->nr_chnls, - ppa->g.lun, dev->luns_per_chnl, - ppa->g.blk, dev->blks_per_lun); + ppa.g.ch, dev->nr_chnls, + ppa.g.lun, dev->luns_per_chnl, + ppa.g.blk, dev->blks_per_lun); return; } - lun = &gn->luns[ppa->g.lun * ppa->g.ch]; - blk = &lun->vlun.blocks[ppa->g.blk]; + lun = &gn->luns[ppa.g.lun * ppa.g.ch]; + blk = &lun->vlun.blocks[ppa.g.blk]; /* will be moved to bb list on put_blk from target */ blk->state = type; @@ -448,12 +447,12 @@ static void gennvm_mark_blk_bad(struct nvm_dev *dev, struct nvm_rq *rqd) /* look up blocks and mark them as bad */ if (rqd->nr_pages == 1) { - gennvm_blk_set_type(dev, &rqd->ppa_addr, NVM_BLK_ST_BAD); + gennvm_mark_blk(dev, rqd->ppa_addr, NVM_BLK_ST_BAD); return; } while ((bit = find_next_bit(comp_bits, max_secs, bit + 1)) < max_secs) - gennvm_blk_set_type(dev, &rqd->ppa_list[bit], NVM_BLK_ST_BAD); + gennvm_mark_blk(dev, rqd->ppa_list[bit], NVM_BLK_ST_BAD); } static void gennvm_end_io(struct nvm_rq *rqd) @@ -544,6 +543,8 @@ static struct nvmm_type gennvm = { .submit_io = gennvm_submit_io, .erase_blk = gennvm_erase_blk, + .mark_blk = gennvm_mark_blk, + .get_lun = gennvm_get_lun, .reserve_lun = gennvm_reserve_lun, .release_lun = gennvm_release_lun, diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index cde31ff..3c53911 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -467,6 +467,7 @@ typedef void (nvmm_flush_blk_fn)(struct nvm_dev *, struct nvm_block *); typedef int (nvmm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *); typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *, unsigned long); +typedef void (nvmm_mark_blk_fn)(struct nvm_dev *, struct ppa_addr, int); typedef struct nvm_lun *(nvmm_get_lun_fn)(struct nvm_dev *, int); typedef int (nvmm_reserve_lun)(struct nvm_dev *, int); typedef void (nvmm_release_lun)(struct nvm_dev *, int); @@ -494,6 +495,9 @@ struct nvmm_type { nvmm_submit_io_fn *submit_io; nvmm_erase_blk_fn *erase_blk; + /* Bad block mgmt */ + nvmm_mark_blk_fn *mark_blk; + /* Configuration management */ nvmm_get_lun_fn *get_lun; nvmm_reserve_lun *reserve_lun;