Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbcDPN3F (ORCPT ); Sat, 16 Apr 2016 09:29:05 -0400 Received: from mail-qk0-f169.google.com ([209.85.220.169]:33335 "EHLO mail-qk0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbcDPN3D (ORCPT ); Sat, 16 Apr 2016 09:29:03 -0400 Subject: Re: [PATCH 1/3] lightnvm: calculate rrpc total blocks and sectors up front To: Wenwei Tao References: <1460536072-1728-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: <57123DFC.7060807@lightnvm.io> Date: Sat, 16 Apr 2016 15:28:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1460536072-1728-1-git-send-email-ww.tao0320@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1365 Lines: 38 On 04/13/2016 10:27 AM, Wenwei Tao wrote: > 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); > Thanks Wenwei. Applied for 4.7.