Merge pull request #45551 from liu-chunmei/crimson-string-view

crimson: keep string alive during string_view lifetime

Reviewed-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2022-03-23 13:49:01 -07:00 committed by GitHub
commit 0859cb8ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -735,7 +735,7 @@ static PG::interruptible_future<hobject_t> pgls_filter(
if (const auto xattr = filter.get_xattr(); !xattr.empty()) {
logger().debug("pgls_filter: filter is interested in xattr={} for obj={}",
xattr, sobj);
return backend.getxattr(sobj, xattr).safe_then_interruptible(
return backend.getxattr(sobj, std::move(xattr)).safe_then_interruptible(
[&filter, sobj] (ceph::bufferlist val) {
logger().debug("pgls_filter: got xvalue for obj={}", sobj);

View File

@ -867,7 +867,7 @@ PGBackend::get_attr_ierrorator::future<> PGBackend::getxattr(
name = "_" + aname;
}
logger().debug("getxattr on obj={} for attr={}", os.oi.soid, name);
return getxattr(os.oi.soid, name).safe_then_interruptible(
return getxattr(os.oi.soid, std::move(name)).safe_then_interruptible(
[&delta_stats, &osd_op] (ceph::bufferlist&& val) {
osd_op.outdata = std::move(val);
osd_op.op.xattr.value_len = osd_op.outdata.length();
@ -889,6 +889,19 @@ PGBackend::getxattr(
return store->get_attr(coll, ghobject_t{soid}, key);
}
PGBackend::get_attr_ierrorator::future<ceph::bufferlist>
PGBackend::getxattr(
const hobject_t& soid,
std::string&& key) const
{
if (__builtin_expect(stopping, false)) {
throw crimson::common::system_shutdown_exception();
}
return seastar::do_with(key, [this, &soid](auto &key) {
return store->get_attr(coll, ghobject_t{soid}, key);
});
}
PGBackend::get_attr_ierrorator::future<> PGBackend::get_xattrs(
const ObjectState& os,
OSDOp& osd_op,
@ -966,7 +979,7 @@ PGBackend::cmp_xattr_ierrorator::future<> PGBackend::cmp_xattr(
bp.copy(osd_op.op.xattr.name_len, name);
logger().debug("cmpxattr on obj={} for attr={}", os.oi.soid, name);
return getxattr(os.oi.soid, name).safe_then_interruptible(
return getxattr(os.oi.soid, std::move(name)).safe_then_interruptible(
[&delta_stats, &osd_op] (auto &&xattr) {
int result = 0;
auto bp = osd_op.indata.cbegin();

View File

@ -211,6 +211,9 @@ public:
get_attr_ierrorator::future<ceph::bufferlist> getxattr(
const hobject_t& soid,
std::string_view key) const;
get_attr_ierrorator::future<ceph::bufferlist> getxattr(
const hobject_t& soid,
std::string&& key) const;
get_attr_ierrorator::future<> get_xattrs(
const ObjectState& os,
OSDOp& osd_op,