]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: really make hexdump optional, set resid in readv unit test
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 30 Oct 2015 20:19:35 +0000 (16:19 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:05:29 +0000 (12:05 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h
src/test/librgw_file_gp.cc

index 3e06cd7abe760f6fa2ccbbc67ec66c8d8f1044f4..7b92b61eb35838a09399136b6ddf71655583669a 100644 (file)
 
 #include "rgw_file.h"
 
-/* XXX
- * ASSERT_H somehow not defined after all the above (which bring
- * in common/debug.h [e.g., dout])
- */
-#include "include/assert.h"
-
 #define dout_subsys ceph_subsys_rgw
 
 extern RGWLib librgw;
@@ -422,6 +416,7 @@ int rgw_readv(struct rgw_fs *rgw_fs,
   RGWGetObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
                      rgw_fh->object_name(), uio->uio_offset, uio->uio_resid,
                      bl);
+  req.do_hexdump = false;
 
   int rc = librgw.get_fe()->execute_req(&req);
 
index 02e62f54125b0a4ddcd292c16c56f0febba3d652..f853d77f0a467440275058372eb84c2fff0c332a 100644 (file)
 #include "xxhash.h"
 #include "include/buffer.h"
 
+/* XXX
+ * ASSERT_H somehow not defined after all the above (which bring
+ * in common/debug.h [e.g., dout])
+ */
+#include "include/assert.h"
+
+
 class RGWLibFS;
 class RGWFileHandle;
 
@@ -455,6 +462,7 @@ public:
   const std::string& bucket_name;
   const std::string& obj_name;
   buffer::list& bl;
+  bool do_hexdump = false;
 
   RGWGetObjRequest(CephContext* _cct, RGWUserInfo *_user,
                  const std::string& _bname, const std::string& _oname,
@@ -514,6 +522,13 @@ public:
   virtual int send_response_data(ceph::buffer::list& _bl, off_t s_off,
                                off_t e_off) {
     /* XXX deal with offsets */
+    if (do_hexdump) {
+      dout(15) << __func__ << " s_off " << s_off
+              << " e_off " << e_off << " len " << _bl.length()
+              << " ";
+      _bl.hexdump(*_dout);
+      *_dout << dendl;
+    }
     bl.claim_append(_bl);
     return 0;
   }
index eb98177343811a0d86634df8e2d25cc0ce428db3..50f2b9e078b8d500943f2ee740b0953b45870d39 100644 (file)
@@ -44,6 +44,7 @@ namespace {
   bool do_readv = false;
   bool do_get = false;
   bool do_delete = false;
+  bool do_hexdump = false;
 
   string bucket_name = "sorry_dave";
   string object_name = "jocaml";
@@ -215,9 +216,11 @@ TEST(LibRGW, GET_OBJECT) {
     ASSERT_EQ(ret, 0);
     buffer::list bl;
     bl.push_back(buffer::create_static(nread, sbuf));
-    dout(15) << "";
-    bl.hexdump(*_dout);
-    *_dout << dendl;
+    if (do_hexdump) {
+      dout(15) << "";
+      bl.hexdump(*_dout);
+      *_dout << dendl;
+    }
   }
 }
 
@@ -283,6 +286,7 @@ TEST(LibRGW, READV)
     rgw_uio uio[1];
     memset(uio, 0, sizeof(rgw_uio));
     uio->uio_offset = 0; // ok, it was already 0
+    uio->uio_resid = UINT64_MAX;
     int ret = rgw_readv(fs, object_fh, uio);
     ASSERT_EQ(ret, 0);
     //buffer::list bl;
@@ -294,9 +298,13 @@ TEST(LibRGW, READV)
                              static_cast<char*>(vio->vio_base)));
     }
 
-    dout(15) << "";
-    bl.hexdump(*_dout);
-    *_dout << dendl;
+    ASSERT_EQ(uint32_t{bl.length()}, uint32_t{iovcnt*page_size});
+
+    if (do_hexdump) {
+      dout(15) << "";
+      bl.hexdump(*_dout);
+      *_dout << dendl;
+    }
 
     // release resources
     ASSERT_NE(uio->uio_rele, nullptr);
@@ -387,6 +395,9 @@ int main(int argc, char *argv[])
     } else if (ceph_argparse_flag(args, arg_iter, "--prelist",
                                            (char*) nullptr)) {
       do_pre_list = true;
+    } else if (ceph_argparse_flag(args, arg_iter, "--hexdump",
+                                           (char*) nullptr)) {
+      do_hexdump = true;
     } else {
       ++arg_iter;
     }