All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lightnvm: move the pages per block check out of the loop
@ 2016-01-05 11:43 Wenwei Tao
  2016-01-05 11:46 ` Matias Bjørling
  0 siblings, 1 reply; 2+ messages in thread
From: Wenwei Tao @ 2016-01-05 11:43 UTC (permalink / raw)
  To: mb; +Cc: linux-kernel, linux-block

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 <ww.tao0320@gmail.com>
---
 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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lightnvm: move the pages per block check out of the loop
  2016-01-05 11:43 [PATCH] lightnvm: move the pages per block check out of the loop Wenwei Tao
@ 2016-01-05 11:46 ` Matias Bjørling
  0 siblings, 0 replies; 2+ messages in thread
From: Matias Bjørling @ 2016-01-05 11:46 UTC (permalink / raw)
  To: Wenwei Tao; +Cc: linux-kernel, linux-block

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 <ww.tao0320@gmail.com>
> ---
>   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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-05 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-05 11:43 [PATCH] lightnvm: move the pages per block check out of the loop Wenwei Tao
2016-01-05 11:46 ` Matias Bjørling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.