Skip to contentSkip to conversation

cifs: WARN_ON_ONCE if kernel_sendmsg() returns -ENOSPC

PATCH In review Suresh Jayaraman 2 participants 3 messages Oct 3, 2012 2 messages not in the archive

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

PATCH 1/1 cifs: WARN_ON_ONCE if kernel_sendmsg() returns -ENOSPC

kernel_sendmsg() is less likely to return -ENOSPC and it might be a bug to do so. However, in the past there might have been cases where a -ENOSPC was returned from a low level driver.

Add a WARN_ON_ONCE() to ensure that it is safe to assume that -ENOSPC is no longer returned. This -ENOSPC specific handling will be removed once we are sure it is no longer returned.

Also, avoid setting -ENOSPC to -EAGAIN while at it.

---
 fs/cifs/transport.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/cifs/transport.c +4 -1
index d9b639b..afe000f 100644
@@ -155,6 +155,10 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 		rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
 				    n_vec - first_vec, total_len);
 		if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
+			/*
+			 * Catch if a low level driver returns -ENOSPC.
+			 */
+			WARN_ON_ONCE(rc == -ENOSPC);
 			i++;
 			/*
 			 * If blocking send we try 3 times, since each can block
@@ -177,7 +181,6 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 			if ((i >= 14) || (!server->noblocksnd && (i > 2))) {
 				cERROR(1, "sends on sock %p stuck for 15 seconds",
 				    ssocket);
-				rc = -EAGAIN;
 				break;
 			}
 			msleep(1 << i);

A message that is not in the archive (sent off-list or not yet received): 506BE618.7050606-IBi9RG/[email protected]

#2 lore raw
Quoted 32 lines · On Wed, 03 Oct 2012 12:45:36 +0530 Suresh Jayaraman…

kernel_sendmsg() is less likely to return -ENOSPC and it might be a bug to do so. However, in the past there might have been cases where a -ENOSPC was returned from a low level driver.

Add a WARN_ON_ONCE() to ensure that it is safe to assume that -ENOSPC is no longer returned. This -ENOSPC specific handling will be removed once we are sure it is no longer returned.

Also, avoid setting -ENOSPC to -EAGAIN while at it.

---
 fs/cifs/transport.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/cifs/transport.c +4 -0
index d9b639b..afe000f 100644
@@ -155,6 +155,10 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 		rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
 				    n_vec - first_vec, total_len);
 		if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
+			/*
+			 * Catch if a low level driver returns -ENOSPC.
+			 */
+			WARN_ON_ONCE(rc == -ENOSPC);
 			i++;
 			/*
 			 * If blocking send we try 3 times, since each can block

fs/cifs/transport.c smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) · line 180

Quoted 4 lines
fs/cifs/transport.c +0 -1
@@ -177,7 +181,6 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 			if ((i >= 14) || (!server->noblocksnd && (i > 2))) {
 				cERROR(1, "sends on sock %p stuck for 15 seconds",
 				    ssocket);
-				rc = -EAGAIN;

Do you really want to remove this reset? This will change the behavior if the lower levels do indeed return -ENOSPC. That will now bubble back up to the upper levels and it will likely abort the call instead of retrying.

I think it would be best that we add the WARN_ON_ONCE but not change anything else. If no one reports seeing that warning fire for 2 or 3 releases then we can safely remove the -ENOSPC handling. Maybe shoot for that in 3.10 or so?

You may want to add a comment to remind us to revisit that for the 3.10 cycle.

Quoted 3 lines
fs/cifs/transport.c +0 -0
 				break;
 			}
 			msleep(1 << i);
Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20121003060410.07c30803-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#4 lore raw
Quoted 36 lines · Jeff Layton
Quoted 33 lines · On Wed, 03 Oct 2012 12:45:36 +0530 Suresh Jayaraman…

kernel_sendmsg() is less likely to return -ENOSPC and it might be a bug to do so. However, in the past there might have been cases where a -ENOSPC was returned from a low level driver.

Add a WARN_ON_ONCE() to ensure that it is safe to assume that -ENOSPC is no longer returned. This -ENOSPC specific handling will be removed once we are sure it is no longer returned.

Also, avoid setting -ENOSPC to -EAGAIN while at it.

---
 fs/cifs/transport.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/cifs/transport.c +4 -0
index d9b639b..afe000f 100644
@@ -155,6 +155,10 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 		rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
 				    n_vec - first_vec, total_len);
 		if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
+			/*
+			 * Catch if a low level driver returns -ENOSPC.
+			 */
+			WARN_ON_ONCE(rc == -ENOSPC);
 			i++;
 			/*
 			 * If blocking send we try 3 times, since each can block
@@ -177,7 +181,6 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
 			if ((i >= 14) || (!server->noblocksnd && (i > 2))) {
Quoted 8 lines

fs/cifs/transport.c smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) · line 180

Quoted 3 lines
fs/cifs/transport.c +0 -1
 				cERROR(1, "sends on sock %p stuck for 15 seconds",
 				    ssocket);
-				rc = -EAGAIN;

Do you really want to remove this reset? This will change the behavior if the lower levels do indeed return -ENOSPC. That will now bubble back up to the upper levels and it will likely abort the call instead of retrying.

Yes, you are correct. I'll remove it.

Quoted 9 lines

I think it would be best that we add the WARN_ON_ONCE but not change anything else. If no one reports seeing that warning fire for 2 or 3 releases then we can safely remove the -ENOSPC handling. Maybe shoot for that in 3.10 or so?

You may want to add a comment to remind us to revisit that for the 3.10 cycle.

Sure, I'll add that when I respin.

Thanks
Suresh