From patchwork Tue Jan 5 11:43:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 7954161 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 3C318BEEE5 for ; Tue, 5 Jan 2016 11:44:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70DDE203AC for ; Tue, 5 Jan 2016 11:44:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87D462039E for ; Tue, 5 Jan 2016 11:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751614AbcAELoD (ORCPT ); Tue, 5 Jan 2016 06:44:03 -0500 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35369 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751188AbcAELoC (ORCPT ); Tue, 5 Jan 2016 06:44:02 -0500 Received: by mail-pf0-f174.google.com with SMTP id 78so221726795pfw.2; Tue, 05 Jan 2016 03:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0HzSHYEWsG1MgYWRavvKXNgT7F4LbaUWXHLG7z9laqg=; b=IGdAoWnM/6oW5aHxQnV+PSvLyOmoHrTL9DnkUPxSESHxkjlI8pXEAxbWLF5Q2BvV+k b/f59vlNYeZEYMHjhG9njvNVIkJhYvjTmrQ4S0L5txtXRomu0HcmyTfweIp4jTF7s2Qj FOEspNbmBMGR0wK0Ng9d9SFcIQdWJOWiOr0P/RJG9gDawVfTbk3qZ1uK8saL4nEzLZKn DVYpbdwlzkijPpfhyTtUxy3sXsYxjOTHQmp3h80niQgifgQ5N7kjus3okq48FFlC9MaB UUGdCAOCanwLtp1awEBVA/xj/yOr5kIlHZXQRcgPdQsdgIzQeFucLm787AU6ZsoDH0dB O3GA== X-Received: by 10.98.74.220 with SMTP id c89mr133863805pfj.11.1451994241567; Tue, 05 Jan 2016 03:44:01 -0800 (PST) Received: from localhost.localdomain.com ([111.204.49.2]) by smtp.gmail.com with ESMTPSA id p86sm89168225pfa.63.2016.01.05.03.43.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2016 03:44:01 -0800 (PST) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] lightnvm: move the pages per block check out of the loop Date: Tue, 5 Jan 2016 19:43:38 +0800 Message-Id: <1451994218-5871-1-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 1.8.3.1 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_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 There is no need to check whether dev's pages per block is beyond rrpc support everytime we init a lun, we only need to check it once before enter the lun init loop. Signed-off-by: Wenwei Tao --- 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 27fb98d..286a038 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1087,6 +1087,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), @@ -1098,12 +1103,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;