[sheepdog] [PATCH 1/2] sheep: split do_io_request

Christoph Hellwig hch at infradead.org
Wed May 23 11:18:02 CEST 2012


Split do_io_request into a local store and a gateway version to make the
code more obvious.

Signed-off-by: Christoph Hellwig <hch at lst.de>

Index: sheepdog/sheep/sdnet.c
===================================================================
--- sheepdog.orig/sheep/sdnet.c	2012-05-18 09:47:08.311994966 +0200
+++ sheepdog/sheep/sdnet.c	2012-05-22 17:34:23.360873284 +0200
@@ -308,8 +308,13 @@ static void queue_request(struct request
 		req->vnodes = get_vnode_info();
 
 	if (is_io_op(req->op)) {
-		req->work.fn = do_io_request;
-		req->work.done = io_op_done;
+		if (req->rq.flags & SD_FLAG_CMD_IO_LOCAL) {
+			req->work.fn = do_io_request;
+			req->work.done = io_op_done;
+		} else {
+			req->work.fn = do_gateway_request;
+			req->work.done = io_op_done;
+		}
 		setup_access_to_local_objects(req);
 		if (check_request(req) < 0)
 			return;
Index: sheepdog/sheep/sheep_priv.h
===================================================================
--- sheepdog.orig/sheep/sheep_priv.h	2012-05-22 17:23:55.076857197 +0200
+++ sheepdog/sheep/sheep_priv.h	2012-05-22 17:34:36.692873626 +0200
@@ -269,6 +269,7 @@ int leave_cluster(void);
 
 void process_request_event_queues(void);
 void do_io_request(struct work *work);
+void do_gateway_request(struct work *work);
 int forward_write_obj_req(struct request *req);
 
 int read_epoch(uint32_t *epoch, uint64_t *ctime,
Index: sheepdog/sheep/store.c
===================================================================
--- sheepdog.orig/sheep/store.c	2012-05-22 17:23:55.080857198 +0200
+++ sheepdog/sheep/store.c	2012-05-22 17:36:49.916877038 +0200
@@ -410,7 +410,7 @@ void do_io_request(struct work *work)
 {
 	struct request *req = container_of(work, struct request, work);
 	uint32_t epoch;
-	int ret = SD_RES_SUCCESS;
+	int ret;
 
 	if (req->rq.flags & SD_FLAG_CMD_RECOVERY)
 		epoch = req->rq.obj.tgt_epoch;
@@ -420,27 +420,41 @@ void do_io_request(struct work *work)
 	dprintf("%x, %" PRIx64" , %u\n",
 		req->rq.opcode, req->rq.obj.oid, epoch);
 
-	if (req->rq.flags & SD_FLAG_CMD_IO_LOCAL) {
-		ret = do_local_io(req, epoch);
+	ret = do_local_io(req, epoch);
+
+	if (ret != SD_RES_SUCCESS)
+		dprintf("failed: %x, %" PRIx64" , %u, %"PRIx32"\n",
+			req->rq.opcode, req->rq.obj.oid, epoch, ret);
+	req->rp.result = ret;
+}
+
+void do_gateway_request(struct work *work)
+{
+	struct request *req = container_of(work, struct request, work);
+	int ret = SD_RES_SUCCESS;
+
+	dprintf("%x, %" PRIx64" , %u\n",
+		req->rq.opcode, req->rq.obj.oid, req->rq.epoch);
+
+	if (!sys->enable_write_cache || bypass_object_cache(req)) {
+		/* fix object consistency when we read the object for the first time */
+		if (req->check_consistency) {
+			ret = fix_object_consistency(req);
+			if (ret != SD_RES_SUCCESS)
+				goto out;
+		}
+		if (req->rq.flags & SD_FLAG_CMD_WRITE)
+			ret = forward_write_obj_req(req);
+		else
+			ret = forward_read_obj_req(req);
 	} else {
-		if (!sys->enable_write_cache || bypass_object_cache(req)) {
-			/* fix object consistency when we read the object for the first time */
-			if (req->check_consistency) {
-				ret = fix_object_consistency(req);
-				if (ret != SD_RES_SUCCESS)
-					goto out;
-			}
-			if (req->rq.flags & SD_FLAG_CMD_WRITE)
-				ret = forward_write_obj_req(req);
-			else
-				ret = forward_read_obj_req(req);
-		} else
-			ret = handle_gateway_request(req);
+		ret = handle_gateway_request(req);
 	}
+
 out:
 	if (ret != SD_RES_SUCCESS)
 		dprintf("failed: %x, %" PRIx64" , %u, %"PRIx32"\n",
-			req->rq.opcode, req->rq.obj.oid, epoch, ret);
+			req->rq.opcode, req->rq.obj.oid, req->rq.epoch, ret);
 	req->rp.result = ret;
 }
 



More information about the sheepdog mailing list