summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Durgin <josh.durgin@inktank.com>2012-12-13 08:30:22 -0800
committerJosh Durgin <josh.durgin@inktank.com>2012-12-13 08:30:22 -0800
commit83ee85b8405e9eef9c0cc9e7a551c8ff3d29870c (patch)
tree07dad6748f6b227720c1cf26440ffd3b825d5125
parent4605fddcf66258ec65a0d937143812b98246ff46 (diff)
parente6dd0681d162d46fb4d6b9ed204c7a742676294a (diff)
downloadceph-83ee85b8405e9eef9c0cc9e7a551c8ff3d29870c.tar.gz
Merge remote branch 'origin/next'
-rw-r--r--ceph.spec.in1
-rw-r--r--debian/ceph-fuse.install1
-rw-r--r--doc/radosgw/config-ref.rst10
-rwxr-xr-xqa/workunits/rbd/map-unmap.sh2
-rw-r--r--src/Makefile.am6
-rw-r--r--src/auth/cephx/CephxProtocol.h9
-rw-r--r--src/common/config_opts.h2
-rw-r--r--src/init-ceph.in2
-rwxr-xr-xsrc/mount.fuse.ceph26
-rw-r--r--src/rgw/rgw_main.cc2
-rw-r--r--src/rgw/rgw_rest.cc117
-rw-r--r--src/rgw/rgw_rest.h2
-rw-r--r--src/rgw/rgw_rest_s3.cc15
13 files changed, 175 insertions, 20 deletions
diff --git a/ceph.spec.in b/ceph.spec.in
index 3a369cf5359..ba1cce459bc 100644
--- a/ceph.spec.in
+++ b/ceph.spec.in
@@ -356,6 +356,7 @@ fi
%defattr(-,root,root,-)
%{_bindir}/ceph-fuse
%{_mandir}/man8/ceph-fuse.8*
+/sbin/mount.fuse.ceph
#################################################################################
%files devel
diff --git a/debian/ceph-fuse.install b/debian/ceph-fuse.install
index b8dd3b32d63..79588d2a629 100644
--- a/debian/ceph-fuse.install
+++ b/debian/ceph-fuse.install
@@ -1,2 +1,3 @@
usr/bin/ceph-fuse
usr/share/man/man8/ceph-fuse.8
+sbin/mount.fuse.ceph
diff --git a/doc/radosgw/config-ref.rst b/doc/radosgw/config-ref.rst
index 213fa4eb028..b8530b428cb 100644
--- a/doc/radosgw/config-ref.rst
+++ b/doc/radosgw/config-ref.rst
@@ -206,21 +206,31 @@ set automatically.
``rgw enable ops log``
+
:Description: Whether rgw will log each successful operation
:Type: Boolean
:Default: ``true``
``rgw ops log rados``
+
:Description: Whether rgw operations logging should be written into the RADOS backend
:Type: Boolean
:Default: ``true``
``rgw ops log socket path``
+
:Description: The path of a unix domain socket to which operations logging data will be written.
:Type: String
:Default: N/A
``rgw ops log data backlog``
+
:Description: Total backlog data size for unix domain socket operations logging
:Type: Integer
:Default: ``5ul << 20``
+
+``rgw extended http attrs``
+:Description: Add new set of attributes that could be set on an object. These extra attributes can be set through HTTP header fields when putting the objects. If set, these attributes will return as HTTP fields when doing GET/HEAD on the object.
+:Type: String
+:Default: N/A
+:Example: "content_foo, content_bar"
diff --git a/qa/workunits/rbd/map-unmap.sh b/qa/workunits/rbd/map-unmap.sh
index 9ecc226e5f5..417f95580bf 100755
--- a/qa/workunits/rbd/map-unmap.sh
+++ b/qa/workunits/rbd/map-unmap.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash -ex
RUN_TIME=300 # approximate duration of run (seconds)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a9759f8fdf..1497b9dd341 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,7 +29,8 @@ sbin_PROGRAMS =
sbin_SCRIPTS = \
ceph-disk-prepare \
ceph-disk-activate \
- ceph-create-keys
+ ceph-create-keys \
+ mount.fuse.ceph
bin_SCRIPTS = ceph-run $(srcdir)/ceph-clsinfo ceph-debugpack ceph-rbdnamer
dist_bin_SCRIPTS =
# C/C++ tests to build will be appended to this
@@ -1100,7 +1101,8 @@ EXTRA_DIST += \
$(srcdir)/upstart/radosgw-all-starter.conf \
ceph-disk-prepare \
ceph-disk-activate \
- ceph-create-keys
+ ceph-create-keys \
+ mount.fuse.ceph
EXTRA_DIST += $(srcdir)/$(shell_scripts:%=%.in)
diff --git a/src/auth/cephx/CephxProtocol.h b/src/auth/cephx/CephxProtocol.h
index dfa2b2f0896..38e0616b501 100644
--- a/src/auth/cephx/CephxProtocol.h
+++ b/src/auth/cephx/CephxProtocol.h
@@ -470,8 +470,13 @@ int decode_decrypt(CephContext *cct, T& t, const CryptoKey key,
bufferlist::iterator& iter, std::string &error)
{
bufferlist bl_enc;
- ::decode(bl_enc, iter);
- decode_decrypt_enc_bl(cct, t, key, bl_enc, error);
+ try {
+ ::decode(bl_enc, iter);
+ decode_decrypt_enc_bl(cct, t, key, bl_enc, error);
+ }
+ catch (buffer::error e) {
+ error = "error decoding block for decryption";
+ }
if (!error.empty())
return CEPHX_CRYPT_ERR;
return 0;
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index b04a28f3259..b9e317b82dc 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -483,8 +483,10 @@ OPTION(rgw_gc_max_objs, OPT_INT, 32)
OPTION(rgw_gc_obj_min_wait, OPT_INT, 2 * 3600) // wait time before object may be handled by gc
OPTION(rgw_gc_processor_max_time, OPT_INT, 3600) // total run time for a single gc processor work
OPTION(rgw_gc_processor_period, OPT_INT, 3600) // gc processor cycle time
+OPTION(rgw_s3_success_create_obj_status, OPT_INT, 0) // alternative success status response for create-obj (0 - default)
OPTION(rgw_resolve_cname, OPT_BOOL, false) // should rgw try to resolve hostname as a dns cname record
OPTION(rgw_obj_stripe_size, OPT_INT, 4 << 20)
+OPTION(rgw_extended_http_attrs, OPT_STR, "") // list of extended attrs that can be set on objects (beyond the default)
OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter
diff --git a/src/init-ceph.in b/src/init-ceph.in
index 788d7172979..b75f639a359 100644
--- a/src/init-ceph.in
+++ b/src/init-ceph.in
@@ -277,7 +277,7 @@ for name in $what; do
# try to fallback to to old keys
get_conf tmp_devs "" "btrfs devs"
if [ -n "$tmp_devs" ]; then
- fs_type = "btrfs"
+ fs_type="btrfs"
else
echo No filesystem type defined!
exit 0
diff --git a/src/mount.fuse.ceph b/src/mount.fuse.ceph
new file mode 100755
index 00000000000..cbf2874f3bd
--- /dev/null
+++ b/src/mount.fuse.ceph
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# Helper to mount ceph-fuse from /etc/fstab. To use, add an entry
+# like:
+#
+# # DEVICE PATH TYPE OPTIONS
+# id=admin /mnt/ceph fuse.ceph defaults 0 0
+# id=myuser,conf=/etc/ceph/foo.conf /mnt/ceph2 fuse.ceph defaults 0 0
+#
+# where the device field is a comma-separated list of options to pass on
+# the command line. The examples above, for example, specify that
+# ceph-fuse will authenticated as client.admin and client.myuser
+# (respectively), and the second example also sets the 'conf' option to
+# '/etc/ceph/foo.conf' via the ceph-fuse command line. Any valid
+# ceph-fuse can be passed in this way.
+
+set -e
+
+# convert device string to options
+cephargs='--'`echo $1 | sed 's/,/ --/g'`
+
+# strip out 'noauto' option; libfuse doesn't like it
+opts=`echo $4 | sed 's/,noauto//' | sed 's/noauto,//'`
+
+# go
+exec ceph-fuse $cephargs $2 $3 $opts
diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc
index 5f52dde228d..29c10dd0eeb 100644
--- a/src/rgw/rgw_main.cc
+++ b/src/rgw/rgw_main.cc
@@ -433,7 +433,7 @@ int main(int argc, const char **argv)
rgw_tools_init(g_ceph_context);
rgw_init_resolver();
- rgw_rest_init();
+ rgw_rest_init(g_ceph_context);
curl_global_init(CURL_GLOBAL_ALL);
diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc
index 9d978d1a4f1..c8c0bacf0a0 100644
--- a/src/rgw/rgw_rest.cc
+++ b/src/rgw/rgw_rest.cc
@@ -3,6 +3,7 @@
#include "common/Formatter.h"
#include "common/utf8.h"
+#include "include/str_list.h"
#include "rgw_common.h"
#include "rgw_rados.h"
#include "rgw_formats.h"
@@ -37,15 +38,6 @@ static struct rgw_http_attr rgw_to_http_attr_list[] = {
};
-map<string, string> rgw_to_http_attrs;
-
-void rgw_rest_init()
-{
- for (struct rgw_http_attr *attr = rgw_to_http_attr_list; attr->rgw_attr; attr++) {
- rgw_to_http_attrs[attr->rgw_attr] = attr->http_attr;
- }
-}
-
struct generic_attr {
const char *http_header;
const char *rgw_attr;
@@ -64,6 +56,106 @@ struct generic_attr generic_attrs[] = {
{ NULL, NULL },
};
+map<string, string> rgw_to_http_attrs;
+static map<string, string> generic_attrs_map;
+
+/*
+ * make attrs look_like_this
+ */
+string lowercase_http_attr(const string& orig)
+{
+ const char *s = orig.c_str();
+ char buf[orig.size() + 1];
+ buf[orig.size()] = '\0';
+
+ for (size_t i = 0; i < orig.size(); ++i, ++s) {
+ switch (*s) {
+ case '-':
+ buf[i] = '_';
+ break;
+ default:
+ buf[i] = tolower(*s);
+ }
+ }
+ return string(buf);
+}
+
+/*
+ * make attrs LOOK_LIKE_THIS
+ */
+string uppercase_http_attr(const string& orig)
+{
+ const char *s = orig.c_str();
+ char buf[orig.size() + 1];
+ buf[orig.size()] = '\0';
+
+ for (size_t i = 0; i < orig.size(); ++i, ++s) {
+ switch (*s) {
+ case '-':
+ buf[i] = '_';
+ break;
+ default:
+ buf[i] = toupper(*s);
+ }
+ }
+ return string(buf);
+}
+
+/*
+ * make attrs Look-Like-This
+ */
+string camelcase_dash_http_attr(const string& orig)
+{
+ const char *s = orig.c_str();
+ char buf[orig.size() + 1];
+ buf[orig.size()] = '\0';
+
+ bool last_sep = true;
+
+ for (size_t i = 0; i < orig.size(); ++i, ++s) {
+ switch (*s) {
+ case '_':
+ buf[i] = '-';
+ last_sep = true;
+ break;
+ default:
+ if (last_sep)
+ buf[i] = toupper(*s);
+ else
+ buf[i] = tolower(*s);
+ last_sep = false;
+ }
+ }
+ return string(buf);
+}
+
+void rgw_rest_init(CephContext *cct)
+{
+ for (struct rgw_http_attr *attr = rgw_to_http_attr_list; attr->rgw_attr; attr++) {
+ rgw_to_http_attrs[attr->rgw_attr] = attr->http_attr;
+ }
+
+ for (struct generic_attr *gen_attr = generic_attrs; gen_attr->http_header; gen_attr++) {
+ generic_attrs_map[gen_attr->http_header] = gen_attr->rgw_attr;
+ }
+
+ list<string> extended_http_attrs;
+ get_str_list(cct->_conf->rgw_extended_http_attrs, extended_http_attrs);
+
+ list<string>::iterator iter;
+ for (iter = extended_http_attrs.begin(); iter != extended_http_attrs.end(); ++iter) {
+ string rgw_attr = RGW_ATTR_PREFIX;
+ rgw_attr.append(lowercase_http_attr(*iter));
+
+ rgw_to_http_attrs[rgw_attr] = camelcase_dash_http_attr(*iter);
+
+ string http_header = "HTTP_";
+ http_header.append(uppercase_http_attr(*iter));
+
+ generic_attrs_map[http_header] = rgw_attr;
+ }
+}
+
static void dump_status(struct req_state *s, const char *status)
{
int r = s->cio->print("Status: %s\n", status);
@@ -1075,10 +1167,11 @@ int RGWREST::preprocess(struct req_state *s, RGWClientIO *cio)
s->content_length = atoll(s->length);
}
- for (int i = 0; generic_attrs[i].http_header; i++) {
- const char *env = s->env->get(generic_attrs[i].http_header);
+ map<string, string>::iterator giter;
+ for (giter = generic_attrs_map.begin(); giter != generic_attrs_map.end(); ++giter) {
+ const char *env = s->env->get(giter->first.c_str());
if (env) {
- s->generic_attrs[generic_attrs[i].rgw_attr] = env;
+ s->generic_attrs[giter->second] = env;
}
}
diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h
index 35c34a6cdba..00ad584575e 100644
--- a/src/rgw/rgw_rest.h
+++ b/src/rgw/rgw_rest.h
@@ -8,7 +8,7 @@
extern std::map<std::string, std::string> rgw_to_http_attrs;
-extern void rgw_rest_init();
+extern void rgw_rest_init(CephContext *cct);
extern void rgw_flush_formatter_and_reset(struct req_state *s,
ceph::Formatter *formatter);
diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc
index f200db847fa..b2925940f77 100644
--- a/src/rgw/rgw_rest_s3.cc
+++ b/src/rgw/rgw_rest_s3.cc
@@ -352,11 +352,26 @@ int RGWPutObj_ObjStore_S3::get_params()
return RGWPutObj_ObjStore::get_params();
}
+static int get_success_retcode(int code)
+{
+ switch (code) {
+ case 201:
+ return STATUS_CREATED;
+ case 204:
+ return STATUS_NO_CONTENT;
+ }
+ return 0;
+}
+
void RGWPutObj_ObjStore_S3::send_response()
{
if (ret) {
set_req_state_err(s, ret);
} else {
+ if (s->cct->_conf->rgw_s3_success_create_obj_status) {
+ ret = get_success_retcode(s->cct->_conf->rgw_s3_success_create_obj_status);
+ set_req_state_err(s, ret);
+ }
dump_etag(s, etag.c_str());
dump_content_length(s, 0);
}