Skip to content

Commit 57322f3

Browse files
committed
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 <[email protected]>
1 parent a372d62 commit 57322f3

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

src/rgw/rgw_file.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,37 @@ namespace rgw {
18251825
}
18261826
}
18271827

1828+
bool RGWListBucketsRequest::eof() {
1829+
using boost::get;
1830+
1831+
if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
1832+
bool is_offset =
1833+
unlikely(! get<const char*>(&offset)) ||
1834+
!! get<const char*>(offset);
1835+
lsubdout(cct, rgw, 15) << "READDIR offset: " <<
1836+
((is_offset) ? offset : "(nil)")
1837+
<< " is_truncated: " << is_truncated
1838+
<< dendl;
1839+
}
1840+
return !is_truncated && !rcb_eof;
1841+
}
1842+
1843+
bool RGWReaddirRequest::eof() {
1844+
using boost::get;
1845+
1846+
if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
1847+
bool is_offset =
1848+
unlikely(! get<const char*>(&offset)) ||
1849+
!! get<const char*>(offset);
1850+
lsubdout(cct, rgw, 15) << "READDIR offset: " <<
1851+
((is_offset) ? offset : "(nil)")
1852+
<< " next marker: " << next_marker
1853+
<< " is_truncated: " << is_truncated
1854+
<< dendl;
1855+
}
1856+
return !is_truncated && !rcb_eof;
1857+
}
1858+
18281859
int RGWWriteRequest::exec_start() {
18291860
req_state* state = get_state();
18301861

src/rgw/rgw_file_int.h

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,21 +1442,7 @@ class RGWListBucketsRequest : public RGWLibRequest,
14421442
return rcb(name.data(), cb_arg, off, nullptr, 0, RGW_LOOKUP_FLAG_DIR);
14431443
}
14441444

1445-
bool eof() {
1446-
using boost::get;
1447-
1448-
if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
1449-
bool is_offset =
1450-
unlikely(! get<const char*>(&offset)) ||
1451-
!! get<const char*>(offset);
1452-
lsubdout(cct, rgw, 15) << "READDIR offset: " <<
1453-
((is_offset) ? offset : "(nil)")
1454-
<< " is_truncated: " << is_truncated
1455-
<< dendl;
1456-
}
1457-
return !is_truncated && !rcb_eof;
1458-
}
1459-
1445+
inline bool eof();
14601446
}; /* RGWListBucketsRequest */
14611447

14621448
/*
@@ -1769,22 +1755,7 @@ class RGWReaddirRequest : public RGWLibRequest,
17691755
send_response();
17701756
}
17711757

1772-
bool eof() {
1773-
using boost::get;
1774-
1775-
if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
1776-
bool is_offset =
1777-
unlikely(! get<const char*>(&offset)) ||
1778-
!! get<const char*>(offset);
1779-
lsubdout(cct, rgw, 15) << "READDIR offset: " <<
1780-
((is_offset) ? offset : "(nil)")
1781-
<< " next marker: " << next_marker
1782-
<< " is_truncated: " << is_truncated
1783-
<< dendl;
1784-
}
1785-
return !is_truncated && !rcb_eof;
1786-
}
1787-
1758+
inline bool eof();
17881759
}; /* RGWReaddirRequest */
17891760

17901761
/*

0 commit comments

Comments
 (0)