Commit 645a1025 authored by Sage Weil's avatar Sage Weil

ceph: fix object striping calculation for non-default striping schemes

We were incorrectly calculationing of object offset.  If we have multiple
stripe units per object, we need to shift to the start of the current
su in addition to the offset within the su.

Also rename bno to ono (object number) to avoid some variable naming
confusion.
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent 5600f5eb
...@@ -723,7 +723,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, ...@@ -723,7 +723,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
*/ */
void ceph_calc_file_object_mapping(struct ceph_file_layout *layout, void ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
u64 off, u64 *plen, u64 off, u64 *plen,
u64 *bno, u64 *ono,
u64 *oxoff, u64 *oxlen) u64 *oxoff, u64 *oxlen)
{ {
u32 osize = le32_to_cpu(layout->fl_object_size); u32 osize = le32_to_cpu(layout->fl_object_size);
...@@ -750,11 +750,14 @@ void ceph_calc_file_object_mapping(struct ceph_file_layout *layout, ...@@ -750,11 +750,14 @@ void ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
stripepos = bl % sc; stripepos = bl % sc;
objsetno = stripeno / su_per_object; objsetno = stripeno / su_per_object;
*bno = objsetno * sc + stripepos; *ono = objsetno * sc + stripepos;
dout("objset %u * sc %u = bno %u\n", objsetno, sc, (unsigned)*bno); dout("objset %u * sc %u = ono %u\n", objsetno, sc, (unsigned)*ono);
/* *oxoff = *off % layout->fl_stripe_unit; */
/* *oxoff = *off % layout->fl_stripe_unit; # offset in su */
t = off; t = off;
*oxoff = do_div(t, su); *oxoff = do_div(t, su);
*oxoff += (stripeno % su_per_object) * su;
*oxlen = min_t(u64, *plen, su - *oxoff); *oxlen = min_t(u64, *plen, su - *oxoff);
*plen = *oxlen; *plen = *oxlen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment