From: Kefu Chai Date: Mon, 12 May 2025 02:01:28 +0000 (+0800) Subject: rgw/rgw_file: Move RGW{ListBuckets,Readdir}Request::eof() to .cc file X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57322f32ae9f088108e133a2e27c5a4cbe1aca68;p=ceph.git rgw/rgw_file: Move RGW{ListBuckets,Readdir}Request::eof() to .cc file 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 --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 15146e63fd6..85c54f8c04c 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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(&offset)) || + !! get(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(&offset)) || + !! get(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(); diff --git a/src/rgw/rgw_file_int.h b/src/rgw/rgw_file_int.h index 84eff1e252e..d9c350e6ca9 100644 --- a/src/rgw/rgw_file_int.h +++ b/src/rgw/rgw_file_int.h @@ -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(&offset)) || - !! get(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(&offset)) || - !! get(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 */ /*