Skip to content

Commit c9382d8

Browse files
committed
osd: use cmd_getval_cast_or() to fetch shard-id
as that interface alleviates the need to cast shard_id_t::NO_SHARD back and forth to/from int. Signed-off-by: Ronen Friedman <[email protected]>
1 parent ae1e251 commit c9382d8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/osd/OSD.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ using ceph::make_mutex;
193193
using namespace ceph::osd::scheduler;
194194
using TOPNSPC::common::cmd_getval;
195195
using TOPNSPC::common::cmd_getval_or;
196+
using TOPNSPC::common::cmd_getval_cast_or;
196197
using namespace std::literals;
197198

198199
static ostream& _prefix(std::ostream* _dout, int whoami, epoch_t epoch) {
@@ -6582,10 +6583,10 @@ void TestOpsSocketHook::test_ops(OSDService *service, ObjectStore *store,
65826583
return;
65836584
}
65846585

6585-
int64_t shardid64 = cmd_getval_or<int64_t>(cmdmap, "shardid", static_cast<int64_t>(shard_id_t::NO_SHARD));
6586-
shard_id_t shardid = shard_id_t(static_cast<int8_t>(shardid64));
6587-
6588-
hobject_t obj(object_t(objname), string(""), CEPH_NOSNAP, rawpg.ps(), pool, nspace);
6586+
shard_id_t shardid =
6587+
cmd_getval_cast_or<int64_t>(cmdmap, "shardid", shard_id_t::NO_SHARD);
6588+
hobject_t obj(
6589+
object_t(objname), ""s, CEPH_NOSNAP, rawpg.ps(), pool, nspace);
65896590
ghobject_t gobj(obj, ghobject_t::NO_GEN, shardid);
65906591
spg_t pgid(curmap->raw_pg_to_pg(rawpg), shardid);
65916592
if (curmap->pg_is_ec(rawpg)) {

0 commit comments

Comments
 (0)