]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 8 Jul 2005 02:14:44 +0000 (02:14 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 8 Jul 2005 02:14:44 +0000 (02:14 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@419 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/client/Client.cc
ceph/client/Client.h
ceph/messages/MClientReply.h

index 06e2ab6593bfd688ae30fb6583cf56e6e11fc02d..aa6e1acc055cfce7d03097585b25aa0ca231e9d2 100644 (file)
@@ -222,6 +222,7 @@ Inode* Client::insert_inode_info(Dir *dir, c_inode_info *in_info)
 
   // take note of latest distribution on mds's
   dn->inode->mds_contacts = in_info->dist;
+  dn->inode->mds_auth = in_info->auth;
 
   return dn->inode;
 }
@@ -298,7 +299,7 @@ Dentry *Client::lookup(filepath& path)
 
 // -------
 
-MClientReply *Client::make_request(MClientRequest *req)
+MClientReply *Client::make_request(MClientRequest *req, bool auth_best)
 {
   // send to what MDS?  find deepest known prefix
   int mds = 0;
@@ -317,15 +318,23 @@ MClientReply *Client::make_request(MClientRequest *req)
          break;
   }
   
-  if (cur && cur->mds_contacts.size()) {
-       dout(9) << "contacting mds from deepest inode " << cur->inode.ino << " " << req->get_filepath() << ": " << cur->mds_contacts << endl;
-       set<int>::iterator it = cur->mds_contacts.begin();
-       if (cur->mds_contacts.size() == 1)
-         mds = *it;
-       else {
-         int r = rand() % cur->mds_contacts.size();
-         while (r--) it++;
-         mds = *it;
+  if (cur) {
+       if (auth_best) {
+         mds = cur->mds_auth;
+       } else {
+         if (cur->mds_contacts.size()) {
+               dout(9) << "contacting mds from deepest inode " << cur->inode.ino << " " << req->get_filepath() << ": " << cur->mds_contacts << endl;
+               set<int>::iterator it = cur->mds_contacts.begin();
+               if (cur->mds_contacts.size() == 1)
+                 mds = *it;
+               else {
+                 int r = rand() % cur->mds_contacts.size();
+                 while (r--) it++;
+                 mds = *it;
+               }
+         } else {
+               mds = cur->mds_auth;
+         }
        }
   } else {
        dout(9) << "i have no idea where " << req->get_filepath() << " is" << endl;
@@ -617,7 +626,7 @@ int Client::link(const char *existing, const char *newname)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   
   this->insert_trace(reply->get_trace());
@@ -647,7 +656,7 @@ int Client::unlink(const char *path)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   if (res == 0) {
        // remove from local cache
@@ -683,7 +692,7 @@ int Client::rename(const char *from, const char *to)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());
   delete reply;
@@ -715,7 +724,7 @@ int Client::mkdir(const char *path, mode_t mode)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());
   delete reply;
@@ -743,7 +752,7 @@ int Client::rmdir(const char *path)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   if (res == 0) {
        // remove from local cache
@@ -785,7 +794,7 @@ int Client::symlink(const char *target, const char *link)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  //FIXME assuming trace of link, not of target
   delete reply;
@@ -915,7 +924,7 @@ int Client::chmod(const char *path, mode_t mode)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
@@ -947,7 +956,7 @@ int Client::chown(const char *path, uid_t uid, gid_t gid)
 
   //FIXME enforce caller uid rights?
 
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
@@ -980,7 +989,7 @@ int Client::utime(const char *path, struct utimbuf *buf)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
@@ -1012,7 +1021,7 @@ int Client::mknod(const char *path, mode_t mode)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
 
@@ -1052,7 +1061,7 @@ int Client::getdir(const char *path, map<string,inode_t*>& contents)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   vector<c_inode_info*> trace = reply->get_trace();
   this->insert_trace(trace);  
@@ -1113,7 +1122,7 @@ int Client::open(const char *path, int mode)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   assert(reply);
   dout(3) << "op: open_files[" << reply->get_result() << "] = fh;  // fh = " << reply->get_result() << endl;
   tout << reply->get_result() << endl;
@@ -1186,7 +1195,7 @@ int Client::close(fileh_t fh)
   release_inode_buffers(in);
   put_inode( in );
 
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   assert(reply);
   int result = reply->get_result();
   dout(3) << "close " << fh << " result = " << result << endl;
@@ -1502,7 +1511,7 @@ int Client::truncate(const char *file, off_t size)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req);
+  MClientReply *reply = make_request(req, true);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
index 4f49c521d3ea41413a3bb252f5a7efbf9b5a9d3c..943008e07626b252f63557bef5a7be7adc419f4c 100644 (file)
@@ -77,6 +77,7 @@ class Dir {
 class Inode {
  public:
   inode_t   inode;    // the actual inode
+  int       mds_auth;
   set<int>     mds_contacts;
   time_t    last_updated;
 
@@ -255,7 +256,7 @@ class Client : public Dispatcher {
 
 
   // blocking mds call
-  MClientReply *make_request(MClientRequest *req);
+  MClientReply *make_request(MClientRequest *req, bool auth_best=false);
 
   
   // buffer cache
index c03d9d107be4a1d7b2f0c5855649c6e2e2982724..b438765c3e7f1e8e2133ed6256824f69079f2115 100644 (file)
@@ -41,6 +41,7 @@ class c_inode_info {
   bool inode_soft_valid;  // true if inode info is valid (ie was readable on mds at the time)
   bool inode_hard_valid;  // true if inode info is valid (ie was readable on mds at the time)
 
+  int      auth;
   set<int> dist;    // where am i replicated?
 
 
@@ -59,6 +60,7 @@ class c_inode_info {
        this->ref_dn = ref_dn;
        
        // replicated where?
+       auth = in->authority();
        in->get_dist_spec(this->dist, whoami, now);
   }