Skip to contentSkip to conversation

NVMe: Prevent bogus synchronous IO command timeouts.

PATCH New Jeffrey Lien 2 participants 5 messages Sep 29, 2015 – Oct 2, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NVMe: Prevent bogus synchronous IO command timeouts.

Attached the patch since I can't get it sent via send-email.

Jeff Lien

Jeff.Lien at hgst.com
507 322-2416/23-2416
3605 Hwy 52 N.
Rochester, MN 55901

HGST E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of HGST and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system. -------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-NVMe-Prevent-bogus-synchronous-IO-command-timeouts.patch
Type: application/octet-stream
Size: 4359 bytes
Desc: 0001-NVMe-Prevent-bogus-synchronous-IO-command-timeouts.patch
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20150929/f80a2d1c/attachment-0001.obj>

#1 lore raw

PATCH 1/1 NVMe: Prevent bogus synchronous IO command timeouts.

Quoted 1 line · Jeffrey Lien

Attached the patch since I can't get it sent via send-email.

If possible, you will want to remove the confidentiality disclaimer from emails to public lists.

On your patch, I think it will be very bad for performance. We can achieve the protection you're going for without spinlocks and use memory barriers instead. What do you think for the following?

---

drivers/block/nvme-core.c +4 -3
index 78e51c2..2d21827 100644
@@ -200,9 +200,10 @@ static int alloc_cmdid(struct nvme_queue *nvmeq, void *ctx,
  	} while (test_and_set_bit(cmdid, nvmeq->cmdid_data));
 
  	info[cmdid].fn = handler;
-	info[cmdid].ctx = ctx;
  	info[cmdid].timeout = jiffies + timeout;
  	info[cmdid].aborted = 0;
+	wmb();
+	info[cmdid].ctx = ctx;
  	return cmdid;
  }
 
@@ -1354,9 +1355,9 @@ static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
  			.status = cpu_to_le16(NVME_SC_ABORT_REQ << 1),
  		};
 
-		if (timeout && !time_after(now, info[cmdid].timeout))
+		if (info[cmdid].ctx == CMD_CTX_CANCELLED || info[cmdid].ctx == CMD_CTX_COMPLETED)
  			continue;
-		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
+		if (timeout && !time_after(now, info[cmdid].timeout))
  			continue;
  		if (timeout && info[cmdid].ctx == CMD_CTX_ASYNC)
  			continue;

--

#2 lore raw

PATCH 1/1 NVMe: Prevent bogus synchronous IO command timeouts.

Keith,
This looks like a much simpler fix with less impact on performance. I'll do some testing of it to verify it indeed resolves the problem we were seeing. I'll let you know how it goes in a day or 2. Thanks.

-----Original Message-----
From: Keith Busch [mailto:[email protected]]
Sent: Tuesday, September 29, 2015 3:03 PM
To: Jeffrey Lien <Jeff.Lien at hgst.com>
Cc: Busch, Keith <keith.busch at intel.com>; linux-nvme at lists.infradead.org
Subject: Re: [PATCH] NVMe: Prevent bogus synchronous IO command timeouts.

Quoted 1 line · Jeffrey Lien

Attached the patch since I can't get it sent via send-email.

If possible, you will want to remove the confidentiality disclaimer from emails to public lists.

On your patch, I think it will be very bad for performance. We can achieve the protection you're going for without spinlocks and use memory barriers instead. What do you think for the following?

---

drivers/block/nvme-core.c +5 -3
@@ -200,9 +200,10 @@ static int alloc_cmdid(struct nvme_queue *nvmeq, void *ctx,
  	} while (test_and_set_bit(cmdid, nvmeq->cmdid_data));
 
  	info[cmdid].fn = handler;
-	info[cmdid].ctx = ctx;
  	info[cmdid].timeout = jiffies + timeout;
  	info[cmdid].aborted = 0;
+	wmb();
+	info[cmdid].ctx = ctx;
  	return cmdid;
  }
 
@@ -1354,9 +1355,9 @@ static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
  			.status = cpu_to_le16(NVME_SC_ABORT_REQ << 1),
  		};
 
-		if (timeout && !time_after(now, info[cmdid].timeout))
+		if (info[cmdid].ctx == CMD_CTX_CANCELLED || info[cmdid].ctx == 
+CMD_CTX_COMPLETED)
  			continue;
-		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
+		if (timeout && !time_after(now, info[cmdid].timeout))
  			continue;
  		if (timeout && info[cmdid].ctx == CMD_CTX_ASYNC)

continue;
--
HGST E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of HGST and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.

#3 lore raw

PATCH 1/1 NVMe: Prevent bogus synchronous IO command timeouts.

Keith,
I wasn't able to recreate the original failure with your version of the fix so I'd say it's good to go. Are you going to push your modified fix into the legacy tree then?

-----Original Message-----
From: Linux-nvme [mailto:[email protected]] On Behalf Of Jeffrey Lien
Sent: Wednesday, September 30, 2015 9:46 AM
To: Keith Busch <keith.busch at intel.com>
Cc: linux-nvme at lists.infradead.org
Subject: RE: [PATCH] NVMe: Prevent bogus synchronous IO command timeouts.

Keith,
This looks like a much simpler fix with less impact on performance. I'll do some testing of it to verify it indeed resolves the problem we were seeing. I'll let you know how it goes in a day or 2. Thanks.

-----Original Message-----
From: Keith Busch [mailto:[email protected]]
Sent: Tuesday, September 29, 2015 3:03 PM
To: Jeffrey Lien <Jeff.Lien at hgst.com>
Cc: Busch, Keith <keith.busch at intel.com>; linux-nvme at lists.infradead.org
Subject: Re: [PATCH] NVMe: Prevent bogus synchronous IO command timeouts.

Quoted 1 line · Jeffrey Lien

Attached the patch since I can't get it sent via send-email.

If possible, you will want to remove the confidentiality disclaimer from emails to public lists.

On your patch, I think it will be very bad for performance. We can achieve the protection you're going for without spinlocks and use memory barriers instead. What do you think for the following?

---

drivers/block/nvme-core.c +5 -3
@@ -200,9 +200,10 @@ static int alloc_cmdid(struct nvme_queue *nvmeq, void *ctx,
  	} while (test_and_set_bit(cmdid, nvmeq->cmdid_data));
 
  	info[cmdid].fn = handler;
-	info[cmdid].ctx = ctx;
  	info[cmdid].timeout = jiffies + timeout;
  	info[cmdid].aborted = 0;
+	wmb();
+	info[cmdid].ctx = ctx;
  	return cmdid;
  }
 
@@ -1354,9 +1355,9 @@ static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
  			.status = cpu_to_le16(NVME_SC_ABORT_REQ << 1),
  		};
 
-		if (timeout && !time_after(now, info[cmdid].timeout))
+		if (info[cmdid].ctx == CMD_CTX_CANCELLED || info[cmdid].ctx == 
+CMD_CTX_COMPLETED)
  			continue;
-		if (info[cmdid].ctx == CMD_CTX_CANCELLED)
+		if (timeout && !time_after(now, info[cmdid].timeout))
  			continue;
  		if (timeout && info[cmdid].ctx == CMD_CTX_ASYNC)

continue;
--
HGST E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of HGST and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.

_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
HGST E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of HGST and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.

#4 lore raw

PATCH 1/1 NVMe: Prevent bogus synchronous IO command timeouts.

Quoted 2 lines · Jeffrey Lien

Keith,
I wasn't able to recreate the original failure with your version of the fix so I'd say it's good to go. Are you going to push your modified fix into the legacy tree then?

Great, thanks! Will apply to the legacy repo today.