]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: temporary fix RGWWrite
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 17 Jan 2016 22:30:06 +0000 (17:30 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:08:12 +0000 (12:08 -0500)
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 <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/test/librgw_file_nfsns.cc

index f168faac28e597c05448c95c0d508c02fea96ee4..24ffbd0a675ee731b2cf6467334447c2f4b39e32 100644 (file)
@@ -420,8 +420,14 @@ namespace rgw {
     }
 
     buffer::list bl;
+    /* XXXX */
+#if 0
     bl.push_back(
       buffer::create_static(len, static_cast<char*>(buffer)));
+#else
+    bl.push_back(
+      buffer::copy(static_cast<char*>(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) {
index dad5f12069d5cff863e5eb355b44f7d43d6e0d56..ff42aa269f72145f461b2361ddc8b297fb1a60b6 100644 (file)
@@ -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);