Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373398
b: refs/heads/master
c: d18d1e2
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent 4471c6d commit 6bcc5a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a19dadfba91c73a12a666e6fdb9e242f325df825
refs/heads/master: d18d1e2807f38a94839be1f83682e17011f53322
50 changes: 22 additions & 28 deletions trunk/net/ceph/osd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ static void __unregister_linger_request(struct ceph_osd_client *osdc,
static void __send_request(struct ceph_osd_client *osdc,
struct ceph_osd_request *req);

static int op_has_extent(int op)
{
return (op == CEPH_OSD_OP_READ ||
op == CEPH_OSD_OP_WRITE);
}

/*
* Implement client access to distributed object storage cluster.
*
Expand Down Expand Up @@ -554,22 +548,15 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
{
struct ceph_osd_req_op ops[2];
struct ceph_osd_request *req;
unsigned int num_op = 1;
unsigned int num_op = do_sync ? 2 : 1;
u64 objnum = 0;
u64 objoff = 0;
u64 objlen = 0;
u32 object_size;
u64 object_base;
int r;

memset(&ops, 0, sizeof ops);

ops[0].op = opcode;
ops[0].extent.truncate_seq = truncate_seq;
ops[0].extent.truncate_size = truncate_size;

if (do_sync) {
ops[1].op = CEPH_OSD_OP_STARTSYNC;
num_op++;
}
BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE);

req = ceph_osdc_alloc_request(osdc, snapc, num_op, use_mempool,
GFP_NOFS);
Expand All @@ -584,21 +571,28 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
return ERR_PTR(r);
}

if (op_has_extent(ops[0].op)) {
u32 osize = le32_to_cpu(layout->fl_object_size);
ops[0].extent.offset = objoff;
ops[0].extent.length = objlen;
if (ops[0].extent.truncate_size <= off - objoff) {
ops[0].extent.truncate_size = 0;
} else {
ops[0].extent.truncate_size -= off - objoff;
if (ops[0].extent.truncate_size > osize)
ops[0].extent.truncate_size = osize;
}
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;
}

memset(&ops, 0, sizeof ops);
ops[0].op = opcode;
ops[0].extent.offset = objoff;
ops[0].extent.length = objlen;
ops[0].extent.truncate_size = truncate_size;
ops[0].extent.truncate_seq = truncate_seq;
if (ops[0].op == CEPH_OSD_OP_WRITE)
ops[0].payload_len = *plen;

if (do_sync)
ops[1].op = CEPH_OSD_OP_STARTSYNC;

req->r_file_layout = *layout; /* keep a copy */

snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx",
Expand Down

0 comments on commit 6bcc5a4

Please sign in to comment.