]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_file: Move RGW{ListBuckets,Readdir}Request::eof() to .cc file
authorKefu Chai <tchaikov@gmail.com>
Mon, 12 May 2025 02:01:28 +0000 (10:01 +0800)
committerKefu Chai <tchaikov@gmail.com>
Fri, 13 Jun 2025 22:14:09 +0000 (06:14 +0800)
Move RGWListBucketsRequest::eof() and RGWReaddirRequest::eof()
implementations from header to rgw/rgw_file.cc for better consistency
with our custom  RGWFileHandle::readdir_offset formatting.

Previously, these functions relied on boost::variant's global operator<<,
but we have our own specialized operator<< for readdir_offset in rgw_file_int.h.
Our implementation is optimized for the case where readdir_offset contains a
const char* and uses unlikely() for performance, unlike boost's default
formatter.

By moving implementations to the .cc file (after our custom operator<<
definition), we ensure they use our formatting logic and resolve potential
conflicts. This also properly addresses the fact that friend declarations
don't serve as function declarations. This change also paves the road to
migrate from boost::variant to std::variant, which does not provide the
global operator<<, so we will have to use our operator<< overload.

To preserve the previous inline behavior, both functions are explicitly
marked with the 'inline' keyword. Verification of inlining was performed
using:

```
readelf -s -W --demangle build/src/rgw/CMakeFiles/rgw_a.dir/rgw_file.cc.o | grep "Request::eof"
```
With `CMAKE_BUILD_TYPE=RelWithDebInfo`, both functions are confirmed to be
inlined as they don't appear in the symbol table, maintaining existing
behavior.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file_int.h

index 15146e63fd67638caa38f09b599453a2bfaad522..85c54f8c04ccd01841a494914404856b4e1b135f 100644 (file)
@@ -1825,6 +1825,37 @@ namespace rgw {
     }
   }
 
+  bool RGWListBucketsRequest::eof() {
+    using boost::get;
+
+    if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
+      bool is_offset =
+       unlikely(! get<const char*>(&offset)) ||
+       !! get<const char*>(offset);
+      lsubdout(cct, rgw, 15) << "READDIR offset: " <<
+       ((is_offset) ? offset : "(nil)")
+                            << " is_truncated: " << is_truncated
+                            << dendl;
+    }
+    return !is_truncated && !rcb_eof;
+  }
+
+  bool RGWReaddirRequest::eof() {
+    using boost::get;
+
+    if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
+      bool is_offset =
+       unlikely(! get<const char*>(&offset)) ||
+       !! get<const char*>(offset);
+      lsubdout(cct, rgw, 15) << "READDIR offset: " <<
+       ((is_offset) ? offset : "(nil)")
+                            << " next marker: " << next_marker
+                            << " is_truncated: " << is_truncated
+                            << dendl;
+    }
+    return !is_truncated && !rcb_eof;
+  }
+
   int RGWWriteRequest::exec_start() {
     req_state* state = get_state();
 
index 84eff1e252e26518fba91db67af84ec49d722037..d9c350e6ca93bad5b40c19b6f8cc0338ed79391e 100644 (file)
@@ -1442,21 +1442,7 @@ public:
     return rcb(name.data(), cb_arg, off, nullptr, 0, RGW_LOOKUP_FLAG_DIR);
   }
 
-  bool eof() {
-    using boost::get;
-
-    if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
-      bool is_offset =
-       unlikely(! get<const char*>(&offset)) ||
-       !! get<const char*>(offset);
-      lsubdout(cct, rgw, 15) << "READDIR offset: " <<
-       ((is_offset) ? offset : "(nil)")
-                            << " is_truncated: " << is_truncated
-                            << dendl;
-    }
-    return !is_truncated && !rcb_eof;
-  }
-
+  inline bool eof();
 }; /* RGWListBucketsRequest */
 
 /*
@@ -1769,22 +1755,7 @@ public:
     send_response();
   }
 
-  bool eof() {
-    using boost::get;
-
-    if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
-      bool is_offset =
-       unlikely(! get<const char*>(&offset)) ||
-       !! get<const char*>(offset);
-      lsubdout(cct, rgw, 15) << "READDIR offset: " <<
-       ((is_offset) ? offset : "(nil)")
-                            << " next marker: " << next_marker
-                            << " is_truncated: " << is_truncated
-                            << dendl;
-    }
-    return !is_truncated && !rcb_eof;
-  }
-
+  inline bool eof();
 }; /* RGWReaddirRequest */
 
 /*