All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] nvmet: synchronize sqhd update
@ 2017-10-18 16:52 James Smart
  2017-10-19  8:00 ` Johannes Thumshirn
  0 siblings, 1 reply; 2+ messages in thread
From: James Smart @ 2017-10-18 16:52 UTC (permalink / raw)


In testing target io in read write mix, we did indeed get into cases
where sqhd didn't update properly and slowly missed enough updates to
shutdown the queue.

Protect the updating sqhd by using cmpxchg

Signed-off-by: James Smart <james.smart at broadcom.com>

---
v2: move locks so around update and assignment
v3: convert to cmpxchg
---
 drivers/nvme/target/core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index cfc35cbb6fe2..72d02f871c03 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -387,11 +387,18 @@ struct nvmet_ns *nvmet_ns_alloc(struct nvmet_subsys *subsys, u32 nsid)
 
 static void __nvmet_req_complete(struct nvmet_req *req, u16 status)
 {
+	u16 old_sqhd, new_sqhd;
+
 	if (status)
 		nvmet_set_status(req, status);
 
-	if (req->sq->size)
-		req->sq->sqhd = (req->sq->sqhd + 1) % req->sq->size;
+	if (req->sq->size) {
+		do {
+			old_sqhd = req->sq->sqhd;
+			new_sqhd = (old_sqhd + 1) % req->sq->size;
+		} while (cmpxchg(&req->sq->sqhd, old_sqhd, new_sqhd) !=
+					old_sqhd);
+	}
 	req->rsp->sq_head = cpu_to_le16(req->sq->sqhd);
 	req->rsp->sq_id = cpu_to_le16(req->sq->qid);
 	req->rsp->command_id = req->cmd->common.command_id;
-- 
2.13.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v3] nvmet: synchronize sqhd update
  2017-10-18 16:52 [PATCH v3] nvmet: synchronize sqhd update James Smart
@ 2017-10-19  8:00 ` Johannes Thumshirn
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Thumshirn @ 2017-10-19  8:00 UTC (permalink / raw)


Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-19  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-18 16:52 [PATCH v3] nvmet: synchronize sqhd update James Smart
2017-10-19  8:00 ` Johannes Thumshirn

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.