]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw_file: add pretty-print for RGWFileHandle
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 10 Feb 2017 22:14:16 +0000 (17:14 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Mon, 13 Feb 2017 20:31:42 +0000 (15:31 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 2abe76b483c161d2e8024be265e40713344961d2..d7076d3052880db4b2b3cd4f42865b1d0c7e78ed 100644 (file)
@@ -720,6 +720,31 @@ namespace rgw {
     } while (! (stop || shutdown));
   } /* RGWLibFS::gc */
 
+  std::ostream& operator<<(std::ostream &os,
+                          RGWFileHandle const &rgw_fh)
+  {
+    const auto& fhk = rgw_fh.get_key();
+    const auto& fh = const_cast<RGWFileHandle&>(rgw_fh).get_fh();
+    os << "<RGWFileHandle:";
+    os << "addr=" << &rgw_fh;
+    switch (fh->fh_type) {
+    case RGW_FS_TYPE_DIRECTORY:
+       os << "type=DIRECTORY;";
+       break;
+    case RGW_FS_TYPE_FILE:
+       os << "type=FILE;";
+       break;
+    default:
+       os << "type=UNKNOWN;";
+       break;
+      };
+    os << "fid=" << fhk.fh_hk.bucket << ":" << fhk.fh_hk.object << ";";
+    os << "name=" << rgw_fh.object_name() << ";";
+    os << "refcnt=" << rgw_fh.get_refcnt() << ";";
+    os << ">";
+    return os;
+  }
+
   RGWFileHandle::~RGWFileHandle() {
     if (parent && (! parent->is_root())) {
       /* safe because if parent->unref causes its deletion,
index 9cc55ac0b946e3260489fa0a890035d42251f907..e0f9b627410c4e1b05922c3f6a7356068ccedd45 100644 (file)
@@ -642,6 +642,9 @@ namespace rgw {
 
     virtual ~RGWFileHandle();
 
+    friend std::ostream& operator<<(std::ostream &os,
+                                   RGWFileHandle const &rgw_fh);
+
     class Factory : public cohort::lru::ObjectFactory
     {
     public: