From: Matt Benjamin Date: Sun, 17 Jan 2016 22:30:06 +0000 (-0500) Subject: librgw: temporary fix RGWWrite X-Git-Tag: v10.1.0~382^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e43eb4d63495471960ae6533e61d64c997b56a36;p=ceph.git librgw: temporary fix RGWWrite The current behavior of put_data_and_throttle leads to data curruption, because the supplied buffer is apparently still being written when the call returns--regardless of the value of need_to_wait. For now, do a buffer::copy of the supplied buffer, rather than the original buffer::static, since that will at least be released when no longer needed. Probably this improves apparent rgw_write performance, but is not what was originally intended. Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index f168faac28e5..24ffbd0a675e 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -420,8 +420,14 @@ namespace rgw { } buffer::list bl; + /* XXXX */ +#if 0 bl.push_back( buffer::create_static(len, static_cast(buffer))); +#else + bl.push_back( + buffer::copy(static_cast(buffer), len)); +#endif f->write_req->put_data(off, bl); rc = f->write_req->exec_continue(); @@ -506,8 +512,9 @@ namespace rgw { if (! len) return 0; - /* XXX won't see multipart */ - bool need_to_wait = (ofs == 0) && multipart; + /* XXX we are currently synchronous--supplied data buffers cannot + * be used after the caller returns */ + bool need_to_wait = true; bufferlist orig_data; if (need_to_wait) { diff --git a/src/test/librgw_file_nfsns.cc b/src/test/librgw_file_nfsns.cc index dad5f12069d5..ff42aa269f72 100644 --- a/src/test/librgw_file_nfsns.cc +++ b/src/test/librgw_file_nfsns.cc @@ -624,7 +624,9 @@ TEST(LibRGW, WRITEF_DIRS1) { << " (" << str << "... [first 4 chars])" << std::endl; } - rc = rgw_write(fs, fobj.fh, offset, length, &nwritten, buffer, + char* leakbuf = (char*) malloc(bufsz); + memcpy(leakbuf, buffer, length); + rc = rgw_write(fs, fobj.fh, offset, length, &nwritten, leakbuf, RGW_WRITE_FLAG_NONE); ASSERT_EQ(rc, 0); ASSERT_EQ(nwritten, length);