Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751416AbcDPODF (ORCPT ); Sat, 16 Apr 2016 10:03:05 -0400 Received: from mail-qk0-f180.google.com ([209.85.220.180]:32816 "EHLO mail-qk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbcDPODE (ORCPT ); Sat, 16 Apr 2016 10:03:04 -0400 Subject: Re: [PATCH 2/3] lightnvm: store rrpc soffset in device sector size instead of 512 To: Wenwei Tao References: <1460536072-1728-1-git-send-email-ww.tao0320@gmail.com> <1460536072-1728-2-git-send-email-ww.tao0320@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: <57124602.9000307@lightnvm.io> Date: Sat, 16 Apr 2016 16:02:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1460536072-1728-2-git-send-email-ww.tao0320@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2036 Lines: 66 On 04/13/2016 10:27 AM, Wenwei Tao wrote: > 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) > Thanks. Applied for 4.7.