diff mbox series

lightnvm: pblk: take write semaphore on metadata

Message ID 1533217674-9514-1-git-send-email-javier@cnexlabs.com (mailing list archive)
State New, archived
Headers show
Series lightnvm: pblk: take write semaphore on metadata | expand

Commit Message

Javier González Aug. 2, 2018, 1:47 p.m. UTC
Take the write semaphore on metadata I/Os too.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/pblk-core.c | 14 ++++++++++++--
 drivers/lightnvm/pblk.h      |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Jens Axboe Aug. 2, 2018, 3:57 p.m. UTC | #1
On 8/2/18 7:47 AM, Javier González wrote:
> Take the write semaphore on metadata I/Os too.

I'm going to nit pick a little bit here, but this isn't a good
changelog at all. A good changelog tells you _why_ a change is
made, not how it's made. Your commit message doesn't really tell
me anything that I can't easily glean from looking at the patch.

A good commit message would tell me _why_ we are now also
grabbing the write sem for metadata.
Javier Gonzalez Aug. 2, 2018, 4:01 p.m. UTC | #2
> On 2 Aug 2018, at 17.57, Jens Axboe <axboe@kernel.dk> wrote:
> 
>> On 8/2/18 7:47 AM, Javier González wrote:
>> Take the write semaphore on metadata I/Os too.
> 
> I'm going to nit pick a little bit here, but this isn't a good
> changelog at all. A good changelog tells you _why_ a change is
> made, not how it's made. Your commit message doesn't really tell
> me anything that I can't easily glean from looking at the patch.
> 
> A good commit message would tell me _why_ we are now also
> grabbing the write sem for metadata.
> 
> -- 
> Jens Axboe
> 

You’re right. I’ll fix the commit message and resend tomorrow. 

Javier
diff mbox series

Patch

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 72acf2f6dbd6..73edb2d8104f 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -493,6 +493,16 @@  int pblk_submit_io_sync(struct pblk *pblk, struct nvm_rq *rqd)
 	return nvm_submit_io_sync(dev, rqd);
 }
 
+int pblk_submit_io_sync_sem(struct pblk *pblk, struct nvm_rq *rqd)
+{
+	if (rqd->opcode != NVM_OP_PWRITE)
+		pblk_submit_io_sync(pblk, rqd);
+
+	pblk_down_page(pblk, rqd->ppa_list, rqd->nr_ppas);
+	pblk_submit_io_sync(pblk, rqd);
+	pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas);
+}
+
 static void pblk_bio_map_addr_endio(struct bio *bio)
 {
 	bio_put(bio);
@@ -735,7 +745,7 @@  static int pblk_line_submit_emeta_io(struct pblk *pblk, struct pblk_line *line,
 		}
 	}
 
-	ret = pblk_submit_io_sync(pblk, &rqd);
+	ret = pblk_submit_io_sync_sem(pblk, &rqd);
 	if (ret) {
 		pblk_err(pblk, "emeta I/O submission failed: %d\n", ret);
 		bio_put(bio);
@@ -837,7 +847,7 @@  static int pblk_line_submit_smeta_io(struct pblk *pblk, struct pblk_line *line,
 	 * the write thread is the only one sending write and erase commands,
 	 * there is no need to take the LUN semaphore.
 	 */
-	ret = pblk_submit_io_sync(pblk, &rqd);
+	ret = pblk_submit_io_sync_sem(pblk, &rqd);
 	if (ret) {
 		pblk_err(pblk, "smeta I/O submission failed: %d\n", ret);
 		bio_put(bio);
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 48b3035df3c4..81401dd88951 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -782,6 +782,7 @@  void pblk_log_write_err(struct pblk *pblk, struct nvm_rq *rqd);
 void pblk_log_read_err(struct pblk *pblk, struct nvm_rq *rqd);
 int pblk_submit_io(struct pblk *pblk, struct nvm_rq *rqd);
 int pblk_submit_io_sync(struct pblk *pblk, struct nvm_rq *rqd);
+int pblk_submit_io_sync_sem(struct pblk *pblk, struct nvm_rq *rqd);
 int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line);
 struct bio *pblk_bio_map_addr(struct pblk *pblk, void *data,
 			      unsigned int nr_secs, unsigned int len,