Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1283788 > unrolled thread

[PATCH] lightnvm: place unlock sentence in the common path

Started byWenwei Tao <ww.tao0320@gmail.com>
First post2015-12-04 13:50 +0100
Last post2015-12-04 14:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] lightnvm: place unlock sentence in the common path Wenwei Tao <ww.tao0320@gmail.com> - 2015-12-04 13:50 +0100
    Re: [PATCH] lightnvm: place unlock sentence in the common path Matias Bjørling <mb@lightnvm.io> - 2015-12-04 14:00 +0100

#1283788 — [PATCH] lightnvm: place unlock sentence in the common path

FromWenwei Tao <ww.tao0320@gmail.com>
Date2015-12-04 13:50 +0100
Subject[PATCH] lightnvm: place unlock sentence in the common path
Message-ID<qBXYe-2HT-11@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1283795

FromMatias Bjørling <mb@lightnvm.io>
Date2015-12-04 14:00 +0100
Message-ID<qBY7U-2M0-11@gated-at.bofh.it>
In reply to#1283788
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web