From: Yehuda Sadeh Date: Fri, 9 Aug 2013 18:52:25 +0000 (-0700) Subject: rgw: return 423 Locked response when failing to lock object X-Git-Tag: v0.67~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=068baae719b6a06487110e30b3cdcafddda0e579;p=ceph.git rgw: return 423 Locked response when failing to lock object Fixes: #5882 Translate the EBUSY we get when trying to lock a shard / object to 423 Locked response. Beforehand it was just translated to the default 500. Reviewed-by: Sage Weil Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 8e4126de2718..8baee258d905 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -127,6 +127,7 @@ using ceph::crypto::MD5; #define ERR_TOO_SMALL 2022 #define ERR_NOT_FOUND 2023 #define ERR_PERMANENT_REDIRECT 2024 +#define ERR_LOCKED 2025 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h index 1eb4e12e695c..6cb9fabf6c0e 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -47,6 +47,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = { { ERR_PRECONDITION_FAILED, 412, "PreconditionFailed" }, { ERANGE, 416, "InvalidRange" }, { ERR_UNPROCESSABLE_ENTITY, 422, "UnprocessableEntity" }, + { ERR_LOCKED, 423, "Locked" }, { ERR_INTERNAL_ERROR, 500, "InternalError" }, }; diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index 7b50986cb374..74e3c445ee93 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -228,6 +228,8 @@ void RGWOp_MDLog_Lock::execute() { } utime_t time(dur, 0); http_ret = meta_log->lock_exclusive(shard_id, time, zone_id, locker_id); + if (http_ret == -EBUSY) + http_ret = -ERR_LOCKED; } void RGWOp_MDLog_Unlock::execute() { @@ -577,6 +579,8 @@ void RGWOp_DATALog_Lock::execute() { } utime_t time(dur, 0); http_ret = store->data_log->lock_exclusive(shard_id, time, zone_id, locker_id); + if (http_ret == -EBUSY) + http_ret = -ERR_LOCKED; } void RGWOp_DATALog_Unlock::execute() { diff --git a/src/rgw/rgw_rest_metadata.cc b/src/rgw/rgw_rest_metadata.cc index de33df17446a..fc1d6ded1669 100644 --- a/src/rgw/rgw_rest_metadata.cc +++ b/src/rgw/rgw_rest_metadata.cc @@ -242,6 +242,8 @@ void RGWOp_Metadata_Lock::execute() { } utime_t time(dur, 0); http_ret = store->meta_mgr->lock_exclusive(metadata_key, time, lock_id); + if (http_ret == -EBUSY) + http_ret = -ERR_LOCKED; } void RGWOp_Metadata_Unlock::execute() {