]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: Fixes for get_or_create
authorGreg Farnum <gregf@hq.newdream.net>
Fri, 18 Sep 2009 22:20:29 +0000 (15:20 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 22 Sep 2009 20:02:50 +0000 (13:02 -0700)
src/client/Client.cc
src/client/Client.h

index ef6f52c9774e67f8fcd03ea3b3ec36d61cd0dd7d..0a0864a3b6252141fd7edc2352798be5e72d4c8b 100644 (file)
@@ -2982,7 +2982,8 @@ int Client::_lookup(Inode *dir, const string& dname, Inode **target)
   return r;
 }
 
-int Client::get_or_create(Inode *dir, const string& name, Dentry **pdn)
+int Client::get_or_create(Inode *dir, const char* name,
+                         Dentry **pdn, bool expect_null)
 {
   // lookup
   if (dir->dir && dir->dir->dentries.count(name)) {
@@ -2997,13 +2998,15 @@ int Client::get_or_create(Inode *dir, const string& name, Dentry **pdn)
       MDSSession &s = mds_sessions[dn->lease_mds];
       if (s.cap_ttl > now &&
          s.cap_gen == dn->lease_gen) {
-       return -EEXIST;
+       if (expect_null)
+         return -EEXIST;
+       else return 0;
       }
     }
-  } else {
-    // link up new one
-    *pdn = link(dir->dir, name.c_str(), NULL);
   }
+  
+  // otherwise link up a new one
+  *pdn = link(dir->dir, name, NULL);
   return 0;
 }
 
index 75ad46f9689f593d139be65a2001ee23b62e6828..f0786c92d1d1c6ad41495a1b6187123802329d00 100644 (file)
@@ -1182,7 +1182,8 @@ private:
   int _sync_fs();
 
   MClientRequest* make_request_from_Meta(MetaRequest * request);
-  int get_or_create(Inode *dir, const string& name, Dentry **pdn);
+  int get_or_create(Inode *dir, const char* name,
+                   Dentry **pdn, bool expect_null=false);
 
 public:
   int mount();