Skip to content

Commit

Permalink
libceph: fix truncate size calculation
Browse files Browse the repository at this point in the history
check the "not truncated yet" case

Signed-off-by: Yan, Zheng <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Yan, Zheng authored and Sage Weil committed Jul 3, 2013
1 parent eb845ff commit ccca4e3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions net/ceph/osd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,14 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,

object_size = le32_to_cpu(layout->fl_object_size);
object_base = off - objoff;
if (truncate_size <= object_base) {
truncate_size = 0;
} else {
truncate_size -= object_base;
if (truncate_size > object_size)
truncate_size = object_size;
if (!(truncate_seq == 1 && truncate_size == -1ULL)) {
if (truncate_size <= object_base) {
truncate_size = 0;
} else {
truncate_size -= object_base;
if (truncate_size > object_size)
truncate_size = object_size;
}
}

osd_req_op_extent_init(req, 0, opcode, objoff, objlen,
Expand Down

0 comments on commit ccca4e3

Please sign in to comment.