Skip to contentSkip to conversation

lightnvm: place unlock sentence in the common path

PATCH In review Wenwei Tao 2 participants 2 messages Dec 4, 2015

lore
Share & tools
lore

Wenwei Tao

author
#0 lore raw

PATCH 1/1 lightnvm: place unlock sentence in the common path

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

---
 drivers/lightnvm/gennvm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/lightnvm/gennvm.c +2 -5
index 35dde84..ce60254 100644
@@ -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;
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 30 lines · Wenwei Tao

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

---
  drivers/lightnvm/gennvm.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
drivers/lightnvm/gennvm.c +1 -4
index 35dde84..ce60254 100644
@@ -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);

drivers/lightnvm/gennvm.c static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev, · line 282

Quoted 9 lines
drivers/lightnvm/gennvm.c +1 -1
@@ -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.