rgw_file: fix write error when the write offset overlaps.

Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
This commit is contained in:
Yao Zongyou 2017-09-24 22:11:22 +08:00
parent 4639b96cae
commit 872d73f945

View File

@ -1159,6 +1159,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
@ -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 */