Skip to content

Commit f0899d0

Browse files
germanopgregkh
authored andcommitted
CIFS: store results of cifs_reopen_file to avoid infinite wait
commit 1fa839b4986d648b907d117275869a0e46c324b9 upstream. 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: Germano Percossi <germano.percossi@citrix.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> Signed-off-by: Steve French <smfrench@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a11ab9d commit f0899d0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

fs/cifs/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
25452545
wdata->credits = credits;
25462546

25472547
if (!wdata->cfile->invalidHandle ||
2548-
!cifs_reopen_file(wdata->cfile, false))
2548+
!(rc = cifs_reopen_file(wdata->cfile, false)))
25492549
rc = server->ops->async_writev(wdata,
25502550
cifs_uncached_writedata_release);
25512551
if (rc) {
@@ -2958,7 +2958,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
29582958
rdata->credits = credits;
29592959

29602960
if (!rdata->cfile->invalidHandle ||
2961-
!cifs_reopen_file(rdata->cfile, true))
2961+
!(rc = cifs_reopen_file(rdata->cfile, true)))
29622962
rc = server->ops->async_readv(rdata);
29632963
error:
29642964
if (rc) {
@@ -3544,7 +3544,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
35443544
}
35453545

35463546
if (!rdata->cfile->invalidHandle ||
3547-
!cifs_reopen_file(rdata->cfile, true))
3547+
!(rc = cifs_reopen_file(rdata->cfile, true)))
35483548
rc = server->ops->async_readv(rdata);
35493549
if (rc) {
35503550
add_credits_and_wake_if(server, rdata->credits, 0);

0 commit comments

Comments
 (0)