From patchwork Wed Apr 13 08:27:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 8819451 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 AECBC9F36E for ; Wed, 13 Apr 2016 08:26:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C750320256 for ; Wed, 13 Apr 2016 08:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EECD32024F for ; Wed, 13 Apr 2016 08:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757709AbcDMI0M (ORCPT ); Wed, 13 Apr 2016 04:26:12 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33038 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757664AbcDMI0K (ORCPT ); Wed, 13 Apr 2016 04:26:10 -0400 Received: by mail-pa0-f68.google.com with SMTP id vv3so3305700pab.0; Wed, 13 Apr 2016 01:26:09 -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; bh=5U3JUYr04asHkuaFw+846cd43EJl3SfIfvdhoMM7yGY=; b=DvWmAj/tHI09z3O3yU32Nch8fD9y7EVNmQIKtX2BJMA/wd8TD4EgWM5UbhmdbOptJo locUOs8nzyXZwlURnJ9RgdeYGhtCrpbURVE33OV6FXIrdZm3I7PeUbnOIypRfG6yQan/ OIlSEbdfCSQ01nv4A1MKxJX+ytpuD7fGvVeYvZ0Mr1kGq5G+mLX3LfEs3NbiMnsb6amH yRcF4diOIs/OFwpZ6YIhEjQdnN0E4euTBDVN1We/24r7bx8GLYrzDofFSmbEWA7lfMSA +CaH4W6JqXVXMGOraufDHsS2pIr4JkXk2AilGqLuBt44U1QTgG0UB7jP98COikMIcc1Q bM3w== 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; bh=5U3JUYr04asHkuaFw+846cd43EJl3SfIfvdhoMM7yGY=; b=SwEmShOH6wWrOTwStSAHIckctTYcS2ZjR+ddBHl2chu4lBmb7U1dPHz6LXORM++0md 8Iz+f2TbGUXMtQEiXT48dX6iT6r0nsjcIhachKripTi2KqY/X+op3MtU0o5Qf3TdbK72 xQaMm5uCi2WlpZ52H26YnQ+7F8AYrYZybGFs2Z7GPoo+IRBWUlOkqIm35SmJiLoED6gu iU2FMflSjdQSUQunNmxMKWJ5juEiXAZkGkRushPrXLjHkMlZamenICJuVV+cAA9PnZn3 aIi/WBSpmc0jojeMP8jj+BKAL4q5GfOY96WWcxxs3QD5Jn6wp//xT2Hw+HwDhC0jSwup 2ifw== X-Gm-Message-State: AOPr4FVmrWHgahIGtJO3Oz0mXj8bRZ7j4/kS9xjuW127iaBHbBZPm61WY/4V236nInbZ/w== X-Received: by 10.66.193.131 with SMTP id ho3mr11030242pac.154.1460535969450; Wed, 13 Apr 2016 01:26:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Apr 2016 01:26:08 -0700 (PDT) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 1/3] lightnvm: calculate rrpc total blocks and sectors up front Date: Wed, 13 Apr 2016 16:27:50 +0800 Message-Id: <1460536072-1728-1-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 2.7.1.windows.2 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 Calculate rrpc total blocks and sectors up front, make sense to use them. For example, we use rrpc->nr_sects to calculate rrpc area size, but it makes no sense if we don't initialize it up front, since it would be zero until we finish rrpc luns init. Signed-off-by: Wenwei Tao --- drivers/lightnvm/rrpc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 3ab6495..c0e303c 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1207,10 +1207,6 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) INIT_WORK(&rlun->ws_gc, rrpc_lun_gc); spin_lock_init(&rlun->lock); - - rrpc->total_blocks += dev->blks_per_lun; - rrpc->nr_sects += dev->sec_per_lun; - } return 0; @@ -1388,6 +1384,8 @@ static void *rrpc_init(struct nvm_dev *dev, struct gendisk *tdisk, INIT_WORK(&rrpc->ws_requeue, rrpc_requeue); rrpc->nr_luns = lun_end - lun_begin + 1; + rrpc->total_blocks = (unsigned long)dev->blks_per_lun * rrpc->nr_luns; + rrpc->nr_sects = (unsigned long long)dev->sec_per_lun * rrpc->nr_luns; /* simple round-robin strategy */ atomic_set(&rrpc->next_lun, -1);