]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: return 423 Locked response when failing to lock object
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 9 Aug 2013 18:52:25 +0000 (11:52 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 9 Aug 2013 19:49:10 +0000 (12:49 -0700)
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>
src/rgw/rgw_common.h
src/rgw/rgw_http_errors.h
src/rgw/rgw_rest_log.cc
src/rgw/rgw_rest_metadata.cc

index 8e4126de271884d52816167e8fe8a9e409781167..8baee258d9059689ef75ba6c85f25551ea4657b5 100644 (file)
@@ -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
 
index 1eb4e12e695cf514b27dd3a563b22e2cfcd682dd..6cb9fabf6c0e0393bd55d2380853f4bcad8e99da 100644 (file)
@@ -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" },
 };
 
index 7b50986cb374bd921220ea37eedb4db77f73707a..74e3c445ee935f6052942090c9dce0e0ab21abc3 100644 (file)
@@ -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() {
index de33df17446a9a45c5c81dde16bdea95d4f6f3ef..fc1d6ded1669c32443015a74abbd1842989024ee 100644 (file)
@@ -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() {