[PATCH 06/15] rbd: add 'done' state for rbd_obj_advance_copyup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rename 'RBD_OBJ_COPYUP_WRITE_OBJECT' to 'RBD_OBJ_COPYUP_DONE' to
signal that the state machine has completed.
With that we can rename '__RBD_OBJ_COPYUP_WRITE_OBJECT' to
'RBD_OPJ_COPYUP_WRITE_OBJECT'.

Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
---
 drivers/block/rbd.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 766d67e4d5e5..c31507a5fdd2 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -277,11 +277,11 @@ enum rbd_obj_write_state {
 };
 
 enum rbd_obj_copyup_state {
-	RBD_OBJ_COPYUP_START = 1,
+	RBD_OBJ_COPYUP_DONE,
+	RBD_OBJ_COPYUP_START,
 	RBD_OBJ_COPYUP_READ_PARENT,
 	__RBD_OBJ_COPYUP_OBJECT_MAPS,
 	RBD_OBJ_COPYUP_OBJECT_MAPS,
-	__RBD_OBJ_COPYUP_WRITE_OBJECT,
 	RBD_OBJ_COPYUP_WRITE_OBJECT,
 };
 
@@ -3294,6 +3294,8 @@ static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result)
 	int ret;
 
 again:
+	dout("%s: obj %p copyup %d pending %d\n", __func__,
+	     obj_req, obj_req->copyup_state, obj_req->pending.num_pending);
 	switch (obj_req->copyup_state) {
 	case RBD_OBJ_COPYUP_START:
 		rbd_assert(!*result);
@@ -3301,17 +3303,19 @@ static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result)
 		ret = rbd_obj_copyup_read_parent(obj_req);
 		if (ret) {
 			*result = ret;
+			obj_req->copyup_state = RBD_OBJ_COPYUP_DONE;
 			return true;
 		}
 		if (obj_req->num_img_extents)
 			obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT;
 		else
-			obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT;
+			obj_req->copyup_state = RBD_OBJ_COPYUP_DONE;
 		return false;
 	case RBD_OBJ_COPYUP_READ_PARENT:
-		if (*result)
+		if (*result) {
+			obj_req->copyup_state = RBD_OBJ_COPYUP_DONE;
 			return true;
-
+		}
 		if (is_zero_bvecs(obj_req->copyup_bvecs,
 				  rbd_obj_img_extents_bytes(obj_req))) {
 			dout("%s %p detected zeros\n", __func__, obj_req);
@@ -3329,27 +3333,30 @@ static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result)
 	case __RBD_OBJ_COPYUP_OBJECT_MAPS:
 		if (!pending_result_dec(&obj_req->pending, result))
 			return false;
+		obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS;
 		/* fall through */
 	case RBD_OBJ_COPYUP_OBJECT_MAPS:
 		if (*result) {
 			rbd_warn(rbd_dev, "snap object map update failed: %d",
 				 *result);
+			obj_req->copyup_state = RBD_OBJ_COPYUP_DONE;
 			return true;
 		}
 
 		rbd_obj_copyup_write_object(obj_req);
 		if (!obj_req->pending.num_pending) {
 			*result = obj_req->pending.result;
-			obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT;
+			obj_req->copyup_state = RBD_OBJ_COPYUP_DONE;
 			goto again;
 		}
-		obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT;
+		obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT;
 		return false;
-	case __RBD_OBJ_COPYUP_WRITE_OBJECT:
+	case RBD_OBJ_COPYUP_WRITE_OBJECT:
 		if (!pending_result_dec(&obj_req->pending, result))
 			return false;
+		obj_req->copyup_state = RBD_OBJ_COPYUP_DONE;
 		/* fall through */
-	case RBD_OBJ_COPYUP_WRITE_OBJECT:
+	case RBD_OBJ_COPYUP_DONE:
 		return true;
 	default:
 		BUG();
-- 
2.16.4




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux