From patchwork Wed Aug 29 12:23:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580137 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 CEDAE14BD for ; Wed, 29 Aug 2018 12:24:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDB6A2A6CF for ; Wed, 29 Aug 2018 12:24:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B21442A70A; Wed, 29 Aug 2018 12:24:35 +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,DKIM_SIGNED, DKIM_VALID,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 E8D372A6D1 for ; Wed, 29 Aug 2018 12:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727312AbeH2QVN (ORCPT ); Wed, 29 Aug 2018 12:21:13 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41989 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbeH2QUf (ORCPT ); Wed, 29 Aug 2018 12:20:35 -0400 Received: by mail-ed1-f65.google.com with SMTP id l5so1131752edw.9 for ; Wed, 29 Aug 2018 05:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YxpryWbxNMN7laS1bl7eqZf5eaAI6L1jREkrriFJ8qg=; b=WyW7lVzm5N3W0rDszF0V3jFi3ldmHm4WDtWXnUQkWZW1CStVuV21bJgmqfCvXtBFD6 PuxpJvnmuMJQQ5PoFSSxvpxRO1vGw2cIBRpD13zQumWIC2Vuh3n0XON+MB4jxwJJZD+n 5auSScj8S6muCZ+tBG709fjP8UDDQz2H6IysZDkQgnc6ItksmP9CN1Mfgi7qugCKDF3L ST1/tfCGk5Z+vK6+o9ehMcVXLxNURXUbkEvdS/R5QbhCGRUSZoGMw29rsZV/k9iGF3X4 lxVZjCVrmDdUvzkcS99zwvu8ALl6zFm1dHHS6WDoT0aRwFIGsIN7WB94sR86NnqeD6Co 9ohQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YxpryWbxNMN7laS1bl7eqZf5eaAI6L1jREkrriFJ8qg=; b=Onrddl3rhI7VY3ELb3MnM39vOnoY6dF74gShLWqz7WxXkx1kuDy2VaYlZn1yIU205t bV18KkTGoHAMcdVv6cE37O9lElOtMLA737j2nj0EInfV7arf6IqRFE+WE+qw2zGcmlcR unBXXaajRLBCGmSqeAbUQVjugLDtaDUOIW77bMMT6CiIH3DTpQPUFUezKKDRwnTNgpRf l4VPToX8EV2qkF3zXPLiR2F+3UMocAkhvEXMuEh+xaERjVwmuCioZbiUZYd9gfAJ+I+q acch/cW5d+WRv1vANzdpNl+a9E+mRo5w52EUIJIWXHahDFZQ1exa2j1EoMR8LjbqnOf7 B03Q== X-Gm-Message-State: APzg51AHgOQM9GWtqQr0+nNhUp++IvbNtdSw72/9ko8Ju14zs9SAKwAF xa3XXSFp18Nl1YE2R+vjQPeLUg== X-Google-Smtp-Source: ANB0VdbrM1uQ+MVGbq+6NNG6JBLSyXQg2s/HSOHbUNq+OBwDi9IL3NXoDsnINHkDjZ7Pgnk+dUTyKw== X-Received: by 2002:a50:9a02:: with SMTP id o2-v6mr7525241edb.236.1535545432900; Wed, 29 Aug 2018 05:23:52 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:52 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 1/7] lightnvm: introduce nvm_rq_to_ppa_list Date: Wed, 29 Aug 2018 14:23:28 +0200 Message-Id: <1535545414-550-2-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg There is a number of places in the lightnvm subsystem where the user iterates over the ppa list. Before iterating, the user must know if it is a single or multiple LBAs due to vector commands using either the nvm_rq ->ppa_addr or ->ppa_list fields on command submission, which leads to open-coding the if/else statement. Instead of having multiple if/else's, move it into a function that can be called by its users. A nice side effect of this cleanup is that this patch fixes up a bunch of cases where we don't consider the single-ppa case in pblk. Signed-off-by: Hans Holmberg --- drivers/lightnvm/core.c | 14 ++++---------- drivers/lightnvm/pblk-map.c | 10 ++++++---- drivers/lightnvm/pblk-read.c | 11 ++++------- drivers/lightnvm/pblk-recovery.c | 9 ++++++--- drivers/lightnvm/pblk-write.c | 18 ++++++++---------- drivers/lightnvm/pblk.h | 4 +--- include/linux/lightnvm.h | 5 +++++ 7 files changed, 34 insertions(+), 37 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 5d0ed33d7c59..f7154398ba38 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -603,22 +603,16 @@ static void nvm_ppa_dev_to_tgt(struct nvm_tgt_dev *tgt_dev, static void nvm_rq_tgt_to_dev(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) { - if (rqd->nr_ppas == 1) { - nvm_ppa_tgt_to_dev(tgt_dev, &rqd->ppa_addr, 1); - return; - } + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); - nvm_ppa_tgt_to_dev(tgt_dev, rqd->ppa_list, rqd->nr_ppas); + nvm_ppa_tgt_to_dev(tgt_dev, ppa_list, rqd->nr_ppas); } static void nvm_rq_dev_to_tgt(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) { - if (rqd->nr_ppas == 1) { - nvm_ppa_dev_to_tgt(tgt_dev, &rqd->ppa_addr, 1); - return; - } + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); - nvm_ppa_dev_to_tgt(tgt_dev, rqd->ppa_list, rqd->nr_ppas); + nvm_ppa_dev_to_tgt(tgt_dev, ppa_list, rqd->nr_ppas); } int nvm_register_tgt_type(struct nvm_tgt_type *tt) diff --git a/drivers/lightnvm/pblk-map.c b/drivers/lightnvm/pblk-map.c index 953ca31dda68..dc0efb852475 100644 --- a/drivers/lightnvm/pblk-map.c +++ b/drivers/lightnvm/pblk-map.c @@ -88,13 +88,14 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry, unsigned int off) { struct pblk_sec_meta *meta_list = rqd->meta_list; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); unsigned int map_secs; int min = pblk->min_write_pgs; int i; for (i = off; i < rqd->nr_ppas; i += min) { map_secs = (i + min > valid_secs) ? (valid_secs % min) : min; - if (pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i], + if (pblk_map_page_data(pblk, sentry + i, &ppa_list[i], lun_bitmap, &meta_list[i], map_secs)) { bio_put(rqd->bio); pblk_free_rqd(pblk, rqd, PBLK_WRITE); @@ -112,6 +113,7 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd, struct nvm_geo *geo = &dev->geo; struct pblk_line_meta *lm = &pblk->lm; struct pblk_sec_meta *meta_list = rqd->meta_list; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); struct pblk_line *e_line, *d_line; unsigned int map_secs; int min = pblk->min_write_pgs; @@ -119,14 +121,14 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd, for (i = 0; i < rqd->nr_ppas; i += min) { map_secs = (i + min > valid_secs) ? (valid_secs % min) : min; - if (pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i], + if (pblk_map_page_data(pblk, sentry + i, &ppa_list[i], lun_bitmap, &meta_list[i], map_secs)) { bio_put(rqd->bio); pblk_free_rqd(pblk, rqd, PBLK_WRITE); pblk_pipeline_stop(pblk); } - erase_lun = pblk_ppa_to_pos(geo, rqd->ppa_list[i]); + erase_lun = pblk_ppa_to_pos(geo, ppa_list[i]); /* line can change after page map. We might also be writing the * last line. @@ -141,7 +143,7 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd, set_bit(erase_lun, e_line->erase_bitmap); atomic_dec(&e_line->left_eblks); - *erase_ppa = rqd->ppa_list[i]; + *erase_ppa = ppa_list[i]; erase_ppa->a.blk = e_line->id; spin_unlock(&e_line->lock); diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c index 928c638af5b6..df3c4eb13be9 100644 --- a/drivers/lightnvm/pblk-read.c +++ b/drivers/lightnvm/pblk-read.c @@ -116,10 +116,9 @@ static void pblk_read_check_seq(struct pblk *pblk, struct nvm_rq *rqd, if (lba != blba + i) { #ifdef CONFIG_NVM_PBLK_DEBUG - struct ppa_addr *p; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); - p = (nr_lbas == 1) ? &rqd->ppa_list[i] : &rqd->ppa_addr; - print_ppa(pblk, p, "seq", i); + print_ppa(pblk, &ppa_list[i], "seq", i); #endif pblk_err(pblk, "corrupted read LBA (%llu/%llu)\n", lba, (u64)blba + i); @@ -148,11 +147,9 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd, if (lba != meta_lba) { #ifdef CONFIG_NVM_PBLK_DEBUG - struct ppa_addr *p; - int nr_ppas = rqd->nr_ppas; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); - p = (nr_ppas == 1) ? &rqd->ppa_list[j] : &rqd->ppa_addr; - print_ppa(pblk, p, "seq", j); + print_ppa(pblk, &ppa_list[j], "seq", j); #endif pblk_err(pblk, "corrupted read LBA (%llu/%llu)\n", lba, meta_lba); diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index cf629ab016ba..3bd2b6b0a359 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -161,6 +161,8 @@ static int pblk_recov_read_oob(struct pblk *pblk, struct pblk_line *line, if (pblk_io_aligned(pblk, rq_ppas)) rqd->is_seq = 1; + ppa_list = nvm_rq_to_ppa_list(rqd); + for (i = 0; i < rqd->nr_ppas; ) { struct ppa_addr ppa; int pos; @@ -175,7 +177,7 @@ static int pblk_recov_read_oob(struct pblk *pblk, struct pblk_line *line, } for (j = 0; j < pblk->min_write_pgs; j++, i++, r_ptr_int++) - rqd->ppa_list[i] = + ppa_list[i] = addr_to_gen_ppa(pblk, r_ptr_int, line->id); } @@ -202,7 +204,7 @@ static int pblk_recov_read_oob(struct pblk *pblk, struct pblk_line *line, if (lba == ADDR_EMPTY || lba > pblk->rl.nr_secs) continue; - pblk_update_map(pblk, lba, rqd->ppa_list[i]); + pblk_update_map(pblk, lba, ppa_list[i]); } left_ppas -= rq_ppas; @@ -221,10 +223,11 @@ static void pblk_recov_complete(struct kref *ref) static void pblk_end_io_recov(struct nvm_rq *rqd) { + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); struct pblk_pad_rq *pad_rq = rqd->private; struct pblk *pblk = pad_rq->pblk; - pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas); + pblk_up_page(pblk, ppa_list, rqd->nr_ppas); pblk_free_rqd(pblk, rqd, PBLK_WRITE_INT); diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index c23b65aaa27b..1bc879ab679d 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -208,15 +208,10 @@ static void pblk_submit_rec(struct work_struct *work) struct pblk *pblk = recovery->pblk; struct nvm_rq *rqd = recovery->rqd; struct pblk_c_ctx *c_ctx = nvm_rq_to_pdu(rqd); - struct ppa_addr *ppa_list; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); pblk_log_write_err(pblk, rqd); - if (rqd->nr_ppas == 1) - ppa_list = &rqd->ppa_addr; - else - ppa_list = rqd->ppa_list; - pblk_map_remaining(pblk, ppa_list); pblk_queue_resubmit(pblk, c_ctx); @@ -273,9 +268,10 @@ static void pblk_end_io_write_meta(struct nvm_rq *rqd) struct pblk_g_ctx *m_ctx = nvm_rq_to_pdu(rqd); struct pblk_line *line = m_ctx->private; struct pblk_emeta *emeta = line->emeta; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); int sync; - pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas); + pblk_up_page(pblk, ppa_list, rqd->nr_ppas); if (rqd->error) { pblk_log_write_err(pblk, rqd); @@ -375,6 +371,7 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line) struct pblk_line_mgmt *l_mg = &pblk->l_mg; struct pblk_line_meta *lm = &pblk->lm; struct pblk_emeta *emeta = meta_line->emeta; + struct ppa_addr *ppa_list; struct pblk_g_ctx *m_ctx; struct bio *bio; struct nvm_rq *rqd; @@ -409,12 +406,13 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line) if (ret) goto fail_free_bio; + ppa_list = nvm_rq_to_ppa_list(rqd); for (i = 0; i < rqd->nr_ppas; ) { spin_lock(&meta_line->lock); paddr = __pblk_alloc_page(pblk, meta_line, rq_ppas); spin_unlock(&meta_line->lock); for (j = 0; j < rq_ppas; j++, i++, paddr++) - rqd->ppa_list[i] = addr_to_gen_ppa(pblk, paddr, id); + ppa_list[i] = addr_to_gen_ppa(pblk, paddr, id); } spin_lock(&l_mg->close_lock); @@ -423,7 +421,7 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line) list_del(&meta_line->list); spin_unlock(&l_mg->close_lock); - pblk_down_page(pblk, rqd->ppa_list, rqd->nr_ppas); + pblk_down_page(pblk, ppa_list, rqd->nr_ppas); ret = pblk_submit_io(pblk, rqd); if (ret) { @@ -434,7 +432,7 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line) return NVM_IO_OK; fail_rollback: - pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas); + pblk_up_page(pblk, ppa_list, rqd->nr_ppas); spin_lock(&l_mg->close_lock); pblk_dealloc_page(pblk, meta_line, rq_ppas); list_add(&meta_line->list, &meta_line->list); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index eda66fed8e3a..fd274985aa82 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -1374,9 +1374,7 @@ static inline int pblk_boundary_ppa_checks(struct nvm_tgt_dev *tgt_dev, static inline int pblk_check_io(struct pblk *pblk, struct nvm_rq *rqd) { struct nvm_tgt_dev *dev = pblk->dev; - struct ppa_addr *ppa_list; - - ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; + struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); if (pblk_boundary_ppa_checks(dev, ppa_list, rqd->nr_ppas)) { WARN_ON(1); diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 0106984400bc..c3ee729feda5 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -320,6 +320,11 @@ static inline void *nvm_rq_to_pdu(struct nvm_rq *rqdata) return rqdata + 1; } +static inline struct ppa_addr *nvm_rq_to_ppa_list(struct nvm_rq *rqd) +{ + return (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; +} + enum { NVM_BLK_ST_FREE = 0x1, /* Free block */ NVM_BLK_ST_TGT = 0x2, /* Block in use by target */ From patchwork Wed Aug 29 12:23:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580135 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 3D4031709 for ; Wed, 29 Aug 2018 12:24:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF112A6CF for ; Wed, 29 Aug 2018 12:24:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20C512A76E; Wed, 29 Aug 2018 12:24:35 +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,DKIM_SIGNED, DKIM_VALID,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 B52C52A6CF for ; Wed, 29 Aug 2018 12:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbeH2QUf (ORCPT ); Wed, 29 Aug 2018 12:20:35 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:35120 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727428AbeH2QUf (ORCPT ); Wed, 29 Aug 2018 12:20:35 -0400 Received: by mail-ed1-f66.google.com with SMTP id y20-v6so3779912edq.2 for ; Wed, 29 Aug 2018 05:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UQkDiPooqhwWS1BzntFMujGan16736ogBbBumqTDCUA=; b=uj14UinMVay5ZkiWviYTdI+pTG4xbCVOnBBgOKyHEuByq4aDPd6zu8ET9xtNACGtvZ Qib4Ajq4vl23c7ywIGB61Oxgde9xo/q6ueEjbwFEi2GCp+iGn11/Ads6ZgDHTWp36OgZ H1OSUxtqzIqDjr26ZMyBHe8uTi9EQ/m+zTRr9OcqRJjmddoltDMs3N4Ki3dH1zMoInqv 7Jm/VUSZm+MvNcaIfmp7gqHLbstOOlAP1TX2TkPdITL22Ng0IV0pcAhL271yREljpU0/ 7mkTRlsHGIz8cz7+ZnIEuAsgPc1WD+PdMsDhPL5gA19umgkHRije+x/auHRIA/mOSzR9 QgmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UQkDiPooqhwWS1BzntFMujGan16736ogBbBumqTDCUA=; b=ue2RjKa1GDdYkp73L1dyNMN3cA/KlynDCwHkfNQ2B/YITdjGVCZbF9rtL9srMHo4Bk q4kPtNapVFU4qnLyv6yX4ATyZ40G9TucMGu4SZEEWRGQ8D4m5C9S1wEZDtO/M2rENbZN PzlYIJvRYyCgtB8bdH/+GN7dXVjX7dcF38YgrxPQZYVRdgxhEaBu8DrkZocfnyzGZ4Ze GcO6A1fUM3fxgpR38xFY6tOmEr5fKufyVhCXUC5VEQe3eLKzoEjvouA75awHlOjWmEEO FnV/SQoQsDKBVHUffHvfK5y5BnhJN9S/7gNwY5oe3DJAvQ/IqVFGNsqdJsQcarYFrgjB Y99w== X-Gm-Message-State: APzg51C5LnIfWdw3jl6TmGo0vx6ZVjlpb69qlDZGXB2k2mERQZJW6d/h 0Z10VAsYcsX7nafYbFPKVd9rQA== X-Google-Smtp-Source: ANB0VdbmFoXZYiJkhlK15N2JZfPiVCuEudCTsMRA/aKm8KcSrbBICal50+bFN6jR+RFrduz9RX4ASQ== X-Received: by 2002:a05:6402:1348:: with SMTP id y8mr7430321edw.222.1535545433868; Wed, 29 Aug 2018 05:23:53 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:53 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 2/7] lightnvm: pblk: fix mapping issue on failed writes Date: Wed, 29 Aug 2018 14:23:29 +0200 Message-Id: <1535545414-550-3-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg On 1.2-devices, the mapping-out of remaning sectors in the failed-write's block can result in an infinite loop, stalling the write pipeline, fix this. Fixes: 6a3abf5beef6 ("lightnvm: pblk: rework write error recovery path") Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-write.c | 45 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index 1bc879ab679d..fd67325f6e54 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -103,6 +103,41 @@ static void pblk_complete_write(struct pblk *pblk, struct nvm_rq *rqd, pblk_rb_sync_end(&pblk->rwb, &flags); } +static int pblk_next_ppa_in_blk(struct nvm_geo *geo, struct ppa_addr *ppa) +{ + int done = 0; + + if (geo->version == NVM_OCSSD_SPEC_12) { + int sec = ppa->g.sec; + + sec++; + if (sec == geo->ws_min) { + int pg = ppa->g.pg; + + sec = 0; + pg++; + if (pg == geo->num_pg) { + int pl = ppa->g.pl; + + pg = 0; + pl++; + if (pl == geo->num_pln) + done = 1; + + ppa->g.pl = pl; + } + ppa->g.pg = pg; + } + ppa->g.sec = sec; + } else { + ppa->m.sec++; + if (ppa->m.sec == geo->clba) + done = 1; + } + + return done; +} + /* Map remaining sectors in chunk, starting from ppa */ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa) { @@ -125,15 +160,7 @@ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa) if (!test_and_set_bit(paddr, line->invalid_bitmap)) le32_add_cpu(line->vsc, -1); - if (geo->version == NVM_OCSSD_SPEC_12) { - map_ppa.ppa++; - if (map_ppa.g.pg == geo->num_pg) - done = 1; - } else { - map_ppa.m.sec++; - if (map_ppa.m.sec == geo->clba) - done = 1; - } + done = pblk_next_ppa_in_blk(geo, &map_ppa); } line->w_err_gc->has_write_err = 1; From patchwork Wed Aug 29 12:23:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580133 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 31E56920 for ; Wed, 29 Aug 2018 12:24:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F862A6CF for ; Wed, 29 Aug 2018 12:24:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14BFC2A70A; Wed, 29 Aug 2018 12:24:26 +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,DKIM_SIGNED, DKIM_VALID,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 83B162A6CF for ; Wed, 29 Aug 2018 12:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbeH2QUg (ORCPT ); Wed, 29 Aug 2018 12:20:36 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:33720 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727877AbeH2QUg (ORCPT ); Wed, 29 Aug 2018 12:20:36 -0400 Received: by mail-ed1-f67.google.com with SMTP id h9-v6so3783916edr.0 for ; Wed, 29 Aug 2018 05:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wd6ju+Sj812p5ByhVH0axrtjEx4TVCFUhWAzZE7kqEw=; b=qIzPA0bQXyNgjNTrtOKifSD0zdslXCpsZvF+bkEaSONuPWXRkydNhAjsaWCsRw2jWc XCPPhKt/SxRPRSdQxvH+qqnXafETwXBhFaS5ywVfGLvaanhAvu90LG3+34ImcymlH0Ag 7JJDf3sDQ2EEdl3cd3+Pa+DB+vMs/Ty2M1f5YYEqwB9KO73+SLgHTanye9gs3Oh/Ggm4 LcttKgD+959fLOIgoRafD/53KBALcLb5n26tcjfbC9Dy61Hmf7CSVGwtNbexuOUA1bre 3yzSJkoodzt4wQ6VrpahBgtOO25VpLpxdhKw3zM41kbUy0bc1JbBNbY9Ai8HpVx1UWOM fLhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wd6ju+Sj812p5ByhVH0axrtjEx4TVCFUhWAzZE7kqEw=; b=imWn5cwg1XH+rA6Wx9Oa8qaOqO+ZVzg93KICuY3Oesn2H0Ktov4Ss6fhTTk4r7gdP+ r5FQwtp7tTJNZ8oEJVYY3II36+FE9V1ilePCpGJAhoTOl4cHN4zpFAOMbhLPjnW92gfB ArtJf2kU4Qng/Ralp8+Ha2k/C0bIYaq9nWtzKfEu4I06T70cm6wc72jPQk1+h5/6pW8T z0j4C4LsZDuQxq5cjeVFB/8GL53SjqOGUwQRRBVE7ifuiuOtkXg7gXFWOkDO+DQsDXZM PSMq8fgzVpetUiierEuHrABmShnawOBUu8c+jhd+5Kv1ARYt2GNx9tNNxOD4wuwCHp8E 1PhA== X-Gm-Message-State: APzg51BTAp6rEGyaw/qiLRRE1hlGydfZgcRkZwXSljoAGj91uZEDFQ8K 6llADv7RGz7Y3dVjQ6yEB4IS6w== X-Google-Smtp-Source: ANB0VdZD7GouwO7N0cfZYacQcNFQbeF8s7QYSvEoXvkqDz6DHT5/uQocDYy5v9QHzj4HS0N+367acg== X-Received: by 2002:a50:8cd7:: with SMTP id r23-v6mr7407214edr.240.1535545435062; Wed, 29 Aug 2018 05:23:55 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:54 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 3/7] lightnvm: pblk: allocate line map bitmaps using a mempool Date: Wed, 29 Aug 2018 14:23:30 +0200 Message-Id: <1535545414-550-4-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg Line map bitmap allocations are fairly large and can fail. Allocation failures are fatal to pblk, stoping the write pipeline. To avoid this, allocate the bitmaps using a mempool instead. Mempool allocations never fail if called from a process context, and pblk *should* only allocate map bitmaps in process context, but keep the failure handling for robustness sake. Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-core.c | 22 +++++++++++++++------- drivers/lightnvm/pblk-init.c | 18 ++++++++++++++++++ drivers/lightnvm/pblk-recovery.c | 2 +- drivers/lightnvm/pblk.h | 4 ++++ 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 36ac9eff8ebd..a1033d82b9cc 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1049,15 +1049,18 @@ static int pblk_line_init_metadata(struct pblk *pblk, struct pblk_line *line, static int pblk_line_alloc_bitmaps(struct pblk *pblk, struct pblk_line *line) { struct pblk_line_meta *lm = &pblk->lm; + struct pblk_line_mgmt *l_mg = &pblk->l_mg; - line->map_bitmap = kzalloc(lm->sec_bitmap_len, GFP_KERNEL); + line->map_bitmap = mempool_alloc(l_mg->bitmap_pool, GFP_KERNEL); if (!line->map_bitmap) return -ENOMEM; + memset(line->map_bitmap, 0, lm->sec_bitmap_len); + /* will be initialized using bb info from map_bitmap */ - line->invalid_bitmap = kmalloc(lm->sec_bitmap_len, GFP_KERNEL); + line->invalid_bitmap = mempool_alloc(l_mg->bitmap_pool, GFP_KERNEL); if (!line->invalid_bitmap) { - kfree(line->map_bitmap); + mempool_free(line->map_bitmap, l_mg->bitmap_pool); line->map_bitmap = NULL; return -ENOMEM; } @@ -1243,7 +1246,9 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line) void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line) { - kfree(line->map_bitmap); + struct pblk_line_mgmt *l_mg = &pblk->l_mg; + + mempool_free(line->map_bitmap, l_mg->bitmap_pool); line->map_bitmap = NULL; line->smeta = NULL; line->emeta = NULL; @@ -1261,8 +1266,11 @@ static void pblk_line_reinit(struct pblk_line *line) void pblk_line_free(struct pblk_line *line) { - kfree(line->map_bitmap); - kfree(line->invalid_bitmap); + struct pblk *pblk = line->pblk; + struct pblk_line_mgmt *l_mg = &pblk->l_mg; + + mempool_free(line->map_bitmap, l_mg->bitmap_pool); + mempool_free(line->invalid_bitmap, l_mg->bitmap_pool); pblk_line_reinit(line); } @@ -1741,7 +1749,7 @@ void pblk_line_close(struct pblk *pblk, struct pblk_line *line) list_add_tail(&line->list, move_list); - kfree(line->map_bitmap); + mempool_free(line->map_bitmap, l_mg->bitmap_pool); line->map_bitmap = NULL; line->smeta = NULL; line->emeta = NULL; diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 8adc8ac8b03c..76a4a271b9cf 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -498,6 +498,9 @@ static void pblk_line_mg_free(struct pblk *pblk) pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type); kfree(l_mg->eline_meta[i]); } + + mempool_destroy(l_mg->bitmap_pool); + kmem_cache_destroy(l_mg->bitmap_cache); } static void pblk_line_meta_free(struct pblk_line_mgmt *l_mg, @@ -797,6 +800,17 @@ static int pblk_line_mg_init(struct pblk *pblk) goto fail_free_smeta; } + l_mg->bitmap_cache = kmem_cache_create("pblk_lm_bitmap", + lm->sec_bitmap_len, 0, 0, NULL); + if (!l_mg->bitmap_cache) + goto fail_free_smeta; + + /* the bitmap pool is used for both valid and map bitmaps */ + l_mg->bitmap_pool = mempool_create_slab_pool(PBLK_DATA_LINES * 2, + l_mg->bitmap_cache); + if (!l_mg->bitmap_pool) + goto fail_destroy_bitmap_cache; + /* emeta allocates three different buffers for managing metadata with * in-memory and in-media layouts */ @@ -849,6 +863,10 @@ static int pblk_line_mg_init(struct pblk *pblk) kfree(l_mg->eline_meta[i]->buf); kfree(l_mg->eline_meta[i]); } + + mempool_destroy(l_mg->bitmap_pool); +fail_destroy_bitmap_cache: + kmem_cache_destroy(l_mg->bitmap_cache); fail_free_smeta: for (i = 0; i < PBLK_DATA_LINES; i++) kfree(l_mg->sline_meta[i]); diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 3bd2b6b0a359..eea901d7cebc 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -939,7 +939,7 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk) list_move_tail(&line->list, move_list); spin_unlock(&l_mg->gc_lock); - kfree(line->map_bitmap); + mempool_free(line->map_bitmap, l_mg->bitmap_pool); line->map_bitmap = NULL; line->smeta = NULL; line->emeta = NULL; diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index fd274985aa82..1a31fda3a9f2 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -530,6 +530,10 @@ struct pblk_line_mgmt { struct pblk_emeta *eline_meta[PBLK_DATA_LINES]; unsigned long meta_bitmap; + /* Cache and mempool for map/invalid bitmaps */ + struct kmem_cache *bitmap_cache; + mempool_t *bitmap_pool; + /* Helpers for fast bitmap calculations */ unsigned long *bb_template; unsigned long *bb_aux; From patchwork Wed Aug 29 12:23:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580129 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 3AC6E14BD for ; Wed, 29 Aug 2018 12:24:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ABBE2A6CF for ; Wed, 29 Aug 2018 12:24:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F2642A70A; Wed, 29 Aug 2018 12:24:14 +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,DKIM_SIGNED, DKIM_VALID,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 96F9A2A6CF for ; Wed, 29 Aug 2018 12:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728247AbeH2QUj (ORCPT ); Wed, 29 Aug 2018 12:20:39 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:43269 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728099AbeH2QUi (ORCPT ); Wed, 29 Aug 2018 12:20:38 -0400 Received: by mail-ed1-f65.google.com with SMTP id z27-v6so3758562edb.10 for ; Wed, 29 Aug 2018 05:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dEOMsr/EO2TZzLIOiOu9mo5dI59Aiw6t2Vf9/2wyrcc=; b=iyIzmVT/XR8nQohoEOdt61vvMQmbx2Gf+y4XB2tGR3I4UZvARemu5GyL+wgdoV7fHP 04g8u+PJ0f9srsoSvHKEqLFe2A5+bMLgpTMafcA9OJwIYitmgF0yMVLAqzyqAMohPf7j 2eYzqLJBtU4O7bUEDSR5GZlBV68HO9AnHZoMdw78BuC21m8qhzrPA3N2529ueyAVMPGC sX8dJhQspC5LXGBCgqQnY6QwybTRG0c6x0PZscpngB4bK+G0/vBq61x4hP9CztnFUY8c xFiH7Y03q8MA+C1y4NXz6zRngzC5ircx6ueSC23pGp/2XjMrlipa05S+CV2+BR9EIh7C WQJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dEOMsr/EO2TZzLIOiOu9mo5dI59Aiw6t2Vf9/2wyrcc=; b=ZuBTwBtpeQ5ffl5H5TCRYJpxZzcVQ8i+k878EW/QqK1iQwJdHROuNSD/X6DO3Tq7BY LYSCWyBKijs6srGlMnkY0kB2wuV1eaynEdOkyXLRf7R7AoDwpIijCtSoCDxOJO2nRYa8 AVJyjNoqgxeVnFJuAf6muDdxhuGtx+hVEr4KKHjOfz5D0E+5EDzqSB/sV9godkAQ7Liy TWW4OQa+73PfSXAKrLCjJVQtXXv7KGnmcbHma+tLI+GsnUMIsSyUv85M/K6EL8zv8omQ B1A2mf1Tj4ETNxetrnxXfsZiaDU5GDr6QqxM6tznMv++9+9ohXPN128t/kDWTD8kXqZ1 mWEQ== X-Gm-Message-State: APzg51C+Q4uVE9otnNC5RrHd9IVNHCUXlys0A08FKEZciyG/PDr0Qji4 9sPD6AqVf/BQU5SkV5SXMiolMptXmU0v7Q== X-Google-Smtp-Source: ANB0Vda6609BCGz7a/znEodqVH1KDtKJwtLXPSUaJfN40R+J0FnvPM+8YRp41df4VFbX9xtdTQPKjQ== X-Received: by 2002:a50:acc6:: with SMTP id x64-v6mr7472654edc.152.1535545436315; Wed, 29 Aug 2018 05:23:56 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:55 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 4/7] lightnvm: pblk: move global caches to module init/exit Date: Wed, 29 Aug 2018 14:23:31 +0200 Message-Id: <1535545414-550-5-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg Pblk's global caches should not be initialized every time a pblk instance is created, so move the creation and destruction of the caches to module init/exit. Also remove the global pblk lock as it is no longer needed after the move. Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-init.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 76a4a271b9cf..0be64220b5d8 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -27,7 +27,6 @@ MODULE_PARM_DESC(write_buffer_size, "number of entries in a write buffer"); static struct kmem_cache *pblk_ws_cache, *pblk_rec_cache, *pblk_g_rq_cache, *pblk_w_rq_cache; -static DECLARE_RWSEM(pblk_lock); struct bio_set pblk_bio_set; static int pblk_rw_io(struct request_queue *q, struct pblk *pblk, @@ -306,21 +305,17 @@ static int pblk_set_addrf(struct pblk *pblk) return 0; } -static int pblk_init_global_caches(struct pblk *pblk) +static int pblk_init_global_caches(void) { - down_write(&pblk_lock); pblk_ws_cache = kmem_cache_create("pblk_blk_ws", sizeof(struct pblk_line_ws), 0, 0, NULL); - if (!pblk_ws_cache) { - up_write(&pblk_lock); + if (!pblk_ws_cache) return -ENOMEM; - } pblk_rec_cache = kmem_cache_create("pblk_rec", sizeof(struct pblk_rec_ctx), 0, 0, NULL); if (!pblk_rec_cache) { kmem_cache_destroy(pblk_ws_cache); - up_write(&pblk_lock); return -ENOMEM; } @@ -329,7 +324,6 @@ static int pblk_init_global_caches(struct pblk *pblk) if (!pblk_g_rq_cache) { kmem_cache_destroy(pblk_ws_cache); kmem_cache_destroy(pblk_rec_cache); - up_write(&pblk_lock); return -ENOMEM; } @@ -339,15 +333,13 @@ static int pblk_init_global_caches(struct pblk *pblk) kmem_cache_destroy(pblk_ws_cache); kmem_cache_destroy(pblk_rec_cache); kmem_cache_destroy(pblk_g_rq_cache); - up_write(&pblk_lock); return -ENOMEM; } - up_write(&pblk_lock); return 0; } -static void pblk_free_global_caches(struct pblk *pblk) +static void pblk_free_global_caches(void) { kmem_cache_destroy(pblk_ws_cache); kmem_cache_destroy(pblk_rec_cache); @@ -381,13 +373,10 @@ static int pblk_core_init(struct pblk *pblk) if (!pblk->pad_dist) return -ENOMEM; - if (pblk_init_global_caches(pblk)) - goto fail_free_pad_dist; - /* Internal bios can be at most the sectors signaled by the device. */ ret = mempool_init_page_pool(&pblk->page_bio_pool, NVM_MAX_VLBA, 0); if (ret) - goto free_global_caches; + goto free_pad_dist; ret = mempool_init_slab_pool(&pblk->gen_ws_pool, PBLK_GEN_WS_POOL_SIZE, pblk_ws_cache); @@ -455,9 +444,7 @@ static int pblk_core_init(struct pblk *pblk) mempool_exit(&pblk->gen_ws_pool); free_page_bio_pool: mempool_exit(&pblk->page_bio_pool); -free_global_caches: - pblk_free_global_caches(pblk); -fail_free_pad_dist: +free_pad_dist: kfree(pblk->pad_dist); return -ENOMEM; } @@ -480,7 +467,6 @@ static void pblk_core_free(struct pblk *pblk) mempool_exit(&pblk->e_rq_pool); mempool_exit(&pblk->w_rq_pool); - pblk_free_global_caches(pblk); kfree(pblk->pad_dist); } @@ -1067,7 +1053,6 @@ static void pblk_exit(void *private, bool graceful) { struct pblk *pblk = private; - down_write(&pblk_lock); pblk_gc_exit(pblk, graceful); pblk_tear_down(pblk, graceful); @@ -1076,7 +1061,6 @@ static void pblk_exit(void *private, bool graceful) #endif pblk_free(pblk); - up_write(&pblk_lock); } static sector_t pblk_capacity(void *private) @@ -1237,9 +1221,22 @@ static int __init pblk_module_init(void) ret = bioset_init(&pblk_bio_set, BIO_POOL_SIZE, 0, 0); if (ret) return ret; + ret = nvm_register_tgt_type(&tt_pblk); if (ret) - bioset_exit(&pblk_bio_set); + goto fail_exit_bioset; + + ret = pblk_init_global_caches(); + if (ret) + goto fail_unregister_tgt_type; + + return 0; + +fail_unregister_tgt_type: + nvm_unregister_tgt_type(&tt_pblk); +fail_exit_bioset: + bioset_exit(&pblk_bio_set); + return ret; } @@ -1247,6 +1244,7 @@ static void pblk_module_exit(void) { bioset_exit(&pblk_bio_set); nvm_unregister_tgt_type(&tt_pblk); + pblk_free_global_caches(); } module_init(pblk_module_init); From patchwork Wed Aug 29 12:23:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580131 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 6E7CF920 for ; Wed, 29 Aug 2018 12:24:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F0262A6CF for ; Wed, 29 Aug 2018 12:24:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 531F62A70A; Wed, 29 Aug 2018 12:24:23 +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,DKIM_SIGNED, DKIM_VALID,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 DC32C2A6CF for ; Wed, 29 Aug 2018 12:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728173AbeH2QUj (ORCPT ); Wed, 29 Aug 2018 12:20:39 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:43273 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727818AbeH2QUi (ORCPT ); Wed, 29 Aug 2018 12:20:38 -0400 Received: by mail-ed1-f68.google.com with SMTP id z27-v6so3758618edb.10 for ; Wed, 29 Aug 2018 05:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lzDu+omVFir9hg9tJTLksPTFQvlNgd9rJmmR2DmzXbg=; b=Db6RH/OSi8kcRputTXCYNlu0oSblIVQhK+xt4Yk4qbOWWRaK8saQIGC8zvZBiJnrTS B1Jtegz9LuB4ayek/bCe3cfNUzfow5RRBi5fsUQ5yHsrqxxRvweK707GZ8YxKKM+eAFY 6rWxOH/ld/uufEDduKaMQrmSHm69EWnhhXP25AeM9HyGdyewUTjSCubfnISY3u7jIN8Q o4aRvuhhuHmddrXjKHGazXJdjgD43bDy7i2ewNBFjYp5uJ0PhOWpTcQyYQIBmqZHVRFg DCraqzLhxYT82fMfQZngw7+3eKf5EtDDt69UvxslLuwQhp9eFE7rg6X+wad8I1JptQwp qXOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lzDu+omVFir9hg9tJTLksPTFQvlNgd9rJmmR2DmzXbg=; b=gZARbSKIM2EsTG52hbCUBVJD3Arqk/dmyCkyyn0PaMOkXHadbbm0v/48Kf2daIAgBd oL+WteDVaJyge0NHYBZOd2FdTs3S+qHRuH60j0nZnOVu5NhJociRQx3I1hVZROEf+R6e BzEOg6E9NTXnE4TMbG71US3Ld31sN+URDE9LxhtCzghC4AW6LT8hTZQ0v7/ywk9AZY5Y DWevpnWmwDhWfdVHuPD+4I248gbRfky5giC87RcSW9Pe6e6qrf0iM2CIcuXJ4wPXnfKk bP+TJelBGlKZbFieeAXp1FrBIZkiioisvaBU0ytlytkG8hhRV+bq1dB4wdbHhz84goIk j3lQ== X-Gm-Message-State: APzg51DMf+97muSzDCVNP60Ia5VVd8tA09tiKXKKRcrq0i7cwfGA6AqU yXBW4cwpKKpPQOgFC0lJWlLzNQ== X-Google-Smtp-Source: ANB0VdZcF+Wlv4LdALKD/btw46rWUaPA4qVFqJrRiAWOpRYK67A6Wq1DR5SAg1KjnJ0khZViIYHzOA== X-Received: by 2002:a50:b8c5:: with SMTP id l63-v6mr7182646ede.80.1535545437349; Wed, 29 Aug 2018 05:23:57 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:56 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 5/7] lightnvm: pblk: remove unused parameters in pblk_up_rq Date: Wed, 29 Aug 2018 14:23:32 +0200 Message-Id: <1535545414-550-6-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg The parameters nr_ppas and ppa_list are not used, so remove them. Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-core.c | 3 +-- drivers/lightnvm/pblk-write.c | 5 ++--- drivers/lightnvm/pblk.h | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index a1033d82b9cc..f7bff3ae52ac 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1920,8 +1920,7 @@ void pblk_up_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas) up(&rlun->wr_sem); } -void pblk_up_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas, - unsigned long *lun_bitmap) +void pblk_up_rq(struct pblk *pblk, unsigned long *lun_bitmap) { struct nvm_tgt_dev *dev = pblk->dev; struct nvm_geo *geo = &dev->geo; diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index fd67325f6e54..8aa4b9ee5092 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -81,8 +81,7 @@ static void pblk_complete_write(struct pblk *pblk, struct nvm_rq *rqd, #ifdef CONFIG_NVM_PBLK_DEBUG atomic_long_sub(c_ctx->nr_valid, &pblk->inflight_writes); #endif - - pblk_up_rq(pblk, rqd->ppa_list, rqd->nr_ppas, c_ctx->lun_bitmap); + pblk_up_rq(pblk, c_ctx->lun_bitmap); pos = pblk_rb_sync_init(&pblk->rwb, &flags); if (pos == c_ctx->sentry) { @@ -242,7 +241,7 @@ static void pblk_submit_rec(struct work_struct *work) pblk_map_remaining(pblk, ppa_list); pblk_queue_resubmit(pblk, c_ctx); - pblk_up_rq(pblk, rqd->ppa_list, rqd->nr_ppas, c_ctx->lun_bitmap); + pblk_up_rq(pblk, c_ctx->lun_bitmap); if (c_ctx->nr_padded) pblk_bio_free_pages(pblk, rqd->bio, c_ctx->nr_valid, c_ctx->nr_padded); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 1a31fda3a9f2..1bdac22e7897 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -827,8 +827,7 @@ void pblk_up_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas); void pblk_down_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas, unsigned long *lun_bitmap); void pblk_down_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas); -void pblk_up_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas, - unsigned long *lun_bitmap); +void pblk_up_rq(struct pblk *pblk, unsigned long *lun_bitmap); int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags, int nr_pages); void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off, From patchwork Wed Aug 29 12:23:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580127 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 0ADB314BD for ; Wed, 29 Aug 2018 12:24:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE1DF2A6CF for ; Wed, 29 Aug 2018 12:24:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E21C22A70A; Wed, 29 Aug 2018 12:24:12 +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,DKIM_SIGNED, DKIM_VALID,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 7DF5A2A6CF for ; Wed, 29 Aug 2018 12:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbeH2QUv (ORCPT ); Wed, 29 Aug 2018 12:20:51 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:44158 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728167AbeH2QUj (ORCPT ); Wed, 29 Aug 2018 12:20:39 -0400 Received: by mail-ed1-f67.google.com with SMTP id s10-v6so3757421edb.11 for ; Wed, 29 Aug 2018 05:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iBg1uCqOePo2LDQD2c20wRoYMAK/OSTDbgOTeB8gv9s=; b=VTH3oS/evm991XifbHxtoLWtJba9u+i+SMVE79aiZQYpTlVXJpLT07prOzvdrhecvG Fqg1V1tY69ZHsQwYYr3KygrZ2LAWrLCC7g6HJLm/5ZtGeTALAa663TethDCgCxGpELyh LqQxov5J3ozG5UXK+pQljH+/WP3j+fSU8vzn5d2Vmtp9nJLF+2uNxOL2ASts6na1DzUR fJ/OLIs1Ttwqo/SuQy+It/jUA8Ksl6+Bp3nNL+BtNYd47m3KFfyt7E4Fd48fFtmSFwD/ Om07UwJGkvLllnwjQOMZ4BmoXx4KGyvcDFVVrMhAoK939DBFn66DVGB2rR3CoiK4rwVS UfGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iBg1uCqOePo2LDQD2c20wRoYMAK/OSTDbgOTeB8gv9s=; b=D8pqDrmgh0dE46jRdVHKt1y0QjbtkoWdWk8CeQlKTDz8e2a15cFahjq7PslnWXHONN yRJUNjH5wct/VgYJevjTN/loIsAnSuhzguDJDSDJ6g4cWUWORmPt9KRjkp1gp5ucunQ+ jIukfgCWjmMHzKozvz7uvI1/JPMVRiSDnhyKjQRpKPp9TShIMY9DafCKQ4dJp47SUu/W o09Pk5EZJj598ln9EhxOALBH2sz5/22ykFSAWZpNKXgWI6NthLXJpV64WOkoPA9+CWMa mcvKkxMZ7R+tNA64u+iyIPX5jWNlYHvelEfPXlgbJ4vQ/lZ9jemaRpfYYK+aWiq03Gbj dTTw== X-Gm-Message-State: APzg51AGXxghgtilJbXZVxDwwz8DcxFz5+35MmjMG5Bhbnka968GjutO 1DEsJlr2QoAjdnWiZeK9v7/AYA== X-Google-Smtp-Source: ANB0VdYbZmjm7lvjZzIrAgDIF4woMGj3O/Sn3M5tcK/PDoYspDA130nYXhZyi+digGGWYSWY/JEA5Q== X-Received: by 2002:a50:94b3:: with SMTP id s48-v6mr7142068eda.125.1535545438286; Wed, 29 Aug 2018 05:23:58 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:57 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 6/7] lightnvm: pblk: fix up prints in pblk_read_check_rand Date: Wed, 29 Aug 2018 14:23:33 +0200 Message-Id: <1535545414-550-7-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg The prefix when printing ppas in pblk_read_check_rand should be "rnd" not "seq", so fix this so we can differentiate between lba missmatches in random and sequential reads. Also change the print order so we align with pblk_read_check_seq, printing read lba first. Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-read.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c index df3c4eb13be9..6d13763f2f6a 100644 --- a/drivers/lightnvm/pblk-read.c +++ b/drivers/lightnvm/pblk-read.c @@ -149,10 +149,10 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd, #ifdef CONFIG_NVM_PBLK_DEBUG struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); - print_ppa(pblk, &ppa_list[j], "seq", j); + print_ppa(pblk, &ppa_list[j], "rnd", j); #endif pblk_err(pblk, "corrupted read LBA (%llu/%llu)\n", - lba, meta_lba); + meta_lba, lba); WARN_ON(1); } From patchwork Wed Aug 29 12:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10580125 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 3B55D920 for ; Wed, 29 Aug 2018 12:24:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 291022A6CF for ; Wed, 29 Aug 2018 12:24:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AF9B2A70A; Wed, 29 Aug 2018 12:24:09 +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,DKIM_SIGNED, DKIM_VALID,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 BBDD12A6CF for ; Wed, 29 Aug 2018 12:24:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727460AbeH2QUk (ORCPT ); Wed, 29 Aug 2018 12:20:40 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35986 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728245AbeH2QUk (ORCPT ); Wed, 29 Aug 2018 12:20:40 -0400 Received: by mail-ed1-f65.google.com with SMTP id f4-v6so3783945edq.3 for ; Wed, 29 Aug 2018 05:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lfyMZlbjbi+SYjhMjZnTgdIpBeV8AHl05jO2l5sWcXY=; b=sYIkLWnCVWGpFIbCk/wCWULMG4wXn798HYm6CEGy/nmnWGgONpOOwLBVaDEkiywptB OPCxvyQAjEm8oIRIWYHDj09K2BODTqTBw3lXrwdQ1SwTPTVx9NWdaW6kn8OsooKi+CbN qiuGVly//MVu3sieDFpQN5XcqCAkTMuO9UxCxc5lmyMX4KJFPad8BcRcty6RUEipWw/4 Whtl8evBPM8fvW0+L/xdAkmWwuN0kO+K7qChzcdzlB1ebjaH57I/aWTZ0kYvUhtKHCgq aVUxz+dPid4bckQtSYO86OREvy3DVMOsLOxWlf3N894Mps/wutI1jmtV4G+aZe3MQ4Qu cq9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lfyMZlbjbi+SYjhMjZnTgdIpBeV8AHl05jO2l5sWcXY=; b=Elw4XhheFCl3slNT5k9EfNyOfkdnrS+2lvgKm12YAm8k0VqNVpVgHx8nlY0J4iX5Ex WChaay17migMrW1C82BqOIjI6MUscqnV4qGFUfAlvMY7Lo/drvfPLjL7jRA+fMs4c9mT wj2Htk4amm6iRSNgKdjvGt/QBcuGy9ufDh01IJnkVxFy3CKgxgEX1DzCwpH07c+mZ30D X7l+1IATyldksO8XWiQLxNIq/jScS7tUn6Tiw4XFHtuAOB9seihNiYXrErwF1vcphkFf kuZ14sXYGTc5wM3Um99KhuFFRK2wASGp5Ngf0HrUT92lrwEQsox5/t5rgp7X9lM7TJqD rPbg== X-Gm-Message-State: APzg51AKatBPNLMIZfH5Vc1dd5x1WTCnN/eraCdpvo9R7hOHtva9QF/O Jm5AXr0IRJ7CitbR44Z7ytt9qw== X-Google-Smtp-Source: ANB0VdYAQ+RjHI27Vgvn+uBh+ixA2+fz4NDdj+pxYu+jFIJP1CAvy4FAM85CyiANDIdz9SL5yVxUkw== X-Received: by 2002:a50:c05a:: with SMTP id u26-v6mr7258923edd.107.1535545439305; Wed, 29 Aug 2018 05:23:59 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id f26-v6sm1752068edb.28.2018.08.29.05.23.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 05:23:58 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg Subject: [PATCH 7/7] lightnvm: pblk: fix write amplificiation calculation Date: Wed, 29 Aug 2018 14:23:34 +0200 Message-Id: <1535545414-550-8-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1535545414-550-1-git-send-email-hans.ml.holmberg@owltronix.com> 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: Hans Holmberg When the user data counter exceeds 32 bits, the write amplification calculation does not provide the right value. Fix this by using div64_u64 in stead of div64. Fixes: 76758390f83e ("lightnvm: pblk: export write amplification counters to sysfs") Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/lightnvm/pblk-sysfs.c b/drivers/lightnvm/pblk-sysfs.c index 9fc3dfa168b4..e56eeeeb914e 100644 --- a/drivers/lightnvm/pblk-sysfs.c +++ b/drivers/lightnvm/pblk-sysfs.c @@ -337,7 +337,6 @@ static ssize_t pblk_get_write_amp(u64 user, u64 gc, u64 pad, { int sz; - sz = snprintf(page, PAGE_SIZE, "user:%lld gc:%lld pad:%lld WA:", user, gc, pad); @@ -349,7 +348,7 @@ static ssize_t pblk_get_write_amp(u64 user, u64 gc, u64 pad, u32 wa_frac; wa_int = (user + gc + pad) * 100000; - wa_int = div_u64(wa_int, user); + wa_int = div64_u64(wa_int, user); wa_int = div_u64_rem(wa_int, 100000, &wa_frac); sz += snprintf(page + sz, PAGE_SIZE - sz, "%llu.%05u\n",