From patchwork Fri May 6 18:03:00 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: 9035051 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 135619F6CD for ; Fri, 6 May 2016 18:04:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 395B820398 for ; Fri, 6 May 2016 18:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F87620272 for ; Fri, 6 May 2016 18:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758725AbcEFSDo (ORCPT ); Fri, 6 May 2016 14:03:44 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:37082 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758693AbcEFSDl (ORCPT ); Fri, 6 May 2016 14:03:41 -0400 Received: by mail-wm0-f52.google.com with SMTP id a17so89983245wme.0 for ; Fri, 06 May 2016 11:03:40 -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=PBCAHuLiI6uv5mSyJ1B49GIg0dG5nEvWn/ZCoFizStA=; b=LqpjGkWka0avxOyi3WIO0Kbdvos9m1ABgsr+xXwsAh/AfZzOzn2dIFBsycsfecpDv3 BXsky6PYjMy7R/cjPKNzz7GIIgLCVCfzGhcBBnBJT1ISRZyWhZJmrrIg1ZaJq5CNVwee d2ptU7AhmjWhl1u+FDiVAp+RBatZ8B6y3Tn0I= 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=PBCAHuLiI6uv5mSyJ1B49GIg0dG5nEvWn/ZCoFizStA=; b=NW7RcClADhm9ACwNq7ZhgoK+sSbDKzs+tBP3k/Ike9AAXUupp/15CvP5xaGw7POJ+V a6XvmgvKnDal22hcQ5GUhPfarelNjVWj1SSruOmaUOe5lFDmoOdLXOO7yvAXeLbbiH5c cA5EfjhpKbI+6CcWPmrCOGV1sw7MiWPgOvv9vclGDBlsYMSuD+fGyiTudMXnpqU/3sQG XGBfpg4x1IWG+oab5HjmK9QRCN4qacFzbi1DLysR0Z0wWrhip3fmweeZcN3gpVPwm/AX wUqeCrXeddDjWk2coaZM7rv+2xUbv62Rl19sTJ+jwNBK4w/Nf4tGu/XfZzcYwO3Qjg1U aMNQ== X-Gm-Message-State: AOPr4FXiZ9xzh7428m15E99P9t6Y5ONfEyeDiWZtyK7Z4PDrtFy365EQTg2Xw3a3l8vyng== X-Received: by 10.194.173.42 with SMTP id bh10mr23775614wjc.150.1462557820047; Fri, 06 May 2016 11:03:40 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 May 2016 11:03:39 -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 07/28] lightnvm: calculate rrpc total blocks and sectors up front Date: Fri, 6 May 2016 20:03:00 +0200 Message-Id: <1462557801-24974-8-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=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 From: Wenwei Tao 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 Signed-off-by: Matias Bjørling --- 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);