From patchwork Fri May 6 18:03:01 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: 9035041 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 480859F1D3 for ; Fri, 6 May 2016 18:04:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E86D2026F for ; Fri, 6 May 2016 18:04:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6245B2035B for ; Fri, 6 May 2016 18:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758719AbcEFSDn (ORCPT ); Fri, 6 May 2016 14:03:43 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38286 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758714AbcEFSDm (ORCPT ); Fri, 6 May 2016 14:03:42 -0400 Received: by mail-wm0-f54.google.com with SMTP id g17so89891599wme.1 for ; Fri, 06 May 2016 11:03:41 -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=Wzdqb/sU7Kb0PKoCajWquTWyJ7/knKVht0tRBjW2Bt0=; b=L+M9P11gWNQ7IEt5h0y42U+qKLb+SBsU16jnmQCH8wgDPnnnfEZVUEQb6HYm1fUgDb 4jg7nn8AMwK8pOZIa7B1w6hc9qDYY2yLPHgMLbQiX17XW2Bl24S8BrF8wFR5HEDgVVQ0 d5bSo0ESi0IR/rJFKUCyBv4NHyOfCI41Z49BI= 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=Wzdqb/sU7Kb0PKoCajWquTWyJ7/knKVht0tRBjW2Bt0=; b=X5+fxplTBZlgAP5Y+8sWJm3D2buCwcZUUdGWEPMGU4flI9gVP8WFFk44yd6IRODyw7 /AASIrhm/ThxRTCJRV32st7D2cCWQvUt4KEfktPUaaertKJsrunXRBjDthi2NMvREXl4 BbvJyExodg+wVN5fCN+7cqB4+RFJeReH+hmo6TbZO4BF045eoH2WAL5oWwKDIxLfphAV V/8DK4gORcUWpK6UziH8CxDKEYrBcp6c82iaj7EfwVaWGUoZGBV53jtzTJvXFEGGeWhm 4MY8hblsve9BDz8jfgj0p9cPpzDTNruo/c61BkVw2YuKb1kthJpXSMivq9gxBF78TVYU C3jw== X-Gm-Message-State: AOPr4FWlS9WZUuytZOw1DGrP43iDNQv+LCdAIdgKwfohxt+8EfxnSbRiUeDXrizxc4yHUA== X-Received: by 10.194.153.65 with SMTP id ve1mr16703003wjb.106.1462557821024; Fri, 06 May 2016 11:03:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 May 2016 11:03:40 -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: Wenwei Tao , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 08/28] lightnvm: store rrpc->soffset in device sector size Date: Fri, 6 May 2016 20:03:01 +0200 Message-Id: <1462557801-24974-9-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 From: Wenwei Tao Since we mainly use soffset in device sector size, we therefore store this value in rrpc->soffset, instead of the offset in 512byte sector size. This eliminates the "(ilog2(dev->sec_size) - 9)" calculation on each I/O. Signed-off-by: Wenwei Tao Updated patch description. Signed-off-by: Matias Bjørling --- 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)