Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373423
b: refs/heads/master
c: c99d2d4
h: refs/heads/master
i:
  373421: 229c766
  373419: 2480b8e
  373415: e7c2c89
  373407: b833c1b
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent fd5c1a7 commit 73e1a4d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 54 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: 8c042b0df99cd06ef8473ef6e204b87b3dc80158
refs/heads/master: c99d2d4abb6c405ef52e9bc1da87b382b8f41739
35 changes: 15 additions & 20 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,16 +1336,17 @@ static void rbd_osd_req_format_op(struct rbd_obj_request *obj_request,
snap_id = img_request->snap_id;
}
if (obj_request->type != OBJ_REQUEST_NODATA) {
struct ceph_osd_req_op *op = &obj_request->osd_req->r_ops[0];

/*
* If it has data, it's either a object class method
* call (cls) or it's an extent operation.
*/
if (op->op == CEPH_OSD_OP_CALL)
osd_req_op_cls_response_data(op, osd_data);
/* XXX This use of the ops array goes away in the next patch */
if (obj_request->osd_req->r_ops[0].op == CEPH_OSD_OP_CALL)
osd_req_op_cls_response_data(obj_request->osd_req, 0,
osd_data);
else
osd_req_op_extent_osd_data(op, osd_data);
osd_req_op_extent_osd_data(obj_request->osd_req, 0,
osd_data);
}
ceph_osdc_build_request(osd_req, obj_request->offset,
snapc, snap_id, mtime);
Expand Down Expand Up @@ -1577,7 +1578,6 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
while (resid) {
const char *object_name;
unsigned int clone_size;
struct ceph_osd_req_op *op;
u64 offset;
u64 length;

Expand Down Expand Up @@ -1606,8 +1606,8 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
if (!obj_request->osd_req)
goto out_partial;

op = &obj_request->osd_req->r_ops[0];
osd_req_op_extent_init(op, opcode, offset, length, 0, 0);
osd_req_op_extent_init(obj_request->osd_req, 0,
opcode, offset, length, 0, 0);
rbd_osd_req_format_op(obj_request, write_request);

/* status and version are initially zero-filled */
Expand Down Expand Up @@ -1710,7 +1710,6 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev,
u64 ver, u64 notify_id)
{
struct rbd_obj_request *obj_request;
struct ceph_osd_req_op *op;
struct ceph_osd_client *osdc;
int ret;

Expand All @@ -1724,8 +1723,8 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev,
if (!obj_request->osd_req)
goto out;

op = &obj_request->osd_req->r_ops[0];
osd_req_op_watch_init(op, CEPH_OSD_OP_NOTIFY_ACK, notify_id, ver, 0);
osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK,
notify_id, ver, 0);
rbd_osd_req_format_op(obj_request, false);

osdc = &rbd_dev->rbd_client->client->osdc;
Expand Down Expand Up @@ -1766,7 +1765,6 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start)
{
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
struct rbd_obj_request *obj_request;
struct ceph_osd_req_op *op;
int ret;

rbd_assert(start ^ !!rbd_dev->watch_event);
Expand All @@ -1790,8 +1788,7 @@ static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start)
if (!obj_request->osd_req)
goto out_cancel;

op = &obj_request->osd_req->r_ops[0];
osd_req_op_watch_init(op, CEPH_OSD_OP_WATCH,
osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH,
rbd_dev->watch_event->cookie,
rbd_dev->header.obj_version, start);
rbd_osd_req_format_op(obj_request, true);
Expand Down Expand Up @@ -1854,7 +1851,6 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
{
struct rbd_obj_request *obj_request;
struct ceph_osd_client *osdc;
struct ceph_osd_req_op *op;
struct page **pages;
u32 page_count;
int ret;
Expand Down Expand Up @@ -1884,8 +1880,8 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
if (!obj_request->osd_req)
goto out;

op = &obj_request->osd_req->r_ops[0];
osd_req_op_cls_init(op, CEPH_OSD_OP_CALL, class_name, method_name,
osd_req_op_cls_init(obj_request->osd_req, 0, CEPH_OSD_OP_CALL,
class_name, method_name,
outbound, outbound_size);
rbd_osd_req_format_op(obj_request, false);

Expand Down Expand Up @@ -2066,7 +2062,6 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,

{
struct rbd_obj_request *obj_request;
struct ceph_osd_req_op *op;
struct ceph_osd_client *osdc;
struct page **pages = NULL;
u32 page_count;
Expand All @@ -2091,8 +2086,8 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
if (!obj_request->osd_req)
goto out;

op = &obj_request->osd_req->r_ops[0];
osd_req_op_extent_init(op, CEPH_OSD_OP_READ, offset, length, 0, 0);
osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ,
offset, length, 0, 0);
rbd_osd_req_format_op(obj_request, false);

osdc = &rbd_dev->rbd_client->client->osdc;
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/ceph/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ static int ceph_writepages_start(struct address_space *mapping,

/* Update the write op length in case we changed it */

osd_req_op_extent_update(&req->r_ops[0], len);
osd_req_op_extent_update(req, 0, len);

vino = ceph_vino(inode);
ceph_osdc_build_request(req, offset, snapc, vino.snap,
Expand Down
19 changes: 12 additions & 7 deletions trunk/include/linux/ceph/osd_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,25 @@ extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
struct ceph_msg *msg);

extern void osd_req_op_init(struct ceph_osd_req_op *op, u16 opcode);
extern void osd_req_op_extent_init(struct ceph_osd_req_op *op, u16 opcode,
extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req,
unsigned int which, u16 opcode,
u64 offset, u64 length,
u64 truncate_size, u32 truncate_seq);
extern void osd_req_op_extent_update(struct ceph_osd_req_op *op, u64 length);
extern void osd_req_op_extent_osd_data(struct ceph_osd_req_op *op,
extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
unsigned int which, u64 length);
extern void osd_req_op_extent_osd_data(struct ceph_osd_request *osd_req,
unsigned int which,
struct ceph_osd_data *osd_data);
extern void osd_req_op_cls_init(struct ceph_osd_req_op *op, u16 opcode,
extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req,
unsigned int which, u16 opcode,
const char *class, const char *method,
const void *request_data,
size_t request_data_size);
extern void osd_req_op_cls_response_data(struct ceph_osd_req_op *op,
extern void osd_req_op_cls_response_data(struct ceph_osd_request *osd_req,
unsigned int which,
struct ceph_osd_data *response_data);
extern void osd_req_op_watch_init(struct ceph_osd_req_op *op, u16 opcode,
extern void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
unsigned int which, u16 opcode,
u64 cookie, u64 version, int flag);

extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
Expand Down
64 changes: 39 additions & 25 deletions trunk/net/ceph/osd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,25 +329,32 @@ static bool osd_req_opcode_valid(u16 opcode)
* other information associated with them. It also serves as a
* common init routine for all the other init functions, below.
*/
void osd_req_op_init(struct ceph_osd_req_op *op, u16 opcode)
static struct ceph_osd_req_op *
osd_req_op_init(struct ceph_osd_request *osd_req, unsigned int which,
u16 opcode)
{
struct ceph_osd_req_op *op;

BUG_ON(which >= osd_req->r_num_ops);
BUG_ON(!osd_req_opcode_valid(opcode));

op = &osd_req->r_ops[which];
memset(op, 0, sizeof (*op));

op->op = opcode;

return op;
}

void osd_req_op_extent_init(struct ceph_osd_req_op *op, u16 opcode,
void osd_req_op_extent_init(struct ceph_osd_request *osd_req,
unsigned int which, u16 opcode,
u64 offset, u64 length,
u64 truncate_size, u32 truncate_seq)
{
struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode);
size_t payload_len = 0;

BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE);

osd_req_op_init(op, opcode);

op->extent.offset = offset;
op->extent.length = length;
op->extent.truncate_size = truncate_size;
Expand All @@ -359,9 +366,15 @@ void osd_req_op_extent_init(struct ceph_osd_req_op *op, u16 opcode,
}
EXPORT_SYMBOL(osd_req_op_extent_init);

void osd_req_op_extent_update(struct ceph_osd_req_op *op, u64 length)
void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
unsigned int which, u64 length)
{
u64 previous = op->extent.length;
struct ceph_osd_req_op *op;
u64 previous;

BUG_ON(which >= osd_req->r_num_ops);
op = &osd_req->r_ops[which];
previous = op->extent.length;

if (length == previous)
return; /* Nothing to do */
Expand All @@ -372,24 +385,25 @@ void osd_req_op_extent_update(struct ceph_osd_req_op *op, u64 length)
}
EXPORT_SYMBOL(osd_req_op_extent_update);

void osd_req_op_extent_osd_data(struct ceph_osd_req_op *op,
void osd_req_op_extent_osd_data(struct ceph_osd_request *osd_req,
unsigned int which,
struct ceph_osd_data *osd_data)
{
op->extent.osd_data = osd_data;
BUG_ON(which >= osd_req->r_num_ops);
osd_req->r_ops[which].extent.osd_data = osd_data;
}
EXPORT_SYMBOL(osd_req_op_extent_osd_data);

void osd_req_op_cls_init(struct ceph_osd_req_op *op, u16 opcode,
const char *class, const char *method,
void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
u16 opcode, const char *class, const char *method,
const void *request_data, size_t request_data_size)
{
struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode);
size_t payload_len = 0;
size_t size;

BUG_ON(opcode != CEPH_OSD_OP_CALL);

osd_req_op_init(op, opcode);

op->cls.class_name = class;
size = strlen(class);
BUG_ON(size > (size_t) U8_MAX);
Expand All @@ -412,26 +426,28 @@ void osd_req_op_cls_init(struct ceph_osd_req_op *op, u16 opcode,
op->payload_len = payload_len;
}
EXPORT_SYMBOL(osd_req_op_cls_init);

void osd_req_op_cls_response_data(struct ceph_osd_req_op *op,
void osd_req_op_cls_response_data(struct ceph_osd_request *osd_req,
unsigned int which,
struct ceph_osd_data *response_data)
{
op->cls.response_data = response_data;
BUG_ON(which >= osd_req->r_num_ops);
osd_req->r_ops[which].cls.response_data = response_data;
}
EXPORT_SYMBOL(osd_req_op_cls_response_data);

void osd_req_op_watch_init(struct ceph_osd_req_op *op, u16 opcode,
void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
unsigned int which, u16 opcode,
u64 cookie, u64 version, int flag)
{
BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH);
struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode);

osd_req_op_init(op, opcode);
BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH);

op->watch.cookie = cookie;
/* op->watch.ver = version; */ /* XXX 3847 */
op->watch.ver = cpu_to_le64(version);
if (opcode == CEPH_OSD_OP_WATCH && flag)
op->watch.flag = (u8) 1;
op->watch.flag = (u8)1;
}
EXPORT_SYMBOL(osd_req_op_watch_init);

Expand Down Expand Up @@ -629,7 +645,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
{
struct ceph_osd_request *req;
struct ceph_osd_data *osd_data;
struct ceph_osd_req_op *op;
u64 objnum = 0;
u64 objoff = 0;
u64 objlen = 0;
Expand Down Expand Up @@ -665,18 +680,17 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
truncate_size = object_size;
}

op = &req->r_ops[0];
osd_req_op_extent_init(op, opcode, objoff, objlen,
osd_req_op_extent_init(req, 0, opcode, objoff, objlen,
truncate_size, truncate_seq);
osd_req_op_extent_osd_data(op, osd_data);
osd_req_op_extent_osd_data(req, 0, osd_data);

/*
* A second op in the ops array means the caller wants to
* also issue a include a 'startsync' command so that the
* osd will flush data quickly.
*/
if (num_ops > 1)
osd_req_op_init(++op, CEPH_OSD_OP_STARTSYNC);
osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC);

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

Expand Down

0 comments on commit 73e1a4d

Please sign in to comment.