This simplifies one of the callers a lot by not having to fake up a
struct request.

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

---
 sheep/object_cache.c |   49 ++++++++++++-------------------------------------
 1 file changed, 12 insertions(+), 37 deletions(-)

Index: sheepdog/sheep/object_cache.c
===================================================================
--- sheepdog.orig/sheep/object_cache.c	2012-07-13 12:47:14.000000000 +0200
+++ sheepdog/sheep/object_cache.c	2012-07-13 12:49:49.649897243 +0200
@@ -413,23 +413,21 @@ out:
 }
 
 static int object_cache_write_int(struct object_cache *oc, uint32_t idx,
-		struct request *req)
+		char *data, unsigned int data_length, uint64_t offset)
 {
-	struct sd_req *hdr = &req->rq;
 	struct object_cache_entry *entry;
 	uint64_t bmap = 0;
 	int ret;
 
 	dprintf("%08"PRIx32", len %"PRIu32", off %"PRIu64"\n", idx,
-		hdr->data_length, hdr->obj.offset);
+		data_length, offset);
 
 
-	ret = write_cache_object(oc->vid, idx, req->data, hdr->data_length,
-				 hdr->obj.offset);
+	ret = write_cache_object(oc->vid, idx, data, data_length, offset);
 	if (ret != SD_RES_SUCCESS)
 		return ret;
 
-	bmap = calc_object_bmap(hdr->data_length, hdr->obj.offset);
+	bmap = calc_object_bmap(data_length, offset);
 	entry = alloc_cache_entry(idx, bmap, 0);
 
 	pthread_mutex_lock(&oc->lock);
@@ -767,9 +765,11 @@ int object_cache_handle_request(struct r
 			return ret;
 	}
 
-	if (req->rq.flags & SD_FLAG_CMD_WRITE)
-		ret = object_cache_write_int(cache, idx, req);
-	else {
+	if (req->rq.flags & SD_FLAG_CMD_WRITE) {
+		ret = object_cache_write_int(cache, idx, req->data,
+					     req->rq.data_length,
+					     req->rq.obj.offset);
+	} else {
 		ret = read_cache_object(cache->vid, idx, req->data,
 					req->rq.data_length,
 					req->rq.obj.offset);
@@ -783,35 +783,10 @@ int object_cache_handle_request(struct r
 int object_cache_write(uint64_t oid, char *data, unsigned int datalen,
 		       uint64_t offset, uint16_t flags, int create)
 {
-	int ret;
-	struct request *req;
-	uint32_t vid = oid_to_vid(oid);
-	uint32_t idx = object_cache_oid_to_idx(oid);
-	struct object_cache *cache;
-
-	cache = find_object_cache(vid, 0);
-
-	req = zalloc(sizeof(*req));
-	if (!req)
-		return SD_RES_NO_MEM;
+	struct object_cache *cache = find_object_cache(oid_to_vid(oid), 0);
 
-	if (create)
-		sd_init_req(&req->rq, SD_OP_CREATE_AND_WRITE_OBJ);
-	else
-		sd_init_req(&req->rq, SD_OP_WRITE_OBJ);
-	req->rq.flags = flags | SD_FLAG_CMD_WRITE;
-	req->rq.data_length = datalen;
-
-	req->rq.obj.oid = oid;
-	req->rq.obj.offset = offset;
-
-	req->data = data;
-	req->op = get_sd_op(req->rq.opcode);
-
-	ret = object_cache_write_int(cache, idx, req);
-
-	free(req);
-	return ret;
+	return object_cache_write_int(cache, object_cache_oid_to_idx(oid),
+				      data, datalen, offset);
 }
 
 int object_cache_read(uint64_t oid, char *data, unsigned int datalen,


