summaryrefslogtreecommitdiff
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-04-05 10:27:11 +0400
committerSage Weil <sage@inktank.com>2013-05-02 08:18:15 +0400
commitc99d2d4abb6c405ef52e9bc1da87b382b8f41739 (patch)
tree073ad414ec82f706a38300d38fe5c5a710d3098a /net/ceph
parent8c042b0df99cd06ef8473ef6e204b87b3dc80158 (diff)
downloadlinux-c99d2d4abb6c405ef52e9bc1da87b382b8f41739.tar.xz
libceph: specify osd op by index in request
An osd request now holds all of its source op structures, and every place that initializes one of these is in fact initializing one of the entries in the the osd request's array. So rather than supplying the address of the op to initialize, have caller specify the osd request and an indication of which op it would like to initialize. This better hides the details the op structure (and faciltates moving the data pointers they use). Since osd_req_op_init() is a common routine, and it's not used outside the osd client code, give it static scope. Also make it return the address of the specified op (so all the other init routines don't have to repeat that code). Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/osd_client.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 23491e92b229..ad24f210bf0c 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -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;
@@ -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 */
@@ -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);
@@ -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);
@@ -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;
@@ -665,10 +680,9 @@ 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
@@ -676,7 +690,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
* 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 */