mirror of
https://github.com/ceph/ceph
synced 2025-01-18 09:02:08 +00:00
Merge pull request #2035 from ceph/wip-da-SCA-20140623
Fix for SCA and CID issues Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
94e1b77624
@ -41,7 +41,7 @@ void dump_open_fds(CephContext *cct)
|
||||
char path[PATH_MAX];
|
||||
snprintf(path, sizeof(path), "%s/%s", fn, de.d_name);
|
||||
char target[PATH_MAX];
|
||||
ssize_t r = readlink(path, target, sizeof(target));
|
||||
ssize_t r = readlink(path, target, sizeof(target) - 1);
|
||||
if (r < 0) {
|
||||
r = -errno;
|
||||
lderr(cct) << "dump_open_fds unable to readlink " << path << ": " << cpp_strerror(r) << dendl;
|
||||
|
@ -588,7 +588,7 @@ int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
|
||||
}
|
||||
// return
|
||||
return rcr;
|
||||
} catch (ErrorCode e) {
|
||||
} catch (ErrorCode &e) {
|
||||
// errror caught when trying to take the exclusive lock
|
||||
return e.m_code;
|
||||
}
|
||||
@ -600,7 +600,7 @@ int libradosstriper::RadosStriperImpl::trunc(const std::string& soid, uint64_t s
|
||||
std::string firstObjOid = getObjectId(soid, 0);
|
||||
try {
|
||||
RadosExclusiveLock lock(&m_ioCtx, firstObjOid);
|
||||
} catch (ErrorCode e) {
|
||||
} catch (ErrorCode &e) {
|
||||
return e.m_code;
|
||||
}
|
||||
// load layout and size
|
||||
|
@ -325,7 +325,7 @@ protected:
|
||||
bool safe;
|
||||
bool committing;
|
||||
bool recovering;
|
||||
umaster() : committing(false), recovering(false) {}
|
||||
umaster() : ls(NULL), safe(false), committing(false), recovering(false) {}
|
||||
};
|
||||
map<metareqid_t, umaster> uncommitted_masters; // master: req -> slave set
|
||||
|
||||
|
@ -154,6 +154,7 @@ static char *parse_options(const char *data, int *filesys_flags)
|
||||
} else if (strncmp(data, "secretfile", 10) == 0) {
|
||||
if (!value || !*value) {
|
||||
printf("keyword secretfile found, but no secret file specified\n");
|
||||
free(saw_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -186,9 +187,8 @@ static char *parse_options(const char *data, int *filesys_flags)
|
||||
}
|
||||
|
||||
/* take a copy of the name, to be used for
|
||||
naming the keys that we add to kernel;
|
||||
ignore memleak as mount.ceph is
|
||||
short-lived */
|
||||
naming the keys that we add to kernel; */
|
||||
free(saw_name);
|
||||
saw_name = strdup(value);
|
||||
if (!saw_name) {
|
||||
printf("out of memory.\n");
|
||||
@ -229,6 +229,7 @@ static char *parse_options(const char *data, int *filesys_flags)
|
||||
char secret_option[MAX_SECRET_OPTION_LEN];
|
||||
ret = get_secret_option(saw_secret, name, secret_option, sizeof(secret_option));
|
||||
if (ret < 0) {
|
||||
free(saw_name);
|
||||
return NULL;
|
||||
} else {
|
||||
if (pos) {
|
||||
@ -238,6 +239,7 @@ static char *parse_options(const char *data, int *filesys_flags)
|
||||
}
|
||||
}
|
||||
|
||||
free(saw_name);
|
||||
if (!out)
|
||||
return strdup(EMPTY_STRING);
|
||||
return out;
|
||||
|
@ -1994,7 +1994,7 @@ public:
|
||||
}
|
||||
|
||||
void chain_cb(const string& key, void *data) {
|
||||
T *entry = (T *)data;
|
||||
T *entry = static_cast<T *>(data);
|
||||
RWLock::WLocker wl(lock);
|
||||
entries[key] = *entry;
|
||||
}
|
||||
|
@ -132,7 +132,6 @@ TEST(LibCephFS, ReleaseMounted) {
|
||||
ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
|
||||
ASSERT_EQ(0, ceph_mount(cmount, "/"));
|
||||
ASSERT_EQ(-EISCONN, ceph_release(cmount));
|
||||
ceph_shutdown(cmount);
|
||||
}
|
||||
|
||||
TEST(LibCephFS, UnmountRelease) {
|
||||
|
@ -137,7 +137,8 @@ protected:
|
||||
// check we do not have an extra object behind
|
||||
uint64_t rados_size;
|
||||
time_t mtime;
|
||||
ASSERT_EQ(-ENOENT, ioctx.stat(getObjName(soid, nb_objects), &rados_size, &mtime));
|
||||
std::string oid = getObjName(soid, nb_objects);
|
||||
ASSERT_EQ(-ENOENT, ioctx.stat(oid, &rados_size, &mtime));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -596,7 +596,7 @@ public:
|
||||
map<string, bufferlist>::iterator it = contents[obj].attrs.begin();
|
||||
while (retry) {
|
||||
retry--;
|
||||
it++;
|
||||
++it;
|
||||
}
|
||||
|
||||
bufferlist bl;
|
||||
@ -624,7 +624,7 @@ public:
|
||||
map<string, bufferlist>::iterator it = contents[obj].attrs.begin();
|
||||
while (retry) {
|
||||
retry--;
|
||||
it++;
|
||||
++it;
|
||||
}
|
||||
|
||||
available_objects.erase(obj);
|
||||
|
@ -56,24 +56,24 @@ static int do_rados_getxattrs(rados_ioctx_t io_ctx, const char *oid,
|
||||
const char **exkeys, const char **exvals)
|
||||
{
|
||||
rados_xattrs_iter_t iter;
|
||||
int nval = 0, i, nfound = 0, ret = 0;
|
||||
int nval = 0, i, nfound = 0, r = 0, ret = 1;
|
||||
|
||||
for (i = 0; exvals[i]; ++i) {
|
||||
++nval;
|
||||
}
|
||||
ret = rados_getxattrs(io_ctx, oid, &iter);
|
||||
if (ret) {
|
||||
printf("rados_getxattrs(%s) failed with error %d\n", oid, ret);
|
||||
r = rados_getxattrs(io_ctx, oid, &iter);
|
||||
if (r) {
|
||||
printf("rados_getxattrs(%s) failed with error %d\n", oid, r);
|
||||
return 1;
|
||||
}
|
||||
while (1) {
|
||||
size_t len;
|
||||
const char *key, *val;
|
||||
ret = rados_getxattrs_next(iter, &key, &val, &len);
|
||||
if (ret) {
|
||||
r = rados_getxattrs_next(iter, &key, &val, &len);
|
||||
if (r) {
|
||||
printf("rados_getxattrs(%s): rados_getxattrs_next "
|
||||
"returned error %d\n", oid, ret);
|
||||
return 1;
|
||||
"returned error %d\n", oid, r);
|
||||
goto out_err;
|
||||
}
|
||||
if (!key)
|
||||
break;
|
||||
@ -87,17 +87,20 @@ static int do_rados_getxattrs(rados_ioctx_t io_ctx, const char *oid,
|
||||
printf("rados_getxattrs(%s): got key %s, but the "
|
||||
"value was %s rather than %s.\n",
|
||||
oid, key, val, exvals[i]);
|
||||
return 1;
|
||||
goto out_err;
|
||||
}
|
||||
}
|
||||
if (nfound != nval) {
|
||||
printf("rados_getxattrs(%s): only found %d extended attributes. "
|
||||
"Expected %d\n", oid, nfound, nval);
|
||||
return 1;
|
||||
goto out_err;
|
||||
}
|
||||
rados_getxattrs_end(iter);
|
||||
ret = 0;
|
||||
printf("rados_getxattrs(%s)\n", oid);
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
rados_getxattrs_end(iter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int testrados(void)
|
||||
@ -159,6 +162,10 @@ static int testrados(void)
|
||||
|
||||
rados_ioctx_t io_ctx;
|
||||
r = rados_ioctx_create(cl, "foo", &io_ctx);
|
||||
if (r < 0) {
|
||||
printf("error creating ioctx\n");
|
||||
goto out_err;
|
||||
}
|
||||
printf("rados_ioctx_create = %d, io_ctx = %p\n", r, io_ctx);
|
||||
|
||||
/* list all pools */
|
||||
@ -170,7 +177,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);
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
}
|
||||
const char *b = buf;
|
||||
printf("begin pools.\n");
|
||||
@ -220,21 +227,21 @@ static int testrados(void)
|
||||
|
||||
/* attrs */
|
||||
if (do_rados_setxattr(io_ctx, oid, "b", "2"))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
if (do_rados_setxattr(io_ctx, oid, "a", "1"))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
if (do_rados_setxattr(io_ctx, oid, "c", "3"))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
if (do_rados_getxattr(io_ctx, oid, "a", "1"))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
if (do_rados_getxattr(io_ctx, oid, "b", "2"))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
if (do_rados_getxattr(io_ctx, oid, "c", "3"))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
const char *exkeys[] = { "a", "b", "c", NULL };
|
||||
const char *exvals[] = { "1", "2", "3", NULL };
|
||||
if (do_rados_getxattrs(io_ctx, oid, exkeys, exvals))
|
||||
goto out_err;
|
||||
goto out_err_cleanup;
|
||||
|
||||
uint64_t size;
|
||||
time_t mtime;
|
||||
@ -292,14 +299,15 @@ static int testrados(void)
|
||||
r = rados_ioctx_pool_stat(io_ctx, &st);
|
||||
printf("rados_stat_pool = %d, %lld KB, %lld objects\n", r, (long long)st.num_kb, (long long)st.num_objects);
|
||||
|
||||
ret = 0;
|
||||
|
||||
out_err_cleanup:
|
||||
/* delete a pool */
|
||||
printf("rados_delete_pool = %d\n", r);
|
||||
rados_ioctx_destroy(io_ctx);
|
||||
|
||||
r = rados_pool_delete(cl, "foo");
|
||||
printf("rados_ioctx_pool_delete = %d\n", r);
|
||||
printf("rados_delete_pool = %d\n", r);
|
||||
|
||||
ret = 0;
|
||||
out_err:
|
||||
rados_shutdown(cl);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user