From: Hua Su <suhua.tanke@gmail.com>
To: mb@lightnvm.io
Cc: javier@cnexlabs.com, axboe@kernel.dk,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
suhua.tanke@gmail.com
Subject: [PATCH] lightnvm: pblk: adjust the position of the lock
Date: Tue, 27 Nov 2018 09:53:09 +0800 [thread overview]
Message-ID: <20181127015309.2374-1-suhua.tanke@gmail.com> (raw)
Add lock protection for list operations.
Signed-off-by: Hua Su <suhua.tanke@gmail.com>
---
drivers/lightnvm/pblk-core.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 6944aac43b01..e490df217dac 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1286,24 +1286,27 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line)
list_del(&line->list);
ret = pblk_line_prepare(pblk, line);
- if (ret) {
- list_add(&line->list, &l_mg->free_list);
- spin_unlock(&l_mg->free_lock);
- return ret;
- }
- spin_unlock(&l_mg->free_lock);
+ if (ret)
+ goto out;
ret = pblk_line_alloc_bitmaps(pblk, line);
if (ret)
- return ret;
+ goto out;
if (!pblk_line_init_bb(pblk, line, 0)) {
list_add(&line->list, &l_mg->free_list);
+ spin_unlock(&l_mg->free_lock);
return -EINTR;
}
+ spin_unlock(&l_mg->free_lock);
pblk_rl_free_lines_dec(&pblk->rl, line, true);
return 0;
+
+out:
+ list_add(&line->list, &l_mg->free_list);
+ spin_unlock(&l_mg->free_lock);
+ return ret;
}
void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line)
--
2.19.1
next reply other threads:[~2018-11-27 1:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 1:53 Hua Su [this message]
2018-11-27 12:57 ` Javier Gonzalez
2018-11-27 14:22 ` Matias Bjørling
2018-11-27 14:24 ` Javier Gonzalez
2018-11-27 14:26 ` Matias Bjørling
[not found] ` <633950CD-FBB6-4228-BB8C-8FD946FB3286@gmail.com>
2018-11-28 7:58 ` Javier Gonzalez
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=20181127015309.2374-1-suhua.tanke@gmail.com \
--to=suhua.tanke@gmail.com \
--cc=axboe@kernel.dk \
--cc=javier@cnexlabs.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®