From patchwork Tue Jan 12 06:49:27 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: 8013851 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6D575BEEE5 for ; Tue, 12 Jan 2016 06:51:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E83220386 for ; Tue, 12 Jan 2016 06:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F4CC20114 for ; Tue, 12 Jan 2016 06:51:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761493AbcALGvR (ORCPT ); Tue, 12 Jan 2016 01:51:17 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38604 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761065AbcALGuL (ORCPT ); Tue, 12 Jan 2016 01:50:11 -0500 Received: by mail-wm0-f54.google.com with SMTP id b14so303595594wmb.1 for ; Mon, 11 Jan 2016 22:50:10 -0800 (PST) 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-type:content-transfer-encoding; bh=pV/xvki6Wk5XRI1EvmZk0HjECtmm5B/pLw7ta2eCVJw=; b=HfFfNLp1IEDz8vGvz6ugrBRI/V0buiWVawwMN+nwPjFoyKq8llzPRDO21gqs109IXD MNAzRBCS0FJ8Hp1sci61eoCtTprKW4+aLL2U3NmKXxmmnJLOvQ3chpfrKolA6i7wV9dL odEsxceYuDdJyiBZv3b71zC6Amd1rZ7SI49kY= 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-type:content-transfer-encoding; bh=pV/xvki6Wk5XRI1EvmZk0HjECtmm5B/pLw7ta2eCVJw=; b=k24E2QVDFzEL95WBsaSiTERkbbHV7Mofw32JVFwV7LdPu+elwuGoPOOkQ87ZmxmwXK u5Yyz4dzHnA+8IX/Aw9wAbJwBkvsNB0Ni7Go7mSIyqBDxq/gWLJ8Q7eJv3ndDbHyZm8T dcoK09drzJyR1XqRMjYudof7Yl5Hyg6PF8d+UZkkLFOiCang4nNtnQAY5t3B0aAzuG5a +NQ9I3NkiP0OY39zkZt5sQyh8iyGEVCDnL4VxhgxxxrUaFq/wMXbemJKbEAYnyYHBkGk pimg293sRmaEny82wnZuXYf19R8MpsTPevX8v8ptmATK1Ze7ltmDb6I3P8XTr+FlNXKQ yWLg== X-Gm-Message-State: ALoCoQlTr/9DF2ibYameOYX8SxtfSO6778ccsM/8X1VndzmsVwTQqX8Ow9jfJeF1gPwGN7oPzzjwrrD3tPLgLnml95sJ2qKJ/w== X-Received: by 10.28.0.79 with SMTP id 76mr18951914wma.27.1452581410043; Mon, 11 Jan 2016 22:50:10 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id yz5sm70776886wjc.36.2016.01.11.22.50.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 22:50:08 -0800 (PST) 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 13/25] lightnvm: move the pages per block check out of the loop Date: Tue, 12 Jan 2016 07:49:27 +0100 Message-Id: <1452581379-18162-14-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452581379-18162-1-git-send-email-m@bjorling.me> References: <1452581379-18162-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=-6.8 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 There is no need to check whether dev's pages per block is beyond rrpc support every time we init a lun, we only need to check it once before enter the lun init loop. Signed-off-by: Wenwei Tao Signed-off-by: Matias Bjørling --- drivers/lightnvm/rrpc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 745acd9..ec7aacf 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1114,6 +1114,11 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) struct rrpc_lun *rlun; int i, j; + if (dev->pgs_per_blk > MAX_INVALID_PAGES_STORAGE * BITS_PER_LONG) { + pr_err("rrpc: number of pages per block too high."); + return -EINVAL; + } + spin_lock_init(&rrpc->rev_lock); rrpc->luns = kcalloc(rrpc->nr_luns, sizeof(struct rrpc_lun), @@ -1125,12 +1130,6 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) for (i = 0; i < rrpc->nr_luns; i++) { struct nvm_lun *lun = dev->mt->get_lun(dev, lun_begin + i); - if (dev->pgs_per_blk > - MAX_INVALID_PAGES_STORAGE * BITS_PER_LONG) { - pr_err("rrpc: number of pages per block too high."); - goto err; - } - rlun = &rrpc->luns[i]; rlun->rrpc = rrpc; rlun->parent = lun;