]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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)
committerNathan Cutler <ncutler@suse.com>
Tue, 4 Jul 2017 07:15:41 +0000 (09:15 +0200)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit ef330f385d3407af5f470b5093145f59cc4dcc79)

src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 5d5391fcd6129d1e897444be5debdb37fce4a7ab..505c0d921765ea03b394e5323aa45683e4faa72a 100644 (file)
@@ -742,6 +742,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 cc081d5fb5cbdd6d782e8c106f5672c7bbc80f89..6c4349950d45bbe5bcd125606328eac6667af3e4 100644 (file)
@@ -638,6 +638,9 @@ namespace rgw {
 
     virtual ~RGWFileHandle();
 
+    friend std::ostream& operator<<(std::ostream &os,
+                                   RGWFileHandle const &rgw_fh);
+
     class Factory : public cohort::lru::ObjectFactory
     {
     public: