public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lightnvm: place unlock sentence in the common path
@ 2015-12-04 12:37 Wenwei Tao
  2015-12-04 12:50 ` Matias Bjørling
  0 siblings, 1 reply; 2+ messages in thread
From: Wenwei Tao @ 2015-12-04 12:37 UTC (permalink / raw)
  To: mb; +Cc: linux-kernel, linux-block

move spin_unlock(&vlun->lock) to common path to make
the code more clean.

Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
---
 drivers/lightnvm/gennvm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index 35dde84..ce60254 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -262,14 +262,11 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
 	if (list_empty(&lun->free_list)) {
 		pr_err_ratelimited("gennvm: lun %u have no free pages available",
 								lun->vlun.id);
-		spin_unlock(&vlun->lock);
 		goto out;
 	}
 
-	while (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) {
-		spin_unlock(&vlun->lock);
+	if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks)
 		goto out;
-	}
 
 	blk = list_first_entry(&lun->free_list, struct nvm_block, list);
 	list_move_tail(&blk->list, &lun->used_list);
@@ -278,8 +275,8 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
 	lun->vlun.nr_free_blocks--;
 	lun->vlun.nr_inuse_blocks++;
 
-	spin_unlock(&vlun->lock);
 out:
+	spin_unlock(&vlun->lock);
 	return blk;
 }
 
-- 
1.8.3.1


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

* Re: [PATCH] lightnvm: place unlock sentence in the common path
  2015-12-04 12:37 [PATCH] lightnvm: place unlock sentence in the common path Wenwei Tao
@ 2015-12-04 12:50 ` Matias Bjørling
  0 siblings, 0 replies; 2+ messages in thread
From: Matias Bjørling @ 2015-12-04 12:50 UTC (permalink / raw)
  To: Wenwei Tao; +Cc: linux-kernel, linux-block

On 12/04/2015 01:37 PM, Wenwei Tao wrote:
> move spin_unlock(&vlun->lock) to common path to make
> the code more clean.
>
> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
> ---
>   drivers/lightnvm/gennvm.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
> index 35dde84..ce60254 100644
> --- a/drivers/lightnvm/gennvm.c
> +++ b/drivers/lightnvm/gennvm.c
> @@ -262,14 +262,11 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
>   	if (list_empty(&lun->free_list)) {
>   		pr_err_ratelimited("gennvm: lun %u have no free pages available",
>   								lun->vlun.id);
> -		spin_unlock(&vlun->lock);
>   		goto out;
>   	}
>
> -	while (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) {
> -		spin_unlock(&vlun->lock);
> +	if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks)
>   		goto out;
> -	}
>
>   	blk = list_first_entry(&lun->free_list, struct nvm_block, list);
>   	list_move_tail(&blk->list, &lun->used_list);
> @@ -278,8 +275,8 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
>   	lun->vlun.nr_free_blocks--;
>   	lun->vlun.nr_inuse_blocks++;
>
> -	spin_unlock(&vlun->lock);
>   out:
> +	spin_unlock(&vlun->lock);
>   	return blk;
>   }
>
>

Thanks Tao, applied.

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

end of thread, other threads:[~2015-12-04 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 12:37 [PATCH] lightnvm: place unlock sentence in the common path Wenwei Tao
2015-12-04 12:50 ` Matias Bjørling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox