Skip to contentSkip to conversation

cifs: allow syscalls to be restarted in __smb_send_rqst()

PATCH In review Paulo Alcantara 4 participants 7 messages Nov 28, 2020 – Nov 30, 2020 1 message not in the archive

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

PATCH 1/1 cifs: allow syscalls to be restarted in __smb_send_rqst()

A customer has reported that several files in their multi-threaded app were left with size of 0 because most of the read(2) calls returned -EINTR and they assumed no bytes were read. Obviously, they could have fixed it by simply retrying on -EINTR.

We noticed that most of the -EINTR on read(2) were due to real-time signals sent by glibc to process wide credential changes (SIGRT_1), and its signal handler had been established with SA_RESTART, in which case those calls could have been automatically restarted by the kernel.

Let me the kernel decide to whether or not restart the syscalls when there is a signal pending in __smb_send_rqst() by returing -ERESTARTSYS. If it can't, it will return -EINTR anyway.

---
 fs/cifs/transport.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/cifs/transport.c +2 -4
index e27e255d40dd..55853b9ed13d 100644
@@ -338,10 +338,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 	if (ssocket == NULL)
 		return -EAGAIN;
 
-	if (signal_pending(current)) {
-		cifs_dbg(FYI, "signal is pending before sending any data\n");
-		return -EINTR;
-	}
+	if (signal_pending(current))
+		return -ERESTARTSYS;
 
 	/* cork the socket */
 	tcp_sock_set_cork(ssocket->sk, true);
Signature · 1 line
2.29.2

A message that is not in the archive (sent off-list or not yet received): CAH2r5msFYUB7RmWjCxQH8s8Amz4eET8_u8V5qZq3KMhdRFDPrA@mail.gmail.com

#2 lore raw
Quoted 1 line · Steve French

Did it fix the customer application?

Yes, it did.

Quoted 1 line

Thoughts on cc:stable?

Looks like a great candidate, yes.

#3 lore raw
In reply to Paulo Alcantara
Quoted 5 lines · Paulo Alcantara
fs/cifs/transport.c +0 -0
index e27e255d40dd..55853b9ed13d 100644

fs/cifs/transport.c __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, · line 342

Quoted 9 lines
fs/cifs/transport.c +2 -4
@@ -338,10 +338,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 	if (ssocket == NULL)
 		return -EAGAIN;
 
-	if (signal_pending(current)) {
-		cifs_dbg(FYI, "signal is pending before sending any data\n");
-		return -EINTR;
-	}
+	if (signal_pending(current))
+		return -ERESTARTSYS;

Can we keep the debug message call?

Cheers,

Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
#4 lore raw
Quoted 9 lines · Aurélien Aptel
Quoted 8 lines · Paulo Alcantara
fs/cifs/transport.c +0 -0
index e27e255d40dd..55853b9ed13d 100644
@@ -338,10 +338,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 	if (ssocket == NULL)
 		return -EAGAIN;
 
Quoted 8 lines

fs/cifs/transport.c __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, · line 342

Quoted 6 lines
fs/cifs/transport.c +2 -4
-	if (signal_pending(current)) {
-		cifs_dbg(FYI, "signal is pending before sending any data\n");
-		return -EINTR;
-	}
+	if (signal_pending(current))
+		return -ERESTARTSYS;

Can we keep the debug message call?

Yes.

Steve, could you please update for-next with above debug msg?

#5 lore raw
Quoted 21 lines · Paulo Alcantara
Quoted 9 lines · Aurélien Aptel
Quoted 8 lines · Paulo Alcantara
fs/cifs/transport.c +0 -0
index e27e255d40dd..55853b9ed13d 100644
@@ -338,10 +338,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
     if (ssocket == NULL)
             return -EAGAIN;
 
Quoted 8 lines

fs/cifs/transport.c __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, · line 342

Quoted 6 lines
fs/cifs/transport.c +2 -4
-    if (signal_pending(current)) {
-            cifs_dbg(FYI, "signal is pending before sending any data\n");
-            return -EINTR;
-    }
+    if (signal_pending(current))
+            return -ERESTARTSYS;

Can we keep the debug message call?

Quoted 3 lines

Yes.

Steve, could you please update for-next with above debug msg?

Done. Please check to see if my lightly modified debug message text is ok.

Signature · 3 lines
Thanks,

Steve
#6 lore raw
Quoted 22 lines · Steve French
Quoted 21 lines · Paulo Alcantara
Quoted 17 lines · Aurélien Aptel
Quoted 5 lines · Paulo Alcantara
fs/cifs/transport.c +0 -0
index e27e255d40dd..55853b9ed13d 100644

fs/cifs/transport.c __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, · line 342

Quoted 9 lines
fs/cifs/transport.c +2 -4
@@ -338,10 +338,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
     if (ssocket == NULL)
             return -EAGAIN;
 
-    if (signal_pending(current)) {
-            cifs_dbg(FYI, "signal is pending before sending any data\n");
-            return -EINTR;
-    }
+    if (signal_pending(current))
+            return -ERESTARTSYS;

Can we keep the debug message call?

Quoted 5 lines
Quoted 3 lines

Yes.

Steve, could you please update for-next with above debug msg?

Done. Please check to see if my lightly modified debug message text is ok.

OK for me. Thanks!

Reviewed-by
#7 lore raw

Agree with the patch. The original change was inspired by the existing code returning -EINTR potentially after partially sending an SMB packet. Returning -ERESTARTSYS seems like a right thing to do here.

--
Best regards,
Pavel Shilovsky

пн, 30 нояб. 2020 г. в 08:35, Paulo Alcantara <[email protected]>:

Quoted 32 lines
Quoted 22 lines · Steve French
Quoted 21 lines · Paulo Alcantara
Quoted 17 lines · Aurélien Aptel
Quoted 5 lines · Paulo Alcantara
fs/cifs/transport.c +0 -0
index e27e255d40dd..55853b9ed13d 100644

fs/cifs/transport.c __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, · line 342

Quoted 9 lines
fs/cifs/transport.c +2 -4
@@ -338,10 +338,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
     if (ssocket == NULL)
             return -EAGAIN;
 
-    if (signal_pending(current)) {
-            cifs_dbg(FYI, "signal is pending before sending any data\n");
-            return -EINTR;
-    }
+    if (signal_pending(current))
+            return -ERESTARTSYS;

Can we keep the debug message call?

Quoted 5 lines
Quoted 3 lines

Yes.

Steve, could you please update for-next with above debug msg?

Done. Please check to see if my lightly modified debug message text is ok.

OK for me. Thanks!