]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: fix write error when the write offset overlaps. 18004/head
authorYao Zongyou <yaozongyou@vip.qq.com>
Sun, 24 Sep 2017 14:11:22 +0000 (22:11 +0800)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 27 Sep 2017 20:58:18 +0000 (16:58 -0400)
Fixes: http://tracker.ceph.com/issues/21455
Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
(cherry picked from commit 872d73f945364002f0fa31762e6976db5b4b3c19)

src/rgw/rgw_file.cc

index 83df3ddbf01bb94ede7be806e23b69f3006cf627..eef9c82e9f128ca6f58eb72b16270acd04797b8d 100644 (file)
@@ -1155,6 +1155,15 @@ namespace rgw {
       }
     }
 
+    int overlap = 0;
+    if ((static_cast<off_t>(off) < f->write_req->real_ofs) &&
+        ((f->write_req->real_ofs - off) <= len)) {
+      overlap = f->write_req->real_ofs - off;
+      off = f->write_req->real_ofs;
+      buffer = static_cast<char*>(buffer) + overlap;
+      len -= overlap;
+    }
+
     buffer::list bl;
     /* XXXX */
 #if 0
@@ -1191,7 +1200,7 @@ namespace rgw {
       rc = -EIO;
     }
 
-    *bytes_written = (rc == 0) ? len : 0;
+    *bytes_written = (rc == 0) ? (len + overlap) : 0;
     return rc;
   } /* RGWFileHandle::write */