All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: fix error handling in ceph_sync_write
@ 2022-08-24 20:53 Jeff Layton
  2022-08-25  1:22 ` Xiubo Li
  2022-08-25  8:32 ` Ilya Dryomov
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff Layton @ 2022-08-24 20:53 UTC (permalink / raw)
  To: xiubli; +Cc: idryomov, ceph-devel

ceph_sync_write has assumed that a zero result in req->r_result means
success. Testing with a recent cluster however shows the OSD returning
a non-zero length written here. I'm not sure whether and when this
changed, but fix the code to accept either result.

Assume a negative result means error, and anything else is a success. If
we're given a short length, then return a short write.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/file.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 86265713a743..c0b2c8968be9 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1632,11 +1632,19 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
 					  req->r_end_latency, len, ret);
 out:
 		ceph_osdc_put_request(req);
-		if (ret != 0) {
+		if (ret < 0) {
 			ceph_set_error_write(ci);
 			break;
 		}
 
+		/*
+		 * FIXME: it's unclear whether all OSD versions return the
+		 * length written on a write. For now, assume that a 0 return
+		 * means that everything got written.
+		 */
+		if (ret && ret < len)
+			len = ret;
+
 		ceph_clear_error_write(ci);
 		pos += len;
 		written += len;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-08-26  0:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24 20:53 [PATCH] ceph: fix error handling in ceph_sync_write Jeff Layton
2022-08-25  1:22 ` Xiubo Li
2022-08-25  8:32 ` Ilya Dryomov
2022-08-25  9:41   ` Luís Henriques
2022-08-25 13:18     ` Jeff Layton
2022-08-25 10:56   ` Jeff Layton
2022-08-25 13:16     ` Jeff Layton
2022-08-26  0:07       ` Xiubo Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.