From: Yao Zongyou Date: Sun, 24 Sep 2017 14:11:22 +0000 (+0800) Subject: rgw_file: fix write error when the write offset overlaps. X-Git-Tag: v13.0.1~796^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17809%2Fhead;p=ceph.git rgw_file: fix write error when the write offset overlaps. Signed-off-by: Yao Zongyou --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index f21216698be3..fa3d373a0f24 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1159,6 +1159,15 @@ namespace rgw { } } + int overlap = 0; + if ((static_cast(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(buffer) + overlap; + len -= overlap; + } + buffer::list bl; /* XXXX */ #if 0 @@ -1195,7 +1204,7 @@ namespace rgw { rc = -EIO; } - *bytes_written = (rc == 0) ? len : 0; + *bytes_written = (rc == 0) ? (len + overlap) : 0; return rc; } /* RGWFileHandle::write */