summaryrefslogtreecommitdiffstats
path: root/src/cls
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@redhat.com>2014-12-18 22:19:22 +0100
committerYehuda Sadeh <yehuda@redhat.com>2015-01-20 00:57:57 +0100
commit4e82209a8aaca24a21345a46cd05671d7335da33 (patch)
tree8e2173eadce68c8c1f7609165e65602603fa5b6a /src/cls
parentrgw: limit print length of bufferlist buffer (diff)
downloadceph-4e82209a8aaca24a21345a46cd05671d7335da33.tar.xz
ceph-4e82209a8aaca24a21345a46cd05671d7335da33.zip
cls_rgw: only maintain object if there are preserved xattrs
rgw.obj_remove op doesn't need to keep the object around if there aren't preserved xattrs found. Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src/cls')
-rw-r--r--src/cls/rgw/cls_rgw.cc48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc
index d0b33c39542..9b05da1f67a 100644
--- a/src/cls/rgw/cls_rgw.cc
+++ b/src/cls/rgw/cls_rgw.cc
@@ -1813,19 +1813,6 @@ static int rgw_obj_remove(cls_method_context_t hctx, bufferlist *in, bufferlist
return ret;
}
- CLS_LOG(20, "%s(): removing object", __func__);
- ret = cls_cxx_remove(hctx);
- if (ret < 0) {
- CLS_LOG(0, "ERROR: %s(): cls_cxx_remove returned %d", __func__, ret);
- return ret;
- }
-
- ret = cls_cxx_create(hctx, false);
- if (ret < 0) {
- CLS_LOG(0, "ERROR: %s(): cls_cxx_create returned %d", __func__, ret);
- return ret;
- }
-
map<string, bufferlist> new_attrs;
for (list<string>::iterator iter = op.keep_attr_prefixes.begin();
iter != op.keep_attr_prefixes.end(); ++iter) {
@@ -1839,16 +1826,39 @@ static int rgw_obj_remove(cls_method_context_t hctx, bufferlist *in, bufferlist
break;
}
- ret = cls_cxx_setxattr(hctx, attr.c_str(), &aiter->second);
- CLS_LOG(20, "%s(): setting attr: %s", __func__, attr.c_str());
- if (ret < 0) {
- CLS_LOG(0, "ERROR: %s(): cls_cxx_setxattr (attr=%s) returned %d", __func__, attr.c_str(), ret);
- return ret;
- }
+ new_attrs[attr] = aiter->second;
}
}
+ CLS_LOG(20, "%s(): removing object", __func__);
+ ret = cls_cxx_remove(hctx);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_remove returned %d", __func__, ret);
+ return ret;
+ }
+
+ if (new_attrs.empty()) {
+ /* no data to keep */
+ return 0;
+ }
+
+ ret = cls_cxx_create(hctx, false);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_create returned %d", __func__, ret);
+ return ret;
+ }
+
+ for (map<string, bufferlist>::iterator aiter = new_attrs.begin();
+ aiter != new_attrs.end(); ++aiter) {
+ const string& attr = aiter->first;
+ ret = cls_cxx_setxattr(hctx, attr.c_str(), &aiter->second);
+ CLS_LOG(20, "%s(): setting attr: %s", __func__, attr.c_str());
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_setxattr (attr=%s) returned %d", __func__, attr.c_str(), ret);
+ return ret;
+ }
+ }
return 0;
}