Commit fbfab539 authored by Alex Elder's avatar Alex Elder

libceph: allow STAT osd operations

Add support for CEPH_OSD_OP_STAT operations in the osd client
and in rbd.

This operation sends no data to the osd; everything required is
encoded in identity of the target object.

The result will be ENOENT if the object doesn't exist.  If it does
exist and no other error occurs the server returns the size and last
modification time of the target object as output data (in little
endian format).  The size is a 64 bit unsigned and the time is
ceph_timespec structure (two unsigned 32-bit integers, representing
a seconds and nanoseconds value).

This resolves:
    http://tracker.ceph.com/issues/4007Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
parent ef06f4d3
...@@ -1148,6 +1148,8 @@ struct ceph_osd_req_op *rbd_osd_req_op_create(u16 opcode, ...) ...@@ -1148,6 +1148,8 @@ struct ceph_osd_req_op *rbd_osd_req_op_create(u16 opcode, ...)
if (opcode == CEPH_OSD_OP_WRITE) if (opcode == CEPH_OSD_OP_WRITE)
op->payload_len = op->extent.length; op->payload_len = op->extent.length;
break; break;
case CEPH_OSD_OP_STAT:
break;
case CEPH_OSD_OP_CALL: case CEPH_OSD_OP_CALL:
/* rbd_osd_req_op_create(CALL, class, method, data, datalen) */ /* rbd_osd_req_op_create(CALL, class, method, data, datalen) */
op->cls.class_name = va_arg(args, char *); op->cls.class_name = va_arg(args, char *);
...@@ -1277,6 +1279,16 @@ static void rbd_osd_write_callback(struct rbd_obj_request *obj_request, ...@@ -1277,6 +1279,16 @@ static void rbd_osd_write_callback(struct rbd_obj_request *obj_request,
obj_request_done_set(obj_request); obj_request_done_set(obj_request);
} }
/*
* For a simple stat call there's nothing to do. We'll do more if
* this is part of a write sequence for a layered image.
*/
static void rbd_osd_stat_callback(struct rbd_obj_request *obj_request,
struct ceph_osd_op *op)
{
obj_request_done_set(obj_request);
}
static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
struct ceph_msg *msg) struct ceph_msg *msg)
{ {
...@@ -1307,6 +1319,9 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, ...@@ -1307,6 +1319,9 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
case CEPH_OSD_OP_WRITE: case CEPH_OSD_OP_WRITE:
rbd_osd_write_callback(obj_request, op); rbd_osd_write_callback(obj_request, op);
break; break;
case CEPH_OSD_OP_STAT:
rbd_osd_stat_callback(obj_request, op);
break;
case CEPH_OSD_OP_CALL: case CEPH_OSD_OP_CALL:
case CEPH_OSD_OP_NOTIFY_ACK: case CEPH_OSD_OP_NOTIFY_ACK:
case CEPH_OSD_OP_WATCH: case CEPH_OSD_OP_WATCH:
......
...@@ -220,6 +220,8 @@ static void osd_req_encode_op(struct ceph_osd_request *req, ...@@ -220,6 +220,8 @@ static void osd_req_encode_op(struct ceph_osd_request *req,
dst->op = cpu_to_le16(src->op); dst->op = cpu_to_le16(src->op);
switch (src->op) { switch (src->op) {
case CEPH_OSD_OP_STAT:
break;
case CEPH_OSD_OP_READ: case CEPH_OSD_OP_READ:
case CEPH_OSD_OP_WRITE: case CEPH_OSD_OP_WRITE:
dst->extent.offset = dst->extent.offset =
...@@ -255,7 +257,6 @@ static void osd_req_encode_op(struct ceph_osd_request *req, ...@@ -255,7 +257,6 @@ static void osd_req_encode_op(struct ceph_osd_request *req,
pr_err("unrecognized osd opcode %d\n", dst->op); pr_err("unrecognized osd opcode %d\n", dst->op);
WARN_ON(1); WARN_ON(1);
break; break;
case CEPH_OSD_OP_STAT:
case CEPH_OSD_OP_MAPEXT: case CEPH_OSD_OP_MAPEXT:
case CEPH_OSD_OP_MASKTRUNC: case CEPH_OSD_OP_MASKTRUNC:
case CEPH_OSD_OP_SPARSE_READ: case CEPH_OSD_OP_SPARSE_READ:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment