All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com
Cc: "Wenwei Tao" <ww.tao0320@gmail.com>, "Matias Bjørling" <m@bjorling.me>
Subject: [PATCH 3/9] lightnvm: refactor spin_unlock in gennvm_get_blk
Date: Sun,  6 Dec 2015 11:25:45 +0100	[thread overview]
Message-ID: <1449397551-16525-4-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1449397551-16525-1-git-send-email-m@bjorling.me>

From: Wenwei Tao <ww.tao0320@gmail.com>

The spin_unlock is duplicated multiple times. Jump to a single unlock
to improve the code flow.

Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 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;
 }
 
-- 
2.1.4


  parent reply	other threads:[~2015-12-06 10:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-06 10:25 [PATCH 0/9] Fixes for LightNVM Matias Bjørling
2015-12-06 10:25 ` [PATCH 1/9] lightnvm: use flags in rrpc_get_blk Matias Bjørling
2015-12-06 10:25 ` [PATCH 2/9] lightnvm: put blks when luns configure failed Matias Bjørling
2015-12-06 10:25 ` Matias Bjørling [this message]
2015-12-06 10:25 ` [PATCH 4/9] lightnvm: check mm before use Matias Bjørling
2015-12-06 10:25 ` [PATCH 5/9] lightnvm: comments on constants Matias Bjørling
2015-12-06 10:25 ` [PATCH 6/9] lightnvm: replace req queue with nvmdev for lld Matias Bjørling
2015-12-06 10:25 ` [PATCH 7/9] lightnvm: fix media mgr registration Matias Bjørling
2015-12-06 10:25 ` [PATCH 8/9] lightnvm: prevent gennvm module unload on use Matias Bjørling
2015-12-06 10:25 ` [PATCH 9/9] lightnvm: do not compile in debugging by default Matias Bjørling
2015-12-07 16:11 ` [PATCH 0/9] Fixes for LightNVM Jens Axboe
2015-12-07 17:52   ` Matias Bjørling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449397551-16525-4-git-send-email-m@bjorling.me \
    --to=m@bjorling.me \
    --cc=axboe@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ww.tao0320@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.