Merge pull request #285 from dalgaaf/wip-da-CID-fixes-2-v3

Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-05-14 10:30:20 -07:00
commit 29d8ec4ecd
16 changed files with 84 additions and 32 deletions

View File

@ -31,7 +31,13 @@ int dupstore(ObjectStore* src, ObjectStore* dst)
// collections
vector<coll_t> collections;
src->list_collections(collections);
int ret = src->list_collections(collections);
if (ret < 0) {
cerr << "Error " << ret << " while listing collections" << std::endl;
return 1;
}
int num = collections.size();
cout << num << " collections" << std::endl;
int i = 1;

View File

@ -212,9 +212,11 @@ struct C_AioCompleteAndSafe : public Context {
}
void finish(int r) {
c->lock.Lock();
c->rval = r;
c->ack = true;
c->safe = true;
c->lock.Unlock();
rados_callback_t cb_complete = c->callback_complete;
void *cb_arg = c->callback_arg;
if (cb_complete)

View File

@ -6210,9 +6210,12 @@ void Server::_rename_prepare(MDRequest *mdr,
// guarantee stray dir is processed first during journal replay. unlink the old inode,
// then link the source inode to destdn
if (destdnl->is_primary() && straydn->is_auth()) {
metablob->add_dir_context(straydn->get_dir());
metablob->add_dir(straydn->get_dir(), true);
if (destdnl->is_primary()) {
assert(straydn);
if (straydn->is_auth()) {
metablob->add_dir_context(straydn->get_dir());
metablob->add_dir(straydn->get_dir(), true);
}
}
// sub off target
@ -6943,7 +6946,7 @@ void Server::do_rename_rollback(bufferlist &rbl, int master, MDRequest *mdr)
bool force_journal_dest = false;
if (in && in->is_dir() && srcdn->authority().first != whoami)
force_journal_src = _need_force_journal(in, false);
if (target && target->is_dir())
if (in && target && target->is_dir())
force_journal_dest = _need_force_journal(in, true);
version_t srcdnpv = 0;
@ -7091,13 +7094,16 @@ void Server::_rename_rollback_finish(Mutation *mut, MDRequest *mdr, CDentry *src
if (srcdn) {
CInode *in = srcdn->get_linkage()->get_inode();
// update subtree map?
if (in && in->is_dir())
if (in && in->is_dir()) {
assert(destdn);
mdcache->adjust_subtree_after_rename(in, destdn->get_dir(), true);
}
}
if (destdn) {
CInode *oldin = destdn->get_linkage()->get_inode();
// update subtree map?
assert(straydn);
if (oldin && oldin->is_dir())
mdcache->adjust_subtree_after_rename(oldin, straydn->get_dir(), true);
}

View File

@ -150,6 +150,7 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
sync_provider(),
timecheck_round(0),
timecheck_acks(0),
timecheck_event(NULL),
probe_timeout_event(NULL),

View File

@ -548,6 +548,7 @@ private:
version(0),
timeout(NULL),
sync_state(STATE_NONE),
crc(0),
crc_available(false),
attempts(0)
{ }

View File

@ -29,7 +29,6 @@
class QuorumService : public RefCountedObject
{
uint32_t flags;
Context *tick_event;
double tick_period;

View File

@ -1294,7 +1294,7 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
bool from_stdin = !strcmp(path, "-");
if (from_stdin) {
fd = 0;
size = 1 << *order;
size = 1ULL << *order;
} else {
fd = open(path, O_RDONLY);

View File

@ -992,7 +992,10 @@ int RGWAccessKeyPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg
RGWSubUserPool::RGWSubUserPool(RGWUser *usr)
{
subusers_allowed = (usr != NULL);
store = usr->get_store();
if (usr)
store = usr->get_store();
else
store = NULL;
user = usr;
subuser_map = NULL;
}

View File

@ -105,6 +105,7 @@ static int testrados(void)
{
char tmp[32];
int i, r;
int ret = 1; //set 1 as error case
rados_t cl;
if (rados_create(&cl, NULL) < 0) {
@ -114,7 +115,7 @@ static int testrados(void)
if (rados_conf_read_file(cl, NULL)) {
printf("error reading configuration file\n");
return 1;
goto out_err;
}
// Try to set a configuration option that doesn't exist.
@ -122,35 +123,35 @@ static int testrados(void)
if (!rados_conf_set(cl, "config option that doesn't exist",
"some random value")) {
printf("error: succeeded in setting nonexistent config option\n");
return 1;
goto out_err;
}
if (rados_conf_get(cl, "log to stderr", tmp, sizeof(tmp))) {
printf("error: failed to read log_to_stderr from config\n");
return 1;
goto out_err;
}
// Can we change it?
if (rados_conf_set(cl, "log to stderr", "true")) {
printf("error: error setting log_to_stderr\n");
return 1;
goto out_err;
}
if (rados_conf_get(cl, "log to stderr", tmp, sizeof(tmp))) {
printf("error: failed to read log_to_stderr from config\n");
return 1;
goto out_err;
}
if (strcmp(tmp, "true")) {
printf("error: new setting for log_to_stderr failed to take effect.\n");
return 1;
goto out_err;
}
if (rados_connect(cl)) {
printf("error connecting\n");
return 1;
goto out_err;
}
if (rados_connect(cl) == 0) {
printf("second connect attempt didn't return an error\n");
return 1;
goto out_err;
}
/* create an io_ctx */
@ -170,7 +171,7 @@ static int testrados(void)
if (r != buf_sz) {
printf("buffer size mismatch: got %d the first time, but %d "
"the second.\n", buf_sz, r);
return 1;
goto out_err;
}
const char *b = buf;
printf("begin pools.\n");
@ -220,21 +221,21 @@ static int testrados(void)
/* attrs */
if (do_rados_setxattr(io_ctx, oid, "b", "2"))
return 1;
goto out_err;
if (do_rados_setxattr(io_ctx, oid, "a", "1"))
return 1;
goto out_err;
if (do_rados_setxattr(io_ctx, oid, "c", "3"))
return 1;
goto out_err;
if (do_rados_getxattr(io_ctx, oid, "a", "1"))
return 1;
goto out_err;
if (do_rados_getxattr(io_ctx, oid, "b", "2"))
return 1;
goto out_err;
if (do_rados_getxattr(io_ctx, oid, "c", "3"))
return 1;
goto out_err;
const char *exkeys[] = { "a", "b", "c", NULL };
const char *exvals[] = { "1", "2", "3", NULL };
if (do_rados_getxattrs(io_ctx, oid, exkeys, exvals))
return 1;
goto out_err;
uint64_t size;
time_t mtime;
@ -299,8 +300,10 @@ static int testrados(void)
r = rados_pool_delete(cl, "foo");
printf("rados_ioctx_pool_delete = %d\n", r);
ret = 0;
out_err:
rados_shutdown(cl);
return 0;
return ret;
}
int main(int argc, const char **argv)

View File

@ -91,6 +91,8 @@ int run_diff(std::string& a_path, std::string& a_journal,
dout(0) << "no diff" << dendl;
}
delete a;
delete b;
return ret;
}
@ -99,8 +101,10 @@ int run_get_last_op(std::string& filestore_path, std::string& journal_path)
FileStore *store = new FileStore(filestore_path, journal_path);
int err = store->mount();
if (err)
if (err) {
delete store;
return err;
}
coll_t txn_coll("meta");
hobject_t txn_object(sobject_t("txn", CEPH_NOSNAP));
@ -135,6 +139,7 @@ int run_sequence_to(int val, std::string& filestore_path,
err = ::mkdir(filestore_path.c_str(), 0755);
if (err) {
cerr << filestore_path << " already exists" << std::endl;
delete store;
return err;
}
@ -149,6 +154,7 @@ int run_sequence_to(int val, std::string& filestore_path,
op_sequence.generate(seed, num_txs);
store->umount();
delete store;
return 0;
}

View File

@ -373,6 +373,7 @@ int KvStoreBench::test_teuthology_aio(next_gen_t distr,
kv = (((KvStoreBench *)this)->*distr)(true);
if (kv.first == "") {
i--;
delete cb_args;
continue;
}
ops_in_flight++;
@ -384,6 +385,7 @@ int KvStoreBench::test_teuthology_aio(next_gen_t distr,
kv = (((KvStoreBench *)this)->*distr)(false);
if (kv.first == "") {
i--;
delete cb_args;
continue;
}
ops_in_flight++;
@ -395,6 +397,7 @@ int KvStoreBench::test_teuthology_aio(next_gen_t distr,
kv = (((KvStoreBench *)this)->*distr)(false);
if (kv.first == "") {
i--;
delete cb_args;
continue;
}
key_set.erase(kv.first);
@ -406,6 +409,7 @@ int KvStoreBench::test_teuthology_aio(next_gen_t distr,
kv = (((KvStoreBench *)this)->*distr)(false);
if (kv.first == "") {
i--;
delete cb_args;
continue;
}
bufferlist val;
@ -415,6 +419,10 @@ int KvStoreBench::test_teuthology_aio(next_gen_t distr,
cb_args, &cb_args->err);
break;
}
if (cb_args) {
delete cb_args;
}
}
while(ops_in_flight > 0) {

View File

@ -1248,6 +1248,11 @@ static void test_list_children(rbd_image_t image, ssize_t num_expected, ...)
ASSERT_TRUE(found);
}
va_end(ap);
if (pools)
free(pools);
if (children)
free(children);
}
TEST(LibRBD, ListChildren)

View File

@ -40,7 +40,8 @@ using namespace std;
extern "C" int ceph_armor(char *dst, const char *dst_end,
const char *src, const char *end);
enum key_type {
KEY_TYPE_SWIFT = 1,
KEY_TYPE_UNDEFINED = 0,
KEY_TYPE_SWIFT,
KEY_TYPE_S3
};
@ -65,7 +66,7 @@ class test_cors_helper {
unsigned resp_code;
key_type kt;
public:
test_cors_helper() : resp_data(NULL){
test_cors_helper() : resp_data(NULL), kt(KEY_TYPE_UNDEFINED){
curl_global_init(CURL_GLOBAL_ALL);
}
~test_cors_helper(){
@ -247,8 +248,11 @@ int test_cors_helper::send_request(string method, string res,
string s3auth;
if(get_s3_auth(method, creds, date, res, s3auth) < 0)return -1;
auth.append(string("Authorization: AWS ") + s3auth);
}else if(kt == KEY_TYPE_SWIFT){
} else if(kt == KEY_TYPE_SWIFT){
auth.append(string("X-Auth-Token: ") + creds);
} else {
cout << "Unknown state (" << kt << ")\n";
return -1;
}
struct curl_slist *slist = NULL;

View File

@ -52,6 +52,8 @@ public:
cond.Wait(lock);
//cout << "waited" << std::endl;
lock.Unlock();
if (c)
delete c;
}
};

View File

@ -357,7 +357,7 @@ void remove_coll(ObjectStore *store, const coll_t &coll)
r = store->collection_list_partial(coll, next, 200, 300, 0,
&objects, &next);
if (r < 0)
return;
goto out;
for (vector<hobject_t>::iterator i = objects.begin();
i != objects.end();
++i, ++num) {
@ -380,6 +380,7 @@ void remove_coll(ObjectStore *store, const coll_t &coll)
}
t->remove_collection(coll);
store->apply_transaction(*t);
out:
delete t;
}
@ -437,6 +438,7 @@ int initiate_new_remove_pg(ObjectStore *store, pg_t r_pgid,
<< std::endl;
rmt->collection_rename(coll_t(r_pgid), to_remove);
} else {
delete rmt;
return ENOENT;
}

View File

@ -194,6 +194,7 @@ static int get_indata(const char *in_file, bufferlist &indata)
int err = errno;
derr << "error getting size of in_file '" << in_file << "': "
<< cpp_strerror(err) << dendl;
TEMP_FAILURE_RETRY(::close(fd));
return 1;
}
@ -231,10 +232,11 @@ int do_admin_socket(string path, string cmd)
if (connect(fd, (struct sockaddr *) &address,
sizeof(struct sockaddr_un)) != 0) {
cerr << "connect to " << path << " failed with " << cpp_strerror(errno) << std::endl;
::close(fd);
return -1;
}
char *buf;
char *buf = NULL;
uint32_t len;
r = safe_write(fd, cmd.c_str(), cmd.length() + 1);
if (r < 0) {
@ -266,6 +268,8 @@ int do_admin_socket(string path, string cmd)
r = 0;
out:
if (buf)
delete[] buf;
::close(fd);
return r;
}