mirror of
https://github.com/ceph/ceph
synced 2024-12-18 01:16:55 +00:00
*** empty log message ***
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@402 29311d96-e01e-0410-9327-a35deaab8ce9
This commit is contained in:
parent
6493661852
commit
a01c764c1e
@ -21,7 +21,7 @@
|
||||
|
||||
#include "include/config.h"
|
||||
#undef dout
|
||||
#define dout(l) if (l<=g_conf.debug) cout << "client" << "." << pthread_self() << " "
|
||||
#define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_client) cout << "client" << "." << pthread_self() << " "
|
||||
|
||||
|
||||
|
||||
@ -184,11 +184,17 @@ Inode* Client::insert_inode_info(Dir *dir, c_inode_info *in_info)
|
||||
}
|
||||
|
||||
if (!dn) {
|
||||
// have inode linked elsewhere? -> unlink and relink!
|
||||
if (inode_map.count(in_info->inode.ino)) {
|
||||
Inode *in = inode_map[in_info->inode.ino];
|
||||
if (in) {
|
||||
dout(12) << " had ino " << in->inode.ino << " at wrong position, moving" << endl;
|
||||
if (in->dn) unlink(in->dn);
|
||||
assert(in);
|
||||
|
||||
if (in->dn) {
|
||||
dout(12) << " had ino " << in->inode.ino << " linked at wrong position, unlinking" << endl;
|
||||
dn = relink(in->dn, dir, dname);
|
||||
} else {
|
||||
// link
|
||||
dout(12) << " had ino " << in->inode.ino << " unlinked, linking" << endl;
|
||||
dn = link(dir, dname, in);
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +225,22 @@ class Client : public Dispatcher {
|
||||
delete dn;
|
||||
}
|
||||
|
||||
Dentry *relink(Dentry *dn, Dir *dir, string& name) {
|
||||
// first link new dn to dir
|
||||
dir->dentries[name] = dn;
|
||||
|
||||
// unlink from old dir
|
||||
dn->dir->dentries.erase(dn->name);
|
||||
if (dn->dir->is_empty())
|
||||
close_dir(dn->dir);
|
||||
|
||||
// fix up dn
|
||||
dn->name = name;
|
||||
dn->dir = dir;
|
||||
|
||||
return dn;
|
||||
}
|
||||
|
||||
// move dentry to top of lru
|
||||
void touch_dn(Dentry *dn) { lru.lru_touch(dn); }
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "include/config.h"
|
||||
#undef dout
|
||||
#define dout(l) if (l<=g_conf.debug) cout << "synthetic" << client->get_nodeid() << " "
|
||||
#define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_client) cout << "synthetic" << client->get_nodeid() << " "
|
||||
|
||||
|
||||
#define DBL 2
|
||||
@ -294,13 +294,14 @@ int SyntheticClient::random_walk(int num_req)
|
||||
if (run_until.first && g_clock.gettimepair() > run_until) break;
|
||||
|
||||
// ascend?
|
||||
if (cwd.depth() && roll_die(.05)) {
|
||||
if (cwd.depth() && roll_die(.1)) {
|
||||
dout(DBL) << "die says up" << endl;
|
||||
up();
|
||||
continue;
|
||||
}
|
||||
|
||||
// descend?
|
||||
if (roll_die(.5) && subdirs.size()) {
|
||||
if (roll_die(.3) && subdirs.size()) {
|
||||
string s = get_random_subdir();
|
||||
cwd.add_dentry( s );
|
||||
dout(DBL) << "cd " << s << " -> " << cwd << endl;
|
||||
@ -311,10 +312,11 @@ int SyntheticClient::random_walk(int num_req)
|
||||
int op = 0;
|
||||
filepath path;
|
||||
|
||||
if (contents.empty() && roll_die(.7)) {
|
||||
if (did_readdir)
|
||||
if (contents.empty() && roll_die(.3)) {
|
||||
if (did_readdir) {
|
||||
dout(DBL) << "empty dir, up" << endl;
|
||||
up();
|
||||
else
|
||||
} else
|
||||
op = MDS_OP_READDIR;
|
||||
} else {
|
||||
op = op_dist.sample();
|
||||
@ -335,7 +337,7 @@ int SyntheticClient::random_walk(int num_req)
|
||||
if (contents.empty())
|
||||
op = MDS_OP_READDIR;
|
||||
else {
|
||||
|
||||
r = client->rename( get_random_sub(), make_sub("ren") );
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,9 +409,14 @@ int SyntheticClient::random_walk(int num_req)
|
||||
if (op == MDS_OP_STAT) {
|
||||
struct stat st;
|
||||
if (contents.empty()) {
|
||||
if (did_readdir)
|
||||
up();
|
||||
else
|
||||
if (did_readdir) {
|
||||
if (roll_die(.1)) {
|
||||
dout(DBL) << "stat in empty dir, up" << endl;
|
||||
up();
|
||||
} else {
|
||||
op = MDS_OP_MKNOD;
|
||||
}
|
||||
} else
|
||||
op = MDS_OP_READDIR;
|
||||
} else
|
||||
r = client->lstat(get_random_sub(), &st);
|
||||
@ -436,13 +443,13 @@ int SyntheticClient::random_walk(int num_req)
|
||||
// errors?
|
||||
if (r < 0) {
|
||||
// reevaluate cwd.
|
||||
while (cwd.depth()) {
|
||||
//if (client->lookup(cwd)) break; // it's in the cache
|
||||
//while (cwd.depth()) {
|
||||
//if (client->lookup(cwd)) break; // it's in the cache
|
||||
|
||||
//dout(DBL) << "r = " << r << ", client doesn't have " << cwd << ", cd .." << endl;
|
||||
dout(DBL) << "r = " << r << ", client may not have " << cwd << ", cd .." << endl;
|
||||
cwd = cwd.prefixpath(cwd.depth()-1);
|
||||
}
|
||||
//dout(DBL) << "r = " << r << ", client doesn't have " << cwd << ", cd .." << endl;
|
||||
dout(DBL) << "r = " << r << ", client may not have " << cwd << ", cd .." << endl;
|
||||
up();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,20 +45,32 @@ class SyntheticClient {
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
||||
filepath n1;
|
||||
const char *get_random_subdir() {
|
||||
assert(!subdirs.empty());
|
||||
int r = rand() % subdirs.size();
|
||||
int r = ((rand() % subdirs.size()) + (rand() % subdirs.size())) / 2; // non-uniform distn
|
||||
set<string>::iterator it = subdirs.begin();
|
||||
while (r--) it++;
|
||||
return (*it).c_str();
|
||||
|
||||
n1 = cwd;
|
||||
n1.add_dentry( *it );
|
||||
return n1.get_path().c_str();
|
||||
}
|
||||
filepath n2;
|
||||
const char *get_random_sub() {
|
||||
assert(!contents.empty());
|
||||
int r = rand() % contents.size();
|
||||
int r = ((rand() % contents.size()) + (rand() % contents.size())) / 2; // non-uniform distn
|
||||
if (cwd.depth() && cwd.last_bit().length())
|
||||
r += cwd.last_bit().c_str()[0]; // slightly permuted
|
||||
r %= contents.size();
|
||||
|
||||
map<string,inode_t>::iterator it = contents.begin();
|
||||
while (r--) it++;
|
||||
return it->first.c_str();
|
||||
|
||||
n2 = cwd;
|
||||
n2.add_dentry( it->first );
|
||||
return n2.get_path().c_str();
|
||||
}
|
||||
|
||||
filepath sub;
|
||||
|
@ -9,6 +9,8 @@ using namespace std;
|
||||
#include <ext/hash_map>
|
||||
using namespace __gnu_cxx;
|
||||
|
||||
#include "Mutex.h"
|
||||
|
||||
// for const char* comparisons
|
||||
struct ltstr
|
||||
{
|
||||
@ -34,18 +36,20 @@ class LogType {
|
||||
version = 1;
|
||||
}
|
||||
void add_inc(const char* key) {
|
||||
if (have_key(key)) return;
|
||||
keys.push_back(key);
|
||||
keyset.insert(key);
|
||||
inc_keys.push_back(key);
|
||||
version++;
|
||||
if (!have_key(key)) {
|
||||
keys.push_back(key);
|
||||
keyset.insert(key);
|
||||
inc_keys.push_back(key);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
void add_set(const char* key){
|
||||
if (have_key(key)) return;
|
||||
keys.push_back(key);
|
||||
keyset.insert(key);
|
||||
set_keys.push_back(key);
|
||||
version++;
|
||||
if (!have_key(key)) {
|
||||
keys.push_back(key);
|
||||
keyset.insert(key);
|
||||
set_keys.push_back(key);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
bool have_key(const char* key) {
|
||||
return keyset.count(key) ? true:false;
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "include/config.h"
|
||||
|
||||
// per-process lock. lame, but this way I protect LogType too!
|
||||
Mutex logger_lock;
|
||||
|
||||
Logger::Logger(string fn, LogType *type)
|
||||
{
|
||||
@ -39,43 +41,43 @@ Logger::~Logger()
|
||||
long Logger::inc(const char *key, long v)
|
||||
{
|
||||
if (!g_conf.log) return 0;
|
||||
lock.Lock();
|
||||
logger_lock.Lock();
|
||||
if (!type->have_key(key))
|
||||
type->add_inc(key);
|
||||
flush();
|
||||
vals[key] += v;
|
||||
long r = vals[key];
|
||||
lock.Unlock();
|
||||
logger_lock.Unlock();
|
||||
return r;
|
||||
}
|
||||
|
||||
long Logger::set(const char *key, long v)
|
||||
{
|
||||
if (!g_conf.log) return 0;
|
||||
lock.Lock();
|
||||
logger_lock.Lock();
|
||||
if (!type->have_key(key))
|
||||
type->add_set(key);
|
||||
|
||||
flush();
|
||||
vals[key] = v;
|
||||
long r = vals[key];
|
||||
lock.Unlock();
|
||||
logger_lock.Unlock();
|
||||
return r;
|
||||
}
|
||||
|
||||
long Logger::get(const char* key)
|
||||
{
|
||||
if (!g_conf.log) return 0;
|
||||
lock.Lock();
|
||||
logger_lock.Lock();
|
||||
long r = vals[key];
|
||||
lock.Unlock();
|
||||
logger_lock.Unlock();
|
||||
return r;
|
||||
}
|
||||
|
||||
void Logger::flush(bool force)
|
||||
{
|
||||
if (!g_conf.log) return;
|
||||
lock.Lock();
|
||||
logger_lock.Lock();
|
||||
|
||||
if (!open) {
|
||||
out.open(filename.c_str(), ofstream::out);
|
||||
@ -124,7 +126,7 @@ void Logger::flush(bool force)
|
||||
this->vals[*it] = 0;
|
||||
}
|
||||
|
||||
lock.Unlock();
|
||||
logger_lock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ struct eqstr
|
||||
class Logger {
|
||||
protected:
|
||||
hash_map<const char*, long, hash<const char*>, eqstr> vals;
|
||||
Mutex lock;
|
||||
//Mutex lock;
|
||||
LogType *type;
|
||||
|
||||
timepair_t start;
|
||||
|
@ -52,6 +52,7 @@ md_config_t g_conf = {
|
||||
debug_mds_log: 1,
|
||||
debug_buffer: 0,
|
||||
debug_filer: 0,
|
||||
debug_client: 0,
|
||||
|
||||
// --- client ---
|
||||
client_cache_size: 400,
|
||||
@ -106,15 +107,15 @@ md_config_t g_conf = {
|
||||
fakeclient_op_chmod: 1,
|
||||
fakeclient_op_chown: 1,
|
||||
|
||||
fakeclient_op_readdir: 20,
|
||||
fakeclient_op_mknod: 10,
|
||||
fakeclient_op_readdir: 2,
|
||||
fakeclient_op_mknod: 30,
|
||||
fakeclient_op_link: false,
|
||||
fakeclient_op_unlink: 5,
|
||||
fakeclient_op_rename: 100,
|
||||
fakeclient_op_unlink: 20,
|
||||
fakeclient_op_rename: 40,
|
||||
|
||||
fakeclient_op_mkdir: 50,
|
||||
fakeclient_op_rmdir: 0, // there's a bug...10,
|
||||
fakeclient_op_symlink: 10,
|
||||
fakeclient_op_mkdir: 10,
|
||||
fakeclient_op_rmdir: 20,
|
||||
fakeclient_op_symlink: 20,
|
||||
|
||||
fakeclient_op_openrd: 200,
|
||||
fakeclient_op_openwr: 0,
|
||||
@ -160,6 +161,8 @@ void parse_config_options(int argc, char **argv,
|
||||
g_conf.debug_buffer = atoi(argv[++i]);
|
||||
else if (strcmp(argv[i], "--debug_filer") == 0)
|
||||
g_conf.debug_filer = atoi(argv[++i]);
|
||||
else if (strcmp(argv[i], "--debug_client") == 0)
|
||||
g_conf.debug_client = atoi(argv[++i]);
|
||||
|
||||
else if (strcmp(argv[i], "--log") == 0)
|
||||
g_conf.log = atoi(argv[++i]);
|
||||
|
@ -27,6 +27,7 @@ struct md_config_t {
|
||||
int debug_mds_log;
|
||||
int debug_buffer;
|
||||
int debug_filer;
|
||||
int debug_client;
|
||||
|
||||
// client
|
||||
int client_cache_size;
|
||||
|
@ -281,10 +281,10 @@ int FakeMessenger::send_message(Message *m, msg_addr_t dest, int port, int fromp
|
||||
if (!awake) {
|
||||
dout(10) << "waking up fakemessenger thread" << endl;
|
||||
awake = true;
|
||||
lock.Unlock();
|
||||
cond.Signal();
|
||||
} else
|
||||
lock.Unlock();
|
||||
}
|
||||
|
||||
lock.Unlock();
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user