[sheepdog] [PATCH] sheep/http: remove the kv_update_object

Liu Yuan namei.unix at gmail.com
Wed Dec 18 18:16:22 CET 2013


Both swift and s3 don't have API to update the existing object, it purely
overwrite the whole objects. So no need to maintain this unused code.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/http/http.h |    2 --
 sheep/http/kv.c   |   84 -----------------------------------------------------
 2 files changed, 86 deletions(-)

diff --git a/sheep/http/http.h b/sheep/http/http.h
index e541d0e..a2f404c 100644
--- a/sheep/http/http.h
+++ b/sheep/http/http.h
@@ -139,8 +139,6 @@ int kv_create_object(struct http_request *req, const char *account,
 		     const char *bucket, const char *object);
 int kv_read_object(struct http_request *req, const char *account,
 		   const char *bucket, const char *object);
-int kv_update_object(struct http_request *req, const char *bucket,
-		     const char *object);
 int kv_delete_object(struct http_request *req, const char *account,
 		     const char *bucket, const char *object);
 int kv_list_objects(struct http_request *req, const char *account,
diff --git a/sheep/http/kv.c b/sheep/http/kv.c
index d94608a..7a826f7 100644
--- a/sheep/http/kv.c
+++ b/sheep/http/kv.c
@@ -1239,90 +1239,6 @@ out:
 	return ret;
 }
 
-static int do_kv_update_object(struct http_request *req, const char *obj_name,
-			       struct kv_onode *obj, uint32_t vid,
-			       uint32_t idx, size_t size)
-{
-	uint64_t oid = vid_to_data_oid(vid, idx);
-	int ret;
-
-	ret = sd_read_object(oid, (char *)&obj->hdr, sizeof(obj->hdr), 0);
-	switch (ret) {
-	case SD_RES_SUCCESS:
-		break;
-	case SD_RES_NO_VDI:
-		sd_info("object %s doesn't exist", obj_name);
-		http_response_header(req, NOT_FOUND);
-		return -1;
-	default:
-		sd_err("failed to read %s, %s", req->uri, sd_strerror(ret));
-		http_response_header(req, INTERNAL_SERVER_ERROR);
-		return -1;
-	}
-
-	if (strcmp(obj->hdr.name, obj_name) == 0) {
-		struct timeval tv;
-
-		gettimeofday(&tv, NULL);
-		obj->hdr.mtime = (uint64_t) tv.tv_sec << 32 | tv.tv_usec * 1000;
-		obj->hdr.size = size;
-
-		ret = sd_write_object(oid, (char *)obj,
-				      sizeof(obj->hdr) + obj->hdr.size,
-				      0, false);
-		if (ret == SD_RES_SUCCESS)
-			http_response_header(req, ACCEPTED);
-		else {
-			sd_err("failed to update object, %" PRIx64, oid);
-			http_response_header(req, INTERNAL_SERVER_ERROR);
-			return -1;
-		}
-	}
-
-	return 0;
-}
-
-int kv_update_object(struct http_request *req, const char *bucket,
-		     const char *object)
-{
-	struct kv_onode *obj;
-	int ret;
-	uint64_t hval;
-	uint32_t vid;
-	ssize_t size;
-
-	ret = lookup_bucket(req, bucket, &vid);
-	if (ret < 0)
-		return ret;
-
-	obj = xzalloc(sizeof(*obj));
-
-	/* TODO: support multi parted object for large object */
-	size = http_request_read(req, obj->data, sizeof(obj->data));
-	if (size < 0) {
-		sd_err("%s: bucket %s, object %s", sd_strerror(ret),
-		       bucket, object);
-		http_response_header(req, INTERNAL_SERVER_ERROR);
-		return -1;
-	}
-
-	hval = sd_hash(object, strlen(object));
-	for (int i = 0; i < MAX_DATA_OBJS; i++) {
-		uint32_t idx = (hval + i) % MAX_DATA_OBJS;
-
-		do_kv_update_object(req, object, obj, vid, idx, size);
-		if (req->status != UNKNOWN) {
-			free(obj);
-			return 0;
-		}
-	}
-
-	free(obj);
-
-	http_response_header(req, NOT_FOUND);
-	return -1;
-}
-
 static int do_kv_delete_object(struct http_request *req, const char *obj_name,
 			       uint32_t vid, uint32_t idx)
 {
-- 
1.7.9.5




More information about the sheepdog mailing list