Commit 113cc52c authored by Germano Percossi's avatar Germano Percossi Committed by Sasha Levin

CIFS: store results of cifs_reopen_file to avoid infinite wait

[ Upstream commit 1fa839b4 ]

This fixes Continuous Availability when errors during
file reopen are encountered.

cifs_user_readv and cifs_user_writev would wait for ever if
results of cifs_reopen_file are not stored and for later inspection.

In fact, results are checked and, in case of errors, a chain
of function calls leading to reads and writes to be scheduled in
a separate thread is skipped.
These threads will wake up the corresponding waiters once reads
and writes are done.

However, given the return value is not stored, when rc is checked
for errors a previous one (always zero) is inspected instead.
This leads to pending reads/writes added to the list, making
cifs_user_readv and cifs_user_writev wait for ever.
Signed-off-by: default avatarGermano Percossi <germano.percossi@citrix.com>
Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
CC: Stable <stable@vger.kernel.org>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent 5c6d0e84
...@@ -2535,7 +2535,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, ...@@ -2535,7 +2535,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
wdata->credits = credits; wdata->credits = credits;
if (!wdata->cfile->invalidHandle || if (!wdata->cfile->invalidHandle ||
!cifs_reopen_file(wdata->cfile, false)) !(rc = cifs_reopen_file(wdata->cfile, false)))
rc = server->ops->async_writev(wdata, rc = server->ops->async_writev(wdata,
cifs_uncached_writedata_release); cifs_uncached_writedata_release);
if (rc) { if (rc) {
...@@ -2948,7 +2948,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, ...@@ -2948,7 +2948,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
rdata->credits = credits; rdata->credits = credits;
if (!rdata->cfile->invalidHandle || if (!rdata->cfile->invalidHandle ||
!cifs_reopen_file(rdata->cfile, true)) !(rc = cifs_reopen_file(rdata->cfile, true)))
rc = server->ops->async_readv(rdata); rc = server->ops->async_readv(rdata);
error: error:
if (rc) { if (rc) {
...@@ -3534,7 +3534,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -3534,7 +3534,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
} }
if (!rdata->cfile->invalidHandle || if (!rdata->cfile->invalidHandle ||
!cifs_reopen_file(rdata->cfile, true)) !(rc = cifs_reopen_file(rdata->cfile, true)))
rc = server->ops->async_readv(rdata); rc = server->ops->async_readv(rdata);
if (rc) { if (rc) {
add_credits_and_wake_if(server, rdata->credits, 0); add_credits_and_wake_if(server, rdata->credits, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment