Skip to content

Commit d3798ac

Browse files
committed
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: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Jason Dillaman <dillaman@redhat.com>
1 parent 8ad44d5 commit d3798ac

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎drivers/block/rbd.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,8 @@ static void __rbd_osd_setup_write_ops(struct ceph_osd_request *osd_req,
22532253
!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) {
22542254
osd_req_op_alloc_hint_init(osd_req, which++,
22552255
rbd_dev->layout.object_size,
2256-
rbd_dev->layout.object_size);
2256+
rbd_dev->layout.object_size,
2257+
0);
22572258
}
22582259

22592260
if (rbd_obj_is_entire(obj_req))

‎include/linux/ceph/osd_client.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct ceph_osd_req_op {
136136
struct {
137137
u64 expected_object_size;
138138
u64 expected_write_size;
139+
u32 flags; /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
139140
} alloc_hint;
140141
struct {
141142
u64 snapid;
@@ -472,7 +473,8 @@ extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int
472473
extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
473474
unsigned int which,
474475
u64 expected_object_size,
475-
u64 expected_write_size);
476+
u64 expected_write_size,
477+
u32 flags);
476478

477479
extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
478480
struct ceph_snap_context *snapc,

‎include/linux/ceph/rados.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,19 @@ enum {
464464

465465
const char *ceph_osd_watch_op_name(int o);
466466

467+
enum {
468+
CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_WRITE = 1,
469+
CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE = 2,
470+
CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
471+
CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_READ = 8,
472+
CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY = 16,
473+
CEPH_OSD_ALLOC_HINT_FLAG_IMMUTABLE = 32,
474+
CEPH_OSD_ALLOC_HINT_FLAG_SHORTLIVED = 64,
475+
CEPH_OSD_ALLOC_HINT_FLAG_LONGLIVED = 128,
476+
CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE = 256,
477+
CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE = 512,
478+
};
479+
467480
enum {
468481
CEPH_OSD_BACKOFF_OP_BLOCK = 1,
469482
CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2,
@@ -517,6 +530,7 @@ struct ceph_osd_op {
517530
struct {
518531
__le64 expected_object_size;
519532
__le64 expected_write_size;
533+
__le32 flags; /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
520534
} __attribute__ ((packed)) alloc_hint;
521535
struct {
522536
__le64 snapid;

‎net/ceph/osd_client.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,17 +932,22 @@ static void osd_req_op_watch_init(struct ceph_osd_request *req, int which,
932932
op->watch.gen = 0;
933933
}
934934

935+
/*
936+
* @flags: CEPH_OSD_OP_ALLOC_HINT_FLAG_*
937+
*/
935938
void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
936939
unsigned int which,
937940
u64 expected_object_size,
938-
u64 expected_write_size)
941+
u64 expected_write_size,
942+
u32 flags)
939943
{
940944
struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which,
941945
CEPH_OSD_OP_SETALLOCHINT,
942946
0);
943947

944948
op->alloc_hint.expected_object_size = expected_object_size;
945949
op->alloc_hint.expected_write_size = expected_write_size;
950+
op->alloc_hint.flags = flags;
946951

947952
/*
948953
* 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,
10181023
cpu_to_le64(src->alloc_hint.expected_object_size);
10191024
dst->alloc_hint.expected_write_size =
10201025
cpu_to_le64(src->alloc_hint.expected_write_size);
1026+
dst->alloc_hint.flags = cpu_to_le32(src->alloc_hint.flags);
10211027
break;
10221028
case CEPH_OSD_OP_SETXATTR:
10231029
case CEPH_OSD_OP_CMPXATTR:

0 commit comments

Comments
 (0)