From: Sage Weil Date: Fri, 6 Mar 2009 22:04:19 +0000 (-0800) Subject: filepath: no more leading / weirdness X-Git-Tag: v0.7~11^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b857a03bf18f2f428624901b8fe39224cb02e9a4;p=ceph.git filepath: no more leading / weirdness Get rid of weird leading '/' iff ino==1 semantic. Clean up interface a bit. --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 907f932d0b882..86b86b2298a32 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2744,7 +2744,7 @@ int Client::_symlink(const filepath &path, const char *target, int uid, int gid) { MClientRequest *req = new MClientRequest(CEPH_MDS_OP_SYMLINK); req->set_filepath(path); - req->set_path2(target); + req->set_string2(target); MClientReply *reply = make_request(req, uid, gid); int res = reply->get_result(); @@ -4203,7 +4203,7 @@ int Client::_mksnap(const filepath& path, const char *name, int uid, int gid) { MClientRequest *req = new MClientRequest(CEPH_MDS_OP_MKSNAP); req->set_filepath(path); - req->set_path2(name); + req->set_string2(name); MClientReply *reply = make_request(req, uid, gid); int res = reply->get_result(); @@ -4218,7 +4218,7 @@ int Client::_rmsnap(const filepath& path, const char *name, int uid, int gid) { MClientRequest *req = new MClientRequest(CEPH_MDS_OP_RMSNAP); req->set_filepath(path); - req->set_path2(name); + req->set_string2(name); MClientReply *reply = make_request(req, uid, gid); int res = reply->get_result(); @@ -4596,7 +4596,7 @@ int Client::_setxattr(const filepath &path, const char *name, const void *value, { MClientRequest *req = new MClientRequest(CEPH_MDS_OP_LSETXATTR); req->set_filepath(path); - req->set_path2(name); + req->set_string2(name); req->head.args.setxattr.flags = flags; bufferlist bl; @@ -4716,7 +4716,7 @@ int Client::ll_mkdir(vinodeno_t parent, const char *name, mode_t mode, struct st if (diri->snapid == CEPH_SNAPDIR) { MClientRequest *req = new MClientRequest(CEPH_MDS_OP_MKSNAP); req->set_filepath(path); - req->set_path2(name); + req->set_string2(name); Inode *in; MClientReply *reply = make_request(req, uid, gid, &in); @@ -4803,7 +4803,7 @@ int Client::ll_rmdir(vinodeno_t vino, const char *name, int uid, int gid) if (diri->snapid == CEPH_SNAPDIR) { MClientRequest *req = new MClientRequest(CEPH_MDS_OP_RMSNAP); req->set_filepath(path); - req->set_path2(name); + req->set_string2(name); MClientReply *reply = make_request(req, uid, gid); int r = reply->get_result(); delete reply; diff --git a/src/client/Client.h b/src/client/Client.h index 868f6c631fbf3..3d23831cd48ce 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -688,7 +688,7 @@ protected: return filepath(rel, 1); filepath t = cwd; - filepath r(rel); + filepath r(rel, 0); t.append(r); return t; } diff --git a/src/include/filepath.h b/src/include/filepath.h index 827c517dade91..d8650fcc391af 100644 --- a/src/include/filepath.h +++ b/src/include/filepath.h @@ -35,7 +35,7 @@ using namespace std; class filepath { inodeno_t ino; // base inode. ino=0 implies pure relative path. - string path; // relative path. leading / IFF ino=1. + string path; // relative path. /** bits - path segments * this is ['a', 'b', 'c'] for both the aboslute and relative case. @@ -45,10 +45,7 @@ class filepath { mutable vector bits; void rebuild_path() { - if (absolute()) - path = "/"; - else - path.clear(); + path.clear(); for (unsigned i=0; i& pathmap) // traverse dout(17) << " missing " << p->first << " at " << p->second << dendl; - filepath path(p->second); + filepath path(p->second, 1); CDir *dir = path_traverse_to_dir(path); assert(dir); fetch_queue.insert(dir); @@ -5384,8 +5384,7 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req, // who if (in->is_symlink() && (follow_trailing_symlink || depth < path.depth()-1)) { // symlink, resolve! - filepath sym = in->symlink; - dout(10) << "traverse: hit symlink " << *in << " to " << sym << dendl; + dout(10) << "traverse: hit symlink " << *in << " to " << in->symlink << dendl; // break up path components // /head/symlink/tail @@ -5405,11 +5404,12 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req, // who // absolute trace.clear(); depth = 0; - path = in->symlink; + path = filepath(in->symlink.c_str() + 1, 1); path.append(tail); dout(10) << "traverse: absolute symlink, path now " << path << " depth " << depth << dendl; } else { // relative + filepath sym(in->symlink, 0); path = head; path.append(sym); path.append(tail); @@ -5532,7 +5532,7 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req, // who bool MDCache::path_is_mine(filepath& path) { - dout(15) << "path_is_mine " << path << dendl; + dout(15) << "path_is_mine " << path.get_ino() << " " << path << dendl; CInode *cur = get_inode(path.get_ino()); if (!cur) @@ -7285,17 +7285,18 @@ void MDCache::handle_discover_reply(MDiscoverReply *m) // wanted a dentry frag_t fg = cur->pick_dirfrag(m->get_error_dentry()); CDir *dir = cur->get_dirfrag(fg); + filepath relpath(m->get_error_dentry(), 0); if (dir) { // don't actaully need the hint, now if (dir->lookup(m->get_error_dentry()) == 0 && dir->is_waiting_for_dentry(m->get_error_dentry().c_str(), m->get_wanted_snapid())) - discover_path(dir, m->get_wanted_snapid(), m->get_error_dentry(), 0, m->get_wanted_xlocked()); + discover_path(dir, m->get_wanted_snapid(), relpath, 0, m->get_wanted_xlocked()); else dout(7) << " doing nothing, have dir but nobody is waiting on dentry " << m->get_error_dentry() << dendl; } else { if (cur->is_waiter_for(CInode::WAIT_DIR)) - discover_path(cur, m->get_wanted_snapid(), m->get_error_dentry(), 0, m->get_wanted_xlocked(), who); + discover_path(cur, m->get_wanted_snapid(), relpath, 0, m->get_wanted_xlocked(), who); else dout(7) << " doing nothing, nobody is waiting for dir" << dendl; } diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 4cd6099d3ed5e..47b7bc612b27b 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -851,7 +851,7 @@ public: int onfail); bool path_is_mine(filepath& path); bool path_is_mine(string& p) { - filepath path(p); + filepath path(p, 1); return path_is_mine(path); } CDir *path_traverse_to_dir(filepath& path); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 45ed25c3973cb..30252ba6f0f11 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -447,7 +447,7 @@ void Server::handle_client_reconnect(MClientReconnect *m) continue; } - filepath path = p->second.path; + filepath path(p->second.path, 1); if ((in && !in->is_auth()) || !mds->mdcache->path_is_mine(path)) { // not mine. diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 304a4701f1305..20945435215ef 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -107,12 +107,9 @@ public: void set_oldest_client_tid(tid_t t) { head.oldest_client_tid = t; } void inc_num_fwd() { head.num_fwd = head.num_fwd + 1; } void set_retry_attempt(int a) { head.retry_attempt = a; } - void set_path(string& p) { path.set_path(p); } - void set_path(const char *p) { path.set_path(p); } void set_filepath(const filepath& fp) { path = fp; } - void set_path2(string& p) { path2.set_path(p); } - void set_path2(const char *p) { path2.set_path(p); } void set_filepath2(const filepath& fp) { path2 = fp; } + void set_string2(const char *s) { path2.set_path(s, 0); } void set_caller_uid(unsigned u) { head.caller_uid = u; } void set_caller_gid(unsigned g) { head.caller_gid = g; } void set_mds_wants_replica_in_dirino(inodeno_t dirino) {