Merge remote branch 'origin/next'

This commit is contained in:
Josh Durgin 2012-12-13 08:30:22 -08:00
commit 83ee85b840
13 changed files with 175 additions and 20 deletions

View File

@ -356,6 +356,7 @@ fi
%defattr(-,root,root,-)
%{_bindir}/ceph-fuse
%{_mandir}/man8/ceph-fuse.8*
/sbin/mount.fuse.ceph
#################################################################################
%files devel

View File

@ -1,2 +1,3 @@
usr/bin/ceph-fuse
usr/share/man/man8/ceph-fuse.8
sbin/mount.fuse.ceph

View File

@ -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"

View File

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash -ex
RUN_TIME=300 # approximate duration of run (seconds)

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -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

26
src/mount.fuse.ceph Executable file
View File

@ -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

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);
}