Implement low-level lookuphash on client, for MDS testing.
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
return r;
}
+int Client::lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name)
+{
+ Mutex::Locker lock(client_lock);
+ dout(3) << "lookup_hash enter(" << ino << ", #" << dirino << "/" << name << ") = " << dendl;
+
+ MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPHASH);
+ filepath path(ino);
+ req->set_filepath(path);
+
+ uint32_t h = ceph_str_hash(0, name, strlen(name));
+ char f[30];
+ sprintf(f, "%d", h);
+ filepath path2(dirino);
+ path2.push_dentry(string(f));
+ req->set_filepath2(path2);
+
+ int r = make_request(req, -1, -1, NULL, rand() % mdsmap->get_num_mds());
+ dout(3) << "lookup_hash exit(" << ino << ", #" << dirino << "/" << name << ") = " << r << dendl;
+ return r;
+}
+
Fh *Client::_create_fh(Inode *in, int flags, int cmode)
{
// yay
// file ops
int mknod(const char *path, mode_t mode, dev_t rdev=0);
int open(const char *path, int flags, mode_t mode=0);
+ int lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name);
int close(int fd);
loff_t lseek(int fd, loff_t offset, int whence);
int read(int fd, char *buf, loff_t size, loff_t offset=-1);
syn_sargs.push_back(args[++i]);
syn_iargs.push_back(atoi(args[++i]));
+ } else if (strcmp(args[i], "lookuphash") == 0) {
+ syn_modes.push_back(SYNCLIENT_MODE_LOOKUPHASH);
+ syn_sargs.push_back(args[++i]);
+ syn_sargs.push_back(args[++i]);
+ syn_sargs.push_back(args[++i]);
+
} else if (strcmp(args[i], "chunkfile") == 0) {
syn_modes.push_back(SYNCLIENT_MODE_CHUNK);
syn_sargs.push_back(args[++i]);
did_run_me();
}
break;
+
+ case SYNCLIENT_MODE_LOOKUPHASH:
+ {
+ inodeno_t ino;
+ string iname = get_sarg(0);
+ sscanf(iname.c_str(), "%llx", (long long unsigned*)&ino.val);
+ inodeno_t dirino;
+ string diname = get_sarg(0);
+ sscanf(diname.c_str(), "%llx", (long long unsigned*)&dirino.val);
+ string name = get_sarg(0);
+ if (run_me()) {
+ lookup_hash(ino, dirino, name.c_str());
+ }
+ }
+ break;
case SYNCLIENT_MODE_MKSNAP:
{
}
+int SyntheticClient::lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name)
+{
+ int r = client->lookup_hash(ino, dirino, name);
+ dout(0) << "lookup_hash(" << ino << ", #" << dirino << "/" << name << ") = " << r << dendl;
+ return r;
+}
+
int SyntheticClient::chunk_file(string &filename)
{
int fd = client->open(filename.c_str(), O_RDONLY);
#define SYNCLIENT_MODE_DUMP 63
+#define SYNCLIENT_MODE_LOOKUPHASH 70
#define SYNCLIENT_MODE_TRUNCATE 200
#define SYNCLIENT_MODE_MKSNAPFILE 1002
+
void parse_syn_options(vector<const char*>& args);
class SyntheticClient {
void import_find(const char *basedir, const char *find, bool writedata);
+ int lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name);
+
int chunk_file(string &filename);
void mksnap(const char *base, const char *name);