From patchwork Wed Apr 13 08:27:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 8819501 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 4389B9F36E for ; Wed, 13 Apr 2016 08:27:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72D6620256 for ; Wed, 13 Apr 2016 08:27:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9298B20122 for ; Wed, 13 Apr 2016 08:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757919AbcDMI0T (ORCPT ); Wed, 13 Apr 2016 04:26:19 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35333 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757705AbcDMI0P (ORCPT ); Wed, 13 Apr 2016 04:26:15 -0400 Received: by mail-pf0-f194.google.com with SMTP id r187so3496004pfr.2; Wed, 13 Apr 2016 01:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CXErOp7PRDNp29sf/ETPT7FWzH8gDpbq1w81igmqBO8=; b=rkJG+Yf/7fhvBbfHMdCaDEDQ9c9JksgJmlm3cG3goZVI9VVFXxA2nTXAycC8kB+X6A xRdvdj5CQw2FFBhZz1e024hZZ95jyz2i0KfDNLqf03iygna2Yo0VH4R2g5Z6BCR3QyIt PR1obph9M3lZnQA/tP69Q3nO7DnjyNTPOW0ZLmHs+hONPfrTkVNn/Tul5cMCxvwS+HYa 89ynWXxrGgDb6+CIOKVIbCOuUPtLdhvfFQ+9RcIZCjVQkSkgJEqkDcwZ6kNM9vQUcZ6L USfpuAHh8c9rzLSYXC0ti9KwBAkgF+y/MMnKU6m3ADOHU3wN9EI1HQ5qiq2sOuY2tzNs +kgQ== 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; bh=CXErOp7PRDNp29sf/ETPT7FWzH8gDpbq1w81igmqBO8=; b=I+LqE4ovwSMzT2JWRf/SwOJElnSo2dbg9m5DPWw2OY6LaTTZpOi8mgHXqjc/biUJUc sHhj0vstFsBqN9hBQgS384ejhia9YOPRrOuUuEJfUO8UJju4f/FHZNA8ebE5hSKuBQRr SspP3nkWRWi4x4zOdFiUX4uji0oQjaS3SNtNltziTG+JmIqQHy5YkZR6IRIX+cvyfMv4 kPzW43jlUb8KKMYXAuqTfMWnFs2JiYXJZTgYZuCRLYxzXmoImidILUQgocRbiEmKHHHf BYS1Bto62XdQGFXZoC5NjqEK2JhuuMsdALRo2OJLjjkATiMOespLQxA0tpea2w8As7wL 6LZg== X-Gm-Message-State: AOPr4FX+5RqVAJG0338vruoNTvn+tHTfe7P2PdYnHfNI1E1TGbkJYhTQXljDc/nQtL5nCQ== X-Received: by 10.98.34.216 with SMTP id p85mr11076309pfj.45.1460535974918; Wed, 13 Apr 2016 01:26:14 -0700 (PDT) Received: from taowenwei.bj-memblaze.com ([61.148.242.58]) by smtp.gmail.com with ESMTPSA id bb5sm3764391pac.21.2016.04.13.01.26.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Apr 2016 01:26:14 -0700 (PDT) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 2/3] lightnvm: store rrpc soffset in device sector size instead of 512 Date: Wed, 13 Apr 2016 16:27:51 +0800 Message-Id: <1460536072-1728-2-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 2.7.1.windows.2 In-Reply-To: <1460536072-1728-1-git-send-email-ww.tao0320@gmail.com> References: <1460536072-1728-1-git-send-email-ww.tao0320@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 Since we mainly use soffset in device sector size, we store that value in rrpc->soffset to reduce doing "(ilog2(dev->sec_size) - 9)". Signed-off-by: Wenwei Tao --- drivers/lightnvm/rrpc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index c0e303c..3143b98 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1039,11 +1039,8 @@ static int rrpc_map_init(struct rrpc *rrpc) { struct nvm_dev *dev = rrpc->dev; sector_t i; - u64 slba; int ret; - slba = rrpc->soffset >> (ilog2(dev->sec_size) - 9); - rrpc->trans_map = vzalloc(sizeof(struct rrpc_addr) * rrpc->nr_sects); if (!rrpc->trans_map) return -ENOMEM; @@ -1065,8 +1062,8 @@ static int rrpc_map_init(struct rrpc *rrpc) return 0; /* Bring up the mapping table from device */ - ret = dev->ops->get_l2p_tbl(dev, slba, rrpc->nr_sects, rrpc_l2p_update, - rrpc); + ret = dev->ops->get_l2p_tbl(dev, rrpc->soffset, rrpc->nr_sects, + rrpc_l2p_update, rrpc); if (ret) { pr_err("nvm: rrpc: could not read L2P table.\n"); return -EINVAL; @@ -1220,18 +1217,24 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin) struct nvm_dev *dev = rrpc->dev; struct nvmm_type *mt = dev->mt; sector_t size = rrpc->nr_sects * dev->sec_size; + int ret; size >>= 9; - return mt->get_area(dev, begin, size); + ret = mt->get_area(dev, begin, size); + if (!ret) + *begin >>= (ilog2(dev->sec_size) - 9); + + return ret; } static void rrpc_area_free(struct rrpc *rrpc) { struct nvm_dev *dev = rrpc->dev; struct nvmm_type *mt = dev->mt; + sector_t begin = rrpc->soffset << (ilog2(dev->sec_size) - 9); - mt->put_area(dev, rrpc->soffset); + mt->put_area(dev, begin); } static void rrpc_free(struct rrpc *rrpc)