From patchwork Fri May 6 18:03:18 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: 9035181 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 3D2DF9F6CD for ; Fri, 6 May 2016 18:05:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 487932035B for ; Fri, 6 May 2016 18:05:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40E7B20272 for ; Fri, 6 May 2016 18:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932416AbcEFSEG (ORCPT ); Fri, 6 May 2016 14:04:06 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:36572 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932376AbcEFSD7 (ORCPT ); Fri, 6 May 2016 14:03:59 -0400 Received: by mail-wm0-f43.google.com with SMTP id n129so67111254wmn.1 for ; Fri, 06 May 2016 11:03:58 -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=ykhOk3x1fxsugVv4AFjhaJBa1/erHidvmJ145XXPCcXU41j560+36ZsM/n6HF+PqbV 41XzPyeEE6lieN6xmLxHLrTi0kpfUYlZ1Hh+RK0qOOxHgASJwt10Ul9nqhicC4pmGKyG FZ/ZY2j64NuA6WypyLyOnsJyLWZitfKfDkmTk= 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=nDGTpcTLrDoectW5LCyRkhy3aRDpYh43m1K/xBQZEn8r+jO5KegMNLtiIwflKOEfGl 90CGxLeL7D5x1cNIuQY5nWn4tNh4mFjAufkC3w/nMlUg8Q2+N1N9PicKM4OcOZMqTZIG vAkLjOB/34uyiUsHVRZ/v0Fi7a2O8VEGSaDz4G3o3CH8n9RWdPA/65/XsEfX1UF1ebXy z1kp+32Ez/kRJPhPofUwXT7XjrUKV2fg02qf0KH0ACeWxGvDectOF1tEwweYm2dSuvK/ nVeYk41M1VTWc2XuPLqF8uPa4HzyDUUApHAU2T4IrwtvkJN2cjGKLw/r8AFKvXtbTPDO 1+xg== X-Gm-Message-State: AOPr4FUcINNozvqUiXsNjYiyNmr22YGJKUNXmAME0gfyIss9eaTab2a0FVZTNeD0nS8h6Q== X-Received: by 10.194.38.67 with SMTP id e3mr21353743wjk.127.1462557837542; Fri, 06 May 2016 11:03:57 -0700 (PDT) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id kz1sm16076559wjc.46.2016.05.06.11.03.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 May 2016 11:03:56 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 25/28] lightnvm: expose gennvm_mark_blk to targets Date: Fri, 6 May 2016 20:03:18 +0200 Message-Id: <1462557801-24974-26-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462557801-24974-1-git-send-email-m@bjorling.me> References: <1462557801-24974-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=unavailable 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;