Skip to content

cifs: don't fail writepages on -EAGAIN errors (try #2)

Jeff Layton linux-cifs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 32 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13cifs: don't fail writepages on -EAGAIN errorsfs/cifs/file.c+11 -127 replies
2/13cifs: make wait_for_free_request take a TCP_Server_Info pointerfs/cifs/transport.c+13 -131 reply
3/13cifs: move mid result processing into common functionfs/cifs/transport.c+47 -843 replies
4/13cifs: wait indefinitely for responsesfs/cifs/transport.c+17 -931 reply
5/13cifs: don't reconnect server when we don't get a responsefs/cifs/transport.c+1 -31 reply
6/13cifs: clean up handle_mid_responsefs/cifs/transport.c+18 -183 replies
7/13cifs: allow for different handling of received responsefs/cifs/cifs_debug.c fs/cifs/cifsglob.h fs/cifs/connect.c +1 more+55 -291 reply
8/13cifs: handle cancelled requests betterfs/cifs/cifsglob.h fs/cifs/cifsproto.h fs/cifs/connect.c +1 more+61 -169 replies
9/13cifs: add cifs_call_asyncfs/cifs/cifsproto.h fs/cifs/transport.c+57 -11 reply
10/13cifs: add ability to send an echo requestfs/cifs/cifspdu.h fs/cifs/cifsproto.h fs/cifs/cifssmb.c+63 -01 reply
11/13cifs: set up recurring workqueue job to do SMB echo requestsfs/cifs/cifsglob.h fs/cifs/connect.c+30 -01 reply
12/13cifs: reconnect unresponsive serversfs/cifs/connect.c+19 -41 reply
13/13cifs: remove code for setting timeouts on requestsfs/cifs/cifsglob.h fs/cifs/cifssmb.c fs/cifs/connect.c +3 more+17 -501 reply

Reviews trailers per patch

12 of 13 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPavel Shilovsky
SeriesR-b
1/13R-b
2/13R-b
3/13R-b
4/13R-b
5/13R-b
6/13R-b
7/13R-b
8/13R-b
9/13R-b
10/13R-b
11/13R-b
12/13R-b
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/13] cifs: don't fail writepages on -EAGAIN errors (try #2)

If CIFSSMBWrite2 returns -EAGAIN, then the error should be considered temporary. CIFS should retry the write instead of setting an error on the mapping and returning.

For WB_SYNC_ALL, just retry the write immediately. In the WB_SYNC_NONE case, call redirty_page_for_writeback on all of the pages that didn't get written out and then move on.

Also, fix up the handling of a short write with a successful return code. MS-CIFS says that 0 bytes_written means ENOSPC or EFBIG. It doesn't mention what a short, but non-zero write means, so for now treat it as we would an -EAGAIN return.

---
 fs/cifs/file.c |   48 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 36 insertions(+), 12 deletions(-)
fs/cifs/file.c +36 -12
index fe16f6d..8bef611 100644
@@ -1430,6 +1430,7 @@ retry:
 				break;
 		}
 		if (n_iov) {
+retry_write:
 			open_file = find_writable_file(CIFS_I(mapping->host),
 							false);
 			if (!open_file) {
@@ -1442,31 +1443,54 @@ retry:
 						   &bytes_written, iov, n_iov,
 						   long_op);
 				cifsFileInfo_put(open_file);
-				cifs_update_eof(cifsi, offset, bytes_written);
 			}
 
-			if (rc || bytes_written < bytes_to_write) {
-				cERROR(1, "Write2 ret %d, wrote %d",
-					  rc, bytes_written);
-				mapping_set_error(mapping, rc);
-			} else {
+			cFYI(1, "Write2 rc=%d, wrote=%u", rc, bytes_written);
+
+			/*
+			 * For now, treat a short write as if nothing got
+			 * written. A zero length write however indicates
+			 * ENOSPC or EFBIG. We have no way to know which
+			 * though, so call it ENOSPC for now. EFBIG would
+			 * get translated to AS_EIO anyway.
+			 *
+			 * FIXME: make it take into account the data that did
+			 *	  get written
+			 */
+			if (rc == 0) {
+				if (bytes_written == 0)
+					rc = -ENOSPC;
+				else if (bytes_written < bytes_to_write)
+					rc = -EAGAIN;
+			}
+
+			/* retry on data-integrity flush */
+			if (wbc->sync_mode == WB_SYNC_ALL &&
+			    (rc == -EAGAIN || bytes_written < bytes_to_write))
+				goto retry_write;
+
+			/* fix the stats and EOF */
+			if (bytes_written > 0) {
 				cifs_stats_bytes_written(tcon, bytes_written);
+				cifs_update_eof(cifsi, offset, bytes_written);
 			}
 
 			for (i = 0; i < n_iov; i++) {
 				page = pvec.pages[first + i];
-				/* Should we also set page error on
-				success rc but too little data written? */
-				/* BB investigate retry logic on temporary
-				server crash cases and how recovery works
-				when page marked as error */
-				if (rc)
+				/* on retryable write error, redirty page */
+				if (rc == -EAGAIN)
+					redirty_page_for_writepage(wbc, page);
+				else if (rc != 0)
 					SetPageError(page);
 				kunmap(page);
 				unlock_page(page);
 				end_page_writeback(page);
 				page_cache_release(page);
 			}
+
+			if (rc != -EAGAIN)
+				mapping_set_error(mapping, rc);
+
 			if ((wbc->nr_to_write -= n_iov) <= 0)
 				done = 1;
 			index = next;
Signature · 1 line
1.7.3.2