From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752450AbcAELqn (ORCPT ); Tue, 5 Jan 2016 06:46:43 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37443 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbcAELqj (ORCPT ); Tue, 5 Jan 2016 06:46:39 -0500 Subject: Re: [PATCH] lightnvm: move the pages per block check out of the loop To: Wenwei Tao References: <1451994218-5871-1-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: <568BAD1D.3090306@lightnvm.io> Date: Tue, 5 Jan 2016 12:46:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1451994218-5871-1-git-send-email-ww.tao0320@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/05/2016 12:43 PM, Wenwei Tao wrote: > 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; > Thanks. Leftover from when luns could have different number of pages. Applied for 4.5.