Commit d3798acc authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: support for alloc hint flags

Allow indicating future I/O pattern via flags.  This is supported since
Kraken (and bluestore persists flags together with expected_object_size
and expected_write_size).
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarJason Dillaman <dillaman@redhat.com>
parent 8ad44d5e
...@@ -2253,7 +2253,8 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req, ...@@ -2253,7 +2253,8 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) {
osd_req_op_alloc_hint_init(osd_req, which++, osd_req_op_alloc_hint_init(osd_req, which++,
rbd_dev->layout.object_size, rbd_dev->layout.object_size,
rbd_dev->layout.object_size); rbd_dev->layout.object_size,
0);
} }
if (rbd_obj_is_entire(obj_req)) if (rbd_obj_is_entire(obj_req))
......
...@@ -136,6 +136,7 @@ struct ceph_osd_req_op { ...@@ -136,6 +136,7 @@ struct ceph_osd_req_op {
struct { struct {
u64 expected_object_size; u64 expected_object_size;
u64 expected_write_size; u64 expected_write_size;
u32 flags; /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
} alloc_hint; } alloc_hint;
struct { struct {
u64 snapid; u64 snapid;
...@@ -472,7 +473,8 @@ extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int ...@@ -472,7 +473,8 @@ extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int
extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
unsigned int which, unsigned int which,
u64 expected_object_size, u64 expected_object_size,
u64 expected_write_size); u64 expected_write_size,
u32 flags);
extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
struct ceph_snap_context *snapc, struct ceph_snap_context *snapc,
......
...@@ -464,6 +464,19 @@ enum { ...@@ -464,6 +464,19 @@ enum {
const char *ceph_osd_watch_op_name(int o); const char *ceph_osd_watch_op_name(int o);
enum {
CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_WRITE = 1,
CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE = 2,
CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_READ = 8,
CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY = 16,
CEPH_OSD_ALLOC_HINT_FLAG_IMMUTABLE = 32,
CEPH_OSD_ALLOC_HINT_FLAG_SHORTLIVED = 64,
CEPH_OSD_ALLOC_HINT_FLAG_LONGLIVED = 128,
CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE = 256,
CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE = 512,
};
enum { enum {
CEPH_OSD_BACKOFF_OP_BLOCK = 1, CEPH_OSD_BACKOFF_OP_BLOCK = 1,
CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2, CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2,
...@@ -517,6 +530,7 @@ struct ceph_osd_op { ...@@ -517,6 +530,7 @@ struct ceph_osd_op {
struct { struct {
__le64 expected_object_size; __le64 expected_object_size;
__le64 expected_write_size; __le64 expected_write_size;
__le32 flags; /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
} __attribute__ ((packed)) alloc_hint; } __attribute__ ((packed)) alloc_hint;
struct { struct {
__le64 snapid; __le64 snapid;
......
...@@ -932,10 +932,14 @@ static void osd_req_op_watch_init(struct ceph_osd_request *req, int which, ...@@ -932,10 +932,14 @@ static void osd_req_op_watch_init(struct ceph_osd_request *req, int which,
op->watch.gen = 0; op->watch.gen = 0;
} }
/*
* @flags: CEPH_OSD_OP_ALLOC_HINT_FLAG_*
*/
void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
unsigned int which, unsigned int which,
u64 expected_object_size, u64 expected_object_size,
u64 expected_write_size) u64 expected_write_size,
u32 flags)
{ {
struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which, struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which,
CEPH_OSD_OP_SETALLOCHINT, CEPH_OSD_OP_SETALLOCHINT,
...@@ -943,6 +947,7 @@ void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, ...@@ -943,6 +947,7 @@ void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
op->alloc_hint.expected_object_size = expected_object_size; op->alloc_hint.expected_object_size = expected_object_size;
op->alloc_hint.expected_write_size = expected_write_size; op->alloc_hint.expected_write_size = expected_write_size;
op->alloc_hint.flags = flags;
/* /*
* CEPH_OSD_OP_SETALLOCHINT op is advisory and therefore deemed * CEPH_OSD_OP_SETALLOCHINT op is advisory and therefore deemed
...@@ -1018,6 +1023,7 @@ static u32 osd_req_encode_op(struct ceph_osd_op *dst, ...@@ -1018,6 +1023,7 @@ static u32 osd_req_encode_op(struct ceph_osd_op *dst,
cpu_to_le64(src->alloc_hint.expected_object_size); cpu_to_le64(src->alloc_hint.expected_object_size);
dst->alloc_hint.expected_write_size = dst->alloc_hint.expected_write_size =
cpu_to_le64(src->alloc_hint.expected_write_size); cpu_to_le64(src->alloc_hint.expected_write_size);
dst->alloc_hint.flags = cpu_to_le32(src->alloc_hint.flags);
break; break;
case CEPH_OSD_OP_SETXATTR: case CEPH_OSD_OP_SETXATTR:
case CEPH_OSD_OP_CMPXATTR: case CEPH_OSD_OP_CMPXATTR:
......
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