summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-08-09 11:52:25 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-08-09 12:49:10 -0700
commit068baae719b6a06487110e30b3cdcafddda0e579 (patch)
treeae670b0f5eea64b7c4732aea014ffd4d0fbcc748
parent9029555f58eed34628fad88f24523b4c554750c9 (diff)
downloadceph-068baae719b6a06487110e30b3cdcafddda0e579.tar.gz
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 <sage@inktank.com> Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_common.h1
-rw-r--r--src/rgw/rgw_http_errors.h1
-rw-r--r--src/rgw/rgw_rest_log.cc4
-rw-r--r--src/rgw/rgw_rest_metadata.cc2
4 files changed, 8 insertions, 0 deletions
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index 8e4126de271..8baee258d90 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 1eb4e12e695..6cb9fabf6c0 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 7b50986cb37..74e3c445ee9 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 de33df17446..fc1d6ded166 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() {