]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client tweaks, small mds bugfix, improved ll_lookup
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Aug 2007 23:51:31 +0000 (23:51 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Aug 2007 23:51:31 +0000 (23:51 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1635 29311d96-e01e-0410-9327-a35deaab8ce9

branches/sage/mds/client/Client.cc
branches/sage/mds/client/FileCache.cc
branches/sage/mds/client/SyntheticClient.cc
branches/sage/mds/mds/CDir.cc
branches/sage/mds/mds/Locker.cc

index 6f38f2bf8225e974b9b4555775e6bb2c7ff33058..a903d6417efb5b8abbdd5fdd69fafb6457e0f71f 100644 (file)
@@ -1370,12 +1370,11 @@ int Client::mount()
          << " and mdsmap " << mdsmap->get_epoch() 
          << endl;
 
-  /*
-  // hack: get+pin root inode
+  // hack: get+pin root inode.
+  //  fuse assumes it's always there.
   Inode *root;
   _do_lstat("/", STAT_MASK_ALL, &root);
   _ll_get(root);
-  */
 
   // trace?
   if (g_conf.client_trace) {
@@ -2890,7 +2889,8 @@ int Client::_write(Fh *f, off_t offset, off_t size, const char *buf)
   utime_t start = g_clock.real_now();
     
   // copy into fresh buffer (since our write may be resub, async)
-  bufferptr bp = buffer::copy(buf, size);
+  bufferptr bp;
+  if (size > 0) bp = buffer::copy(buf, size);
   bufferlist blist;
   blist.push_back( bp );
 
@@ -3254,55 +3254,40 @@ int Client::ll_lookup(inodeno_t parent, const char *name, struct stat *attr)
 
   string dname = name;
   Inode *diri = 0;
+  Inode *in = 0;
   int r = 0;
 
   if (inode_map.count(parent) == 0) {
-    tout << 0 << endl;
     dout(1) << "ll_lookup " << parent << " " << name << " -> ENOENT (parent DNE... WTF)" << endl;
     r = -ENOENT;
+    attr->st_ino = 0;
     goto out;
   }
   diri = inode_map[parent];
   if (!diri->inode.is_dir()) {
-    tout << 0 << endl;
     dout(1) << "ll_lookup " << parent << " " << name << " -> ENOTDIR (parent not a dir... WTF)" << endl;
     r = -ENOTDIR;
+    attr->st_ino = 0;
     goto out;
   }
 
-
-  // refresh the dir?
-  //  FIXME: this is the hackish way.
-  if (!diri->dir ||
-      diri->dir->dentries.count(dname) == 0) {
+  // get the inode
+  if (diri->dir &&
+      diri->dir->dentries.count(dname)) {
+    in = diri->dir->dentries[dname]->inode;
+  } else {
     string path;
     diri->make_path(path);
-    DirResult *dirp = new DirResult(path, diri);
-
-    while (1) {
-      hash<string> H;
-      dirp->set_frag(diri->dirfragtree[H(dname)]);
-
-      dout(10) << "ll_lookup fetching frag " << dirp->frag() << " for " << name << endl;
-      int r = _readdir_get_frag(dirp);
-      if (r < 0) return r;
-
-      if (dirp->buffer.count(diri->dirfragtree[H(dname)])) break;
-      dirp->buffer.clear();
-    }
-
-    _closedir(dirp);
+    path += "/";
+    path += name;
+    _do_lstat(path.c_str(), 0, &in);
   }
-
-  // do we have it?
-  if (diri->dir &&
-      diri->dir->dentries.count(dname)) {
-    Inode *in = diri->dir->dentries[dname]->inode;
+  if (in) {
     fill_stat(in, attr);
     _ll_get(in);
-    assert(inode_map[in->inode.ino] == in);
   } else {
     r = -ENOENT;
+    attr->st_ino = 0;
   }
 
  out:
@@ -3706,6 +3691,8 @@ int Client::ll_create(inodeno_t parent, const char *name, mode_t mode, int flags
     Inode *in = (*fhp)->inode;
     fill_stat(in, attr);
     _ll_get(in);
+  } else {
+    attr->st_ino = 0;
   }
   tout << (unsigned long)*fhp << endl;
   tout << attr->st_ino << endl;
index 0c5b6b1c9440aa3a4bed0f8c6c550203bac57953..33f1cf4bfd0b838ab7ecfde0e81eb74a4a45c122 100644 (file)
@@ -232,16 +232,18 @@ void FileCache::write(off_t offset, size_t size, bufferlist& blist, Mutex& clien
   // inc writing counter
   num_writing++;
 
-  if (latest_caps & CAP_FILE_WRBUFFER) {   // caps buffered write?
-    // wait? (this may block!)
-    oc->wait_for_write(size, client_lock);
-
-    // async, caching, non-blocking.
-    oc->file_write(inode, offset, size, blist);
-  } else {
-    // atomic, synchronous, blocking.
-    oc->file_atomic_sync_write(inode, offset, size, blist, client_lock);
-  }    
+  if (size > 0) {
+    if (latest_caps & CAP_FILE_WRBUFFER) {   // caps buffered write?
+      // wait? (this may block!)
+      oc->wait_for_write(size, client_lock);
+      
+      // async, caching, non-blocking.
+      oc->file_write(inode, offset, size, blist);
+    } else {
+      // atomic, synchronous, blocking.
+      oc->file_atomic_sync_write(inode, offset, size, blist, client_lock);
+    }    
+  }
     
   // dec writing counter
   num_writing--;
index 6e8b2da099f23ac77ed3d4d23b5ce6e2beb39370..68d3f3daf787ce7db3d2124081934a36f82a0d02 100644 (file)
@@ -830,6 +830,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
        memset(b, 1, size);            // let's write 1's!
        client->write(fd, b, size, off);
        delete[] b;
+      } else {
+       client->write(fd, NULL, 0, size+off);
       }
     } else if (strcmp(op, "truncate") == 0) {
       const char *a = t.get_string(buf, p);
@@ -982,6 +984,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
        bl.push_back(bp);
        bp.zero();
        client->ll_write(fh, off, size, bl.c_str());
+      } else {
+       client->ll_write(fh, off+size, 0, NULL);
       }
     } else if (strcmp(op, "ll_release") == 0) {
       int64_t f = t.get_int();
index b74d99c699695986f959dee6ab3cca0b926fd95b..c14d9de225f4fbc40ec259c82b33f8dae7ef8ca7 100644 (file)
@@ -931,7 +931,7 @@ void CDir::_fetched(bufferlist &bl)
       }
     }
   }
-  assert(off == len);
+  //assert(off == len);   no, directories may shrink.  add this back in when we properly truncate objects on write.
 
   // take the loaded version?
   // only if we are a fresh CDir* with no prior state.
index ea87fe8569b0bbc06271fbb0459ae393dceb3951..653f73154d101295ff1128084465919c0ac9fc18 100644 (file)
@@ -688,7 +688,7 @@ void Locker::handle_client_file_caps(MClientFileCaps *m)
         so, we don't want wanted reductions to clobber mds's notion of wanted unless we're
         sure the client has seen all the latest caps.
       */
-      dout(-10) << "handle_client_file_caps ignoring wanted " << cap_string(m->get_wanted())
+      dout(10) << "handle_client_file_caps ignoring wanted " << cap_string(m->get_wanted())
                << " bc seq " << m->get_seq() << " < " << cap->get_last_seq() << endl;
     } else {
       cap->set_wanted(wanted);