return num_periods * stripe_count - remainder_objs;
}
+uint64_t Striper::get_file_offset(CephContext *cct,
+ const file_layout_t *layout, uint64_t objectno, uint64_t off) {
+ ldout(cct, 10) << "get_file_offset " << objectno << " " << off << dendl;
+
+ __u32 object_size = layout->object_size;
+ __u32 su = layout->stripe_unit;
+ __u32 stripe_count = layout->stripe_count;
+ ceph_assert(object_size >= su);
+ uint64_t stripes_per_object = object_size / su;
+ ldout(cct, 20) << " stripes_per_object " << stripes_per_object << dendl;
+
+ uint64_t off_in_block = off % su;
+
+ uint64_t stripepos = objectno % stripe_count;
+ uint64_t objectsetno = objectno / stripe_count;
+ uint64_t stripeno = off / su + objectsetno * stripes_per_object;
+ uint64_t blockno = stripeno * stripe_count + stripepos;
+ return blockno * su + off_in_block;
+}
+
// StripedReadResult
void Striper::StripedReadResult::add_partial_result(
static uint64_t get_num_objects(const file_layout_t& layout,
uint64_t size);
+
+ static uint64_t get_file_offset(CephContext *cct,
+ const file_layout_t *layout, uint64_t objectno, uint64_t off);
/*
* helper to assemble a striped result
*/
numobjs = Striper::get_num_objects(l, size);
ASSERT_EQ(6u, numobjs);
}
+
+TEST(Striper, GetFileOffset)
+{
+ file_layout_t l;
+
+ l.object_size = 262144;
+ l.stripe_unit = 4096;
+ l.stripe_count = 3;
+
+ uint64_t object_no = 100;
+ uint64_t object_off = 200000;
+ uint64_t file_offset = Striper::get_file_offset(
+ g_ceph_context, &l, object_no, object_off);
+ ASSERT_EQ(26549568u, file_offset);
+}