From 435f68a0e8d07a428b3ca5ed5029c9a649bfd71b Mon Sep 17 00:00:00 2001
From: Mike Christie <michaelc@cs.wisc.edu>
Date: Wed, 29 Jul 2015 04:23:44 -0500
Subject: [PATCH] rbd: add num ops calculator helper
References: fate#318836
Patch-mainline: Not yet, SES2 clustered LIO/RBD
The next patches add new commands that have different
number of ops, so this adds a helper.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: David Disseldorp <ddiss@suse.de>
---
drivers/block/rbd.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -887,6 +887,16 @@ static int parse_rbd_opts_token(char *c,
return 0;
}
+static int obj_num_ops(enum obj_operation_type op_type)
+{
+ switch (op_type) {
+ case OBJ_OP_WRITE:
+ return 2;
+ default:
+ return 1;
+ }
+}
+
static char* obj_op_name(enum obj_operation_type op_type)
{
switch (op_type) {
@@ -2037,7 +2047,7 @@ static struct ceph_osd_request *rbd_osd_
snapc = img_request->snapc;
}
- rbd_assert(num_ops == 1 || ((op_type == OBJ_OP_WRITE) && num_ops == 2));
+ rbd_assert(num_ops == 1 || obj_num_ops(op_type) == num_ops);
return __rbd_osd_req_create(rbd_dev, snapc, num_ops,
(op_type == OBJ_OP_WRITE || op_type == OBJ_OP_DISCARD) ?
@@ -2576,8 +2586,7 @@ static int rbd_img_request_fill(struct r
}
osd_req = rbd_osd_req_create(rbd_dev, op_type,
- (op_type == OBJ_OP_WRITE) ? 2 : 1,
- obj_request);
+ obj_num_ops(op_type), obj_request);
if (!osd_req)
goto out_unwind;