From 36e8cd7ac6f6422d2972f152ef5a96f875365790 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 16 Sep 2019 17:21:01 +0200 Subject: [PATCH] osd: Clean up endian handling Replace remaining uses of __le16/__le32/__le64 in contexts that are not relevant to code generation, or where objects are only used locally and do not require endian swaps. Also, remove unnecessary calls to le16/32/64_to_cpu. This change is a no-op on all architectures. Signed-off-by: Ulrich Weigand --- src/osd/PrimaryLogPG.cc | 13 ++++++------- src/osd/mClockOpClassSupport.cc | 6 +----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index eb06312d0a7..3f954328c84 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -4832,10 +4832,10 @@ struct FillInVerifyExtent : public Context { uint64_t size; OSDService *osd; hobject_t soid; - __le32 flags; + uint32_t flags; FillInVerifyExtent(ceph_le64 *r, int32_t *rv, bufferlist *blp, std::optional mc, uint64_t size, - OSDService *osd, hobject_t soid, __le32 flags) : + OSDService *osd, hobject_t soid, uint32_t flags) : r(r), rval(rv), outdatap(blp), maybe_crc(mc), size(size), osd(osd), soid(soid), flags(flags) {} void finish(int len) override { @@ -4951,7 +4951,7 @@ struct C_ChecksumRead : public Context { C_ChecksumRead(PrimaryLogPG *primary_log_pg, OSDOp &osd_op, Checksummer::CSumType csum_type, bufferlist &&init_value_bl, std::optional maybe_crc, uint64_t size, - OSDService *osd, hobject_t soid, __le32 flags) + OSDService *osd, hobject_t soid, uint32_t flags) : primary_log_pg(primary_log_pg), osd_op(osd_op), csum_type(csum_type), init_value_bl(std::move(init_value_bl)), fill_extent_ctx(new FillInVerifyExtent(&read_length, &osd_op.rval, @@ -5163,7 +5163,7 @@ struct C_ExtentCmpRead : public Context { C_ExtentCmpRead(PrimaryLogPG *primary_log_pg, OSDOp &osd_op, std::optional maybe_crc, uint64_t size, - OSDService *osd, hobject_t soid, __le32 flags) + OSDService *osd, hobject_t soid, uint32_t flags) : primary_log_pg(primary_log_pg), osd_op(osd_op), fill_extent_ctx(new FillInVerifyExtent(&read_length, &osd_op.rval, &read_bl, maybe_crc, size, @@ -5481,7 +5481,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) } } - // TODO: check endianness (__le32 vs uint32_t, etc.) + // TODO: check endianness (ceph_le32 vs uint32_t, etc.) // The fields in ceph_osd_op are little-endian (according to the definition in rados.h), // but the code in this function seems to treat them as native-endian. What should the // tracepoints do? @@ -6353,9 +6353,8 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) result = 0; { tracepoint(osd, do_osd_op_pre_create, soid.oid.name.c_str(), soid.snap.val); - int flags = le32_to_cpu(op.flags); if (obs.exists && !oi.is_whiteout() && - (flags & CEPH_OSD_OP_FLAG_EXCL)) { + (op.flags & CEPH_OSD_OP_FLAG_EXCL)) { result = -EEXIST; /* this is an exclusive create */ } else { if (osd_op.indata.length()) { diff --git a/src/osd/mClockOpClassSupport.cc b/src/osd/mClockOpClassSupport.cc index 22416e064f4..49cad6ced58 100644 --- a/src/osd/mClockOpClassSupport.cc +++ b/src/osd/mClockOpClassSupport.cc @@ -85,13 +85,9 @@ namespace ceph { if (osd_op_type_t::client_op != type) { return type; } else { - // get_header returns ceph_msg_header type, ceph_msg_header - // stores type as unsigned little endian, so be sure to - // convert to CPU byte ordering std::optional op_ref_maybe = op.maybe_get_op(); ceph_assert(op_ref_maybe); - __le16 mtype_le = (*op_ref_maybe)->get_req()->get_header().type; - __u16 mtype = le16_to_cpu(mtype_le); + __u16 mtype = (*op_ref_maybe)->get_req()->get_header().type; if (rep_op_msg_bitset.test(mtype)) { return osd_op_type_t::osd_rep_op; } else { -- 2.39.5