diff mbox series

[focal:linux-azure,1/2] cifs: allow syscalls to be restarted in __smb_send_rqst()

Message ID 20210125175234.2963573-2-marcelo.cerri@canonical.com
State New
Headers show
Series LP:#1911438 - CIFS: Request for backport | expand

Commit Message

Marcelo Henrique Cerri Jan. 25, 2021, 5:52 p.m. UTC
From: Paulo Alcantara <pc@cjr.nz>

BugLink: https://bugs.launchpad.net/bugs/1911438

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 the kernel decide to whether or not restart the syscalls when
there is a signal pending in __smb_send_rqst() by returning
-ERESTARTSYS.  If it can't, it will return -EINTR anyway.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
CC: Stable <stable@vger.kernel.org>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 6988a619f5b79e4efadea6e19dcfe75fbcd350b5)
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 fs/cifs/transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index eafc49de4d7f..6d6de183915b 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -340,8 +340,8 @@  __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 		return -EAGAIN;
 
 	if (signal_pending(current)) {
-		cifs_dbg(FYI, "signal is pending before sending any data\n");
-		return -EINTR;
+		cifs_dbg(FYI, "signal pending before send request\n");
+		return -ERESTARTSYS;
 	}
 
 	/* cork the socket */