ceph: re-calculate truncate_size for strip object
authorYan, Zheng <zheng.z.yan@intel.com>
Fri, 30 Nov 2012 05:49:51 +0000 (13:49 +0800)
committerAlex Elder <elder@inktank.com>
Thu, 17 Jan 2013 18:42:37 +0000 (12:42 -0600)
Otherwise osd may truncate the object to larger size.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Sage Weil <sage@inktank.com>
net/ceph/osd_client.c

index eb9a4447876481e9a4110a1e68ea351ce3ec86d9..267f183b801a2db737fce65910efb92ffa38a260 100644 (file)
@@ -76,8 +76,16 @@ int ceph_calc_raw_layout(struct ceph_osd_client *osdc,
                     orig_len - *plen, off, *plen);
 
        if (op_has_extent(op->op)) {
+               u32 osize = le32_to_cpu(layout->fl_object_size);
                op->extent.offset = objoff;
                op->extent.length = objlen;
+               if (op->extent.truncate_size <= off - objoff) {
+                       op->extent.truncate_size = 0;
+               } else {
+                       op->extent.truncate_size -= off - objoff;
+                       if (op->extent.truncate_size > osize)
+                               op->extent.truncate_size = osize;
+               }
        }
        req->r_num_pages = calc_pages_for(off, *plen);
        req->r_page_alignment = off & ~PAGE_MASK;