From 96a7519aa21dfd59d5943ea5e5fd9089f518e5ed Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 27 Aug 2019 22:47:37 +0200 Subject: [PATCH] crimson/os: fix ENODATA handling in CyanStore::get_attrs(). Signed-off-by: Radoslaw Zarzynski --- src/crimson/os/cyan_store.cc | 2 +- src/crimson/os/futurized_store.h | 4 ++++ src/crimson/osd/exceptions.h | 4 ++++ src/crimson/osd/pg_backend.cc | 7 ++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/crimson/os/cyan_store.cc b/src/crimson/os/cyan_store.cc index 650dcb896ad5b..06deaaa102eb6 100644 --- a/src/crimson/os/cyan_store.cc +++ b/src/crimson/os/cyan_store.cc @@ -218,7 +218,7 @@ seastar::future CyanStore::get_attr(CollectionRef ch, return seastar::make_ready_future(found->second); } else { return seastar::make_exception_future( - EnoentException(fmt::format("attr does not exist: {}/{}", oid, name))); + EnodataException(fmt::format("attr does not exist: {}/{}", oid, name))); } } diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index edd7866dfdef9..3ff9cb0f7a861 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -23,6 +23,7 @@ class Transaction; class FuturizedStore { public: + // TODO: replace with the ceph::errorator concept template class Exception : public std::logic_error { public: @@ -49,6 +50,9 @@ public: struct EnoentException : public Exception { using Exception::Exception; }; + struct EnodataException : public Exception { + using Exception::Exception; + }; static std::unique_ptr create(const std::string& type, const std::string& data); FuturizedStore() = default; diff --git a/src/crimson/osd/exceptions.h b/src/crimson/osd/exceptions.h index 563cc4e3f532e..0d678e3729469 100644 --- a/src/crimson/osd/exceptions.h +++ b/src/crimson/osd/exceptions.h @@ -40,6 +40,10 @@ struct invalid_argument : public error { invalid_argument() : error(std::errc::invalid_argument) {} }; +struct no_message_available : public error { + no_message_available() : error(std::errc::no_message_available) {} +}; + // FIXME: error handling struct operation_not_supported : public error { operation_not_supported() diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index b0af08417973a..40d109d448ce4 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -453,6 +453,7 @@ seastar::future<> PGBackend::setxattr( name = "_" + aname; bp.copy(osd_op.op.xattr.value_len, val); } + logger().debug("setxattr on obj={} for attr={}", os.oi.soid, name); txn.setattr(coll->get_cid(), ghobject_t{os.oi.soid}, name, val); return seastar::now(); @@ -471,14 +472,18 @@ seastar::future<> PGBackend::getxattr( bp.copy(osd_op.op.xattr.name_len, aname); name = "_" + aname; } + logger().debug("getxattr on obj={} for attr={}", os.oi.soid, name); return getxattr(os.oi.soid, name).then([&osd_op] (ceph::bufferptr val) { osd_op.outdata.clear(); osd_op.outdata.push_back(std::move(val)); osd_op.op.xattr.value_len = osd_op.outdata.length(); //ctx->delta_stats.num_rd_kb += shift_round_up(osd_op.outdata.length(), 10); }).handle_exception_type( - [] (ceph::os::FuturizedStore::EnoentException& e) { + [] (ceph::os::FuturizedStore::EnoentException&) { return seastar::make_exception_future<>(ceph::osd::object_not_found{}); + }).handle_exception_type( + [] (ceph::os::FuturizedStore::EnodataException&) { + return seastar::make_exception_future<>(ceph::osd::no_message_available{}); }); //ctx->delta_stats.num_rd++; } -- 2.39.5