]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix O_CREAT on existing file trace behavior
authorSage Weil <sage@newdream.net>
Tue, 1 Apr 2008 15:17:30 +0000 (08:17 -0700)
committerSage Weil <sage@newdream.net>
Tue, 1 Apr 2008 15:17:30 +0000 (08:17 -0700)
src/client/SyntheticClient.cc
src/mds/Server.cc

index f040f5206868c10a9802641a7ce4ce650f99d88a..61dd8287bbe1011f5fa1aa3263fe940672b2ff92 100644 (file)
@@ -2626,6 +2626,19 @@ void SyntheticClient::make_dir_mess(const char *basedir, int n)
 
 void SyntheticClient::foo()
 {
+  if (1) {
+    dout(0) << "first" << dendl;
+    int fd = client->open("tester", O_WRONLY|O_CREAT);
+    client->write(fd, "hi there", 0, 8);
+    client->close(fd);
+    dout(0) << "sleep" << dendl;
+    sleep(10);
+    dout(0) << "again" << dendl;
+    fd = client->open("tester", O_WRONLY|O_CREAT);
+    client->write(fd, "hi there", 0, 8);
+    client->close(fd);
+    return;    
+  }
   if (1) {
     // open some files
     srand(0);
index 5579e9793a641d73b29023076e5d0388aae4496e..c101c943a1000d14affc7bf6c8e835f51298877e 100644 (file)
@@ -676,9 +676,6 @@ void Server::handle_client_request(MClientRequest *req)
     // they have a high request rate.
   }
 
-  // okay, i want
-  CInode *ref = 0;
-
   // retry?
   if (req->get_retry_attempt()) {
     assert(session);
@@ -700,12 +697,6 @@ void Server::handle_client_request(MClientRequest *req)
   if (!mdr) return;
   mdr->session = session;
 
-  if (ref) {
-    dout(10) << "inode op on ref " << *ref << dendl;
-    mdr->ref = ref;
-    mdr->pin(ref);
-  }
-
   dispatch_client_request(mdr);
   return;
 }
@@ -1232,9 +1223,17 @@ CDir *Server::traverse_to_auth_dir(MDRequest *mdr, vector<CDentry*> &trace, file
 
 CInode* Server::rdlock_path_pin_ref(MDRequest *mdr, bool want_auth)
 {
+  dout(10) << "rdlock_path_pin_ref " << *mdr << dendl;
+
   // already got ref?
-  if (mdr->ref) 
+  if (mdr->ref) {
+    if (mdr->trace.size()) {
+      CDentry *last = mdr->trace[mdr->trace.size()-1];
+      assert(last->get_inode() == mdr->ref);
+    }
+    dout(10) << "rdlock_path_pin_ref had " << *mdr->ref << dendl;
     return mdr->ref;
+  }
 
   MClientRequest *req = mdr->client_request;
 
@@ -1330,6 +1329,15 @@ CDentry* Server::rdlock_path_xlock_dentry(MDRequest *mdr, bool okexist, bool mus
 {
   MClientRequest *req = mdr->client_request;
 
+  dout(10) << "rdlock_path_xlock_dentry " << *mdr << dendl;
+
+  if (mdr->ref) {
+    CDentry *last = mdr->trace[mdr->trace.size()-1];
+    assert(last->get_inode() == mdr->ref);
+    dout(10) << "rdlock_path_xlock_dentry had " << *last << " " << *mdr->ref << dendl;
+    return last;
+  }
+
   vector<CDentry*> trace;
   CDir *dir = traverse_to_auth_dir(mdr, trace, req->get_filepath());
   if (!dir) return 0;
@@ -3900,6 +3908,8 @@ void Server::handle_client_open(MDRequest *mdr)
 
   bool need_auth = !file_mode_is_readonly(cmode) || (flags & O_TRUNC);
 
+  dout(7) << "open on " << req->get_filepath() << dendl;
+
   CInode *cur = rdlock_path_pin_ref(mdr, need_auth);
   if (!cur) return;
 
@@ -4123,6 +4133,8 @@ void Server::handle_client_openc(MDRequest *mdr)
     } 
     
     // pass to regular open handler.
+    mdr->trace.push_back(dn);
+    mdr->ref = dn->get_inode();
     handle_client_open(mdr);
     return;
   }