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

Robin Dong robin.k.dong at gmail.com
Thu Dec 19 11:23:13 CET 2013


Reviewed-by: Robin Dong <sanbai at taobao.com>


2013/12/19 Liu Yuan <namei.unix at gmail.com>

> 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
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog
>



-- 
--
Best Regard
Robin Dong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20131219/d506c222/attachment-0004.html>


More information about the sheepdog mailing list