]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fixed up client, mds
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 7 Aug 2007 21:01:24 +0000 (21:01 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 7 Aug 2007 21:01:24 +0000 (21:01 +0000)
* frag_t bug
* client stat mask handling
* client debug output cleanup
* potential CDir store/fecth problem with shrinkage

git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1598 29311d96-e01e-0410-9327-a35deaab8ce9

17 files changed:
branches/sage/mds/Makefile
branches/sage/mds/client/Client.cc
branches/sage/mds/client/Client.h
branches/sage/mds/client/SyntheticClient.cc
branches/sage/mds/config.cc
branches/sage/mds/include/frag.h
branches/sage/mds/include/lru.h
branches/sage/mds/include/types.h
branches/sage/mds/include/utime.h
branches/sage/mds/mds/CDir.cc
branches/sage/mds/mds/CInode.cc
branches/sage/mds/mds/MDS.cc
branches/sage/mds/mds/Server.cc
branches/sage/mds/mds/mdstypes.h
branches/sage/mds/messages/MClientReply.h
branches/sage/mds/osd/FakeStore.cc
branches/sage/mds/osd/osd_types.h

index 8bb5562316c835a08fcd1681d0339e36297859b5..ed84e550d66fcf2badba01eceffb9d2a31e91095 100644 (file)
@@ -13,7 +13,7 @@
 #  on issdm, it's /usr/local/mpich2/bin.
 
 # Hook for extra -I options, etc.
-EXTRA_CFLAGS = 
+EXTRA_CFLAGS =  -I${HOME}/include -L${HOME}/lib
 
 # base
 CFLAGS = -pg -g -Wall -I. -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE ${EXTRA_CFLAGS}
index 3ac1a1dfff40e2fca91b83c751e7bb23b22619a4..7be5d84c71b3a2933abb02e9425d4e0a9148ac32 100644 (file)
@@ -114,7 +114,7 @@ Client::Client(Messenger *m, MonMap *mm) : timer(client_lock)
   // 
   root = 0;
 
-  set_cache_size(g_conf.client_cache_size);
+  lru.lru_set_max(g_conf.client_cache_size);
 
   // file handles
   free_fh_set.insert(10, 1<<30);
@@ -254,7 +254,9 @@ void Client::trim_cache()
     Dentry *dn = (Dentry*)lru.lru_expire();
     if (!dn) break;  // done
     
-    //dout(10) << "trim_cache unlinking dn " << dn->name << " in dir " << hex << dn->dir->inode->inode.ino << endl;
+    dout(15) << "trim_cache unlinking dn " << dn->name 
+            << " in dir " << hex << dn->dir->parent_inode->inode.ino 
+            << endl;
     unlink(dn);
   }
 
@@ -279,6 +281,8 @@ Inode* Client::insert_inode(Dir *dir, InodeStat *st, const string& dname)
   dout(12) << "insert_inode " << dname << " ino " << st->inode.ino 
            << "  size " << st->inode.size
            << "  mtime " << st->inode.mtime
+          << "  mask " << st->mask
+          << " in dir " << dir->parent_inode->inode.ino
            << endl;
   
   if (dn) {
@@ -324,20 +328,27 @@ Inode* Client::insert_inode(Dir *dir, InodeStat *st, const string& dname)
   } else {
     // actually update info
     dout(12) << " stat inode mask is " << st->mask << endl;
-    dn->inode->inode = st->inode;
-    dn->inode->dirfragtree = st->dirfragtree;  // FIXME look at the mask!
+    if (st->mask & STAT_MASK_BASE) {
+      dn->inode->inode = st->inode;
+      dn->inode->dirfragtree = st->dirfragtree;  // FIXME look at the mask!
+    }
 
     // ...but don't clobber our mtime, size!
-    if ((dn->inode->mask & INODE_MASK_SIZE) == 0 &&
+    /* isn't this handled below?
+    if ((dn->inode->mask & STAT_MASK_SIZE) == 0 &&
         dn->inode->file_wr_size > dn->inode->inode.size) 
       dn->inode->inode.size = dn->inode->file_wr_size;
-    if ((dn->inode->mask & INODE_MASK_MTIME) == 0 &&
+    if ((dn->inode->mask & STAT_MASK_MTIME) == 0 &&
         dn->inode->file_wr_mtime > dn->inode->inode.mtime) 
       dn->inode->inode.mtime = dn->inode->file_wr_mtime;
+    */
   }
 
   // OK, we found it!
   assert(dn && dn->inode);
+
+  // save the mask
+  dn->inode->mask = st->mask;
   
   // or do we have newer size/mtime from writing?
   if (dn->inode->file_caps() & CAP_FILE_WR) {
@@ -348,7 +359,7 @@ Inode* Client::insert_inode(Dir *dir, InodeStat *st, const string& dname)
   }
 
   // symlink?
-  if ((dn->inode->inode.mode & INODE_TYPE_MASK) == INODE_MODE_SYMLINK) {
+  if (dn->inode->inode.is_symlink()) {
     if (!dn->inode->symlink) 
       dn->inode->symlink = new string;
     *(dn->inode->symlink) = st->symlink;
@@ -1475,7 +1486,6 @@ int Client::link(const char *existing, const char *newname)
 
 int Client::_link(const char *existing, const char *newname) 
 {
-  dout(3) << "op: client->link(\"" << existing << "\", \"" << newname << "\");" << endl;
   tout << "link" << endl;
   tout << existing << endl;
   tout << newname << endl;
@@ -1501,6 +1511,7 @@ int Client::_link(const char *existing, const char *newname)
   dout(10) << "link result is " << res << endl;
 
   trim_cache();
+  dout(3) << "link(\"" << existing << "\", \"" << newname << "\") = " << res << endl;
   return res;
 }
 
@@ -1515,11 +1526,9 @@ int Client::unlink(const char *relpath)
 
 int Client::_unlink(const char *path)
 {
-  dout(3) << "op: client->unlink\(\"" << path << "\");" << endl;
   tout << "unlink" << endl;
   tout << path << endl;
 
-
   MClientRequest *req = new MClientRequest(MDS_OP_UNLINK, messenger->get_myinst());
   req->set_path(path);
  
@@ -1545,6 +1554,7 @@ int Client::_unlink(const char *path)
   dout(10) << "unlink result is " << res << endl;
 
   trim_cache();
+  dout(3) << "unlink(\"" << path << "\") = " << res << endl;
   return res;
 }
 
@@ -1559,13 +1569,10 @@ int Client::rename(const char *relfrom, const char *relto)
 
 int Client::_rename(const char *from, const char *to)
 {
-
-  dout(3) << "op: client->rename(\"" << from << "\", \"" << to << "\");" << endl;
   tout << "rename" << endl;
   tout << from << endl;
   tout << to << endl;
 
-
   MClientRequest *req = new MClientRequest(MDS_OP_RENAME, messenger->get_myinst());
   req->set_path(from);
   req->set_sarg(to);
@@ -1583,6 +1590,7 @@ int Client::_rename(const char *from, const char *to)
   dout(10) << "rename result is " << res << endl;
 
   trim_cache();
+  dout(3) << "rename(\"" << from << "\", \"" << to << "\") = " << res << endl;
   return res;
 }
 
@@ -1598,12 +1606,10 @@ int Client::mkdir(const char *relpath, mode_t mode)
 
 int Client::_mkdir(const char *path, mode_t mode)
 {
-  dout(3) << "op: client->mkdir(\"" << path << "\", " << mode << ");" << endl;
   tout << "mkdir" << endl;
   tout << path << endl;
   tout << mode << endl;
 
-
   MClientRequest *req = new MClientRequest(MDS_OP_MKDIR, messenger->get_myinst());
   req->set_path(path);
   req->args.mkdir.mode = mode;
@@ -1621,6 +1627,8 @@ int Client::_mkdir(const char *path, mode_t mode)
   dout(10) << "mkdir result is " << res << endl;
 
   trim_cache();
+
+  dout(3) << "mkdir(\"" << path << "\", 0" << oct << mode << dec << ") = " << res << endl;
   return res;
 }
 
@@ -1634,11 +1642,9 @@ int Client::rmdir(const char *relpath)
 
 int Client::_rmdir(const char *path)
 {
-  dout(3) << "op: client->rmdir(\"" << path << "\");" << endl;
   tout << "rmdir" << endl;
   tout << path << endl;
 
-
   MClientRequest *req = new MClientRequest(MDS_OP_RMDIR, messenger->get_myinst());
   req->set_path(path);
  
@@ -1662,9 +1668,9 @@ int Client::_rmdir(const char *path)
   }
   insert_trace(reply);  
   delete reply;
-  dout(10) << "rmdir result is " << res << endl;
 
   trim_cache();
+  dout(3) << "rmdir(\"" << path << "\") = " << res << endl;
   return res;
 }
 
@@ -1681,12 +1687,10 @@ int Client::symlink(const char *reltarget, const char *rellink)
 
 int Client::_symlink(const char *target, const char *link)
 {
-  dout(3) << "op: client->symlink(\"" << target << "\", \"" << link << "\");" << endl;
   tout << "symlink" << endl;
   tout << target << endl;
   tout << link << endl;
 
-
   MClientRequest *req = new MClientRequest(MDS_OP_SYMLINK, messenger->get_myinst());
   req->set_path(link);
   req->set_sarg(target);
@@ -1701,9 +1705,9 @@ int Client::_symlink(const char *target, const char *link)
   int res = reply->get_result();
   insert_trace(reply);  //FIXME assuming trace of link, not of target
   delete reply;
-  dout(10) << "symlink result is " << res << endl;
 
   trim_cache();
+  dout(3) << "symlink(\"" << target << "\", \"" << link << "\") = " << res << endl;
   return res;
 }
 
@@ -1717,21 +1721,24 @@ int Client::readlink(const char *path, char *buf, off_t size)
 
 int Client::_readlink(const char *path, char *buf, off_t size) 
 { 
-  dout(3) << "op: client->readlink(\"" << path << "\", readlinkbuf, readlinkbuf_len);" << endl;
   tout << "readlink" << endl;
   tout << path << endl;
 
   Inode *in;
-  int r = _lstat(path, INODE_MASK_ALL_STAT, &in);
-  if (r != 0) return r;
-  
-  // copy into buf (at most size bytes)
-  unsigned res = in->symlink->length();
-  if (res > size) res = size;
-  memcpy(buf, in->symlink->c_str(), res);
-
+  int r = _lstat(path, STAT_MASK_BASE, &in);
+  if (r == 0 && !in->inode.is_symlink()) r = -EINVAL;
+  if (r == 0) {
+    // copy into buf (at most size bytes)
+    r = in->symlink->length();
+    if (r > size) r = size;
+    memcpy(buf, in->symlink->c_str(), r);
+  } else {
+    buf[0] = 0;
+  }
   trim_cache();
-  return res;  // return length in bytes (to mimic the system call)
+
+  dout(3) << "readlink(\"" << path << "\", \"" << buf << "\", " << size << ") = " << r << endl;
+  return r;
 }
 
 
@@ -1749,11 +1756,16 @@ int Client::_lstat(const char *path, int mask, Inode **in)
   Dentry *dn = lookup(fpath);
   inode_t inode;
   utime_t now = g_clock.real_now();
+
   if (dn && 
-      now <= dn->inode->valid_until &&
-      ((dn->inode->mask & INODE_MASK_ALL_STAT) == INODE_MASK_ALL_STAT)) {
+      now <= dn->inode->valid_until)
+    dout(10) << "_lstat has inode " << path << " with mask " << dn->inode->mask << ", want " << mask << endl;
+
+  if (dn && dn->inode &&
+      ((mask & ~STAT_MASK_BASE) || now <= dn->inode->valid_until) &&
+      ((dn->inode->mask & mask) == mask)) {
     inode = dn->inode->inode;
-    dout(10) << "lstat cache hit w/ sufficient inode.mask, valid until " << dn->inode->valid_until << endl;
+    dout(10) << "lstat cache hit w/ sufficient mask, valid until " << dn->inode->valid_until << endl;
     
     if (g_conf.client_cache_stat_ttl == 0)
       dn->inode->valid_until = utime_t();           // only one stat allowed after each readdir
@@ -1825,17 +1837,15 @@ int Client::lstat(const char *relpath, struct stat *stbuf)
 {
   client_lock.Lock();
 
+  tout << "lstat" << endl;
+  tout << relpath << endl;
+
   string abspath;
   mkabspath(relpath, abspath);
   const char *path = abspath.c_str();
 
-  dout(3) << "op: client->lstat(\"" << path << "\", &st);" << endl;
-  tout << "lstat" << endl;
-  tout << path << endl;
-
   Inode *in = 0;
-
-  int res = _lstat(path, INODE_MASK_ALL_STAT, &in);
+  int res = _lstat(path, STAT_MASK_ALL, &in);
   if (res == 0) {
     assert(in);
     fill_stat(in, stbuf);
@@ -1843,6 +1853,7 @@ int Client::lstat(const char *relpath, struct stat *stbuf)
   }
 
   trim_cache();
+  dout(3) << "lstat(\"" << relpath << "\", " << stbuf << ") = " << res << endl;
   client_lock.Unlock();
   return res;
 }
@@ -1894,12 +1905,10 @@ int Client::chmod(const char *relpath, mode_t mode)
 
 int Client::_chmod(const char *path, mode_t mode) 
 {
-  dout(3) << "op: client->chmod(\"" << path << "\", " << mode << ");" << endl;
   tout << "chmod" << endl;
   tout << path << endl;
   tout << mode << endl;
 
-
   MClientRequest *req = new MClientRequest(MDS_OP_CHMOD, messenger->get_myinst());
   req->set_path(path); 
   req->args.chmod.mode = mode;
@@ -1915,6 +1924,7 @@ int Client::_chmod(const char *path, mode_t mode)
   dout(10) << "chmod result is " << res << endl;
 
   trim_cache();
+  dout(3) << "chmod(\"" << path << "\", " << mode << ") = " << res << endl;
   return res;
 }
 
@@ -1928,7 +1938,6 @@ int Client::chown(const char *relpath, uid_t uid, gid_t gid)
 
 int Client::_chown(const char *path, uid_t uid, gid_t gid)
 {
-  dout(3) << "op: client->chown(\"" << path << "\", " << uid << ", " << gid << ");" << endl;
   tout << "chown" << endl;
   tout << path << endl;
   tout << uid << endl;
@@ -1952,6 +1961,7 @@ int Client::_chown(const char *path, uid_t uid, gid_t gid)
   dout(10) << "chown result is " << res << endl;
 
   trim_cache();
+  dout(3) << "chown(\"" << path << "\", " << uid << ", " << gid << ") = " << res << endl;
   return res;
 }
 
@@ -1965,8 +1975,6 @@ int Client::utime(const char *relpath, struct utimbuf *buf)
 
 int Client::_utime(const char *path, utime_t mtime, utime_t atime)
 {
-  dout(3) << "op: utim.actime = " << mtime << "; utim.modtime = " << atime << ";" << endl;
-  dout(3) << "op: client->utime(\"" << path << "\", &utim);" << endl;
   tout << "utime" << endl;
   tout << path << endl;
   tout << mtime.sec() << endl;
@@ -1981,14 +1989,12 @@ int Client::_utime(const char *path, utime_t mtime, utime_t atime)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
 
-  //FIXME enforce caller uid rights?
-   
   MClientReply *reply = make_request(req);
   int res = reply->get_result();
   insert_trace(reply);  
   delete reply;
-  dout(10) << "utime result is " << res << endl;
 
+  dout(3) << "utime(\"" << path << "\", " << mtime << ", " << atime << ") = " << res << endl;
   trim_cache();
   return res;
 }
@@ -2005,7 +2011,6 @@ int Client::mknod(const char *relpath, mode_t mode, dev_t rdev)
 
 int Client::_mknod(const char *path, mode_t mode, dev_t rdev) 
 { 
-  dout(3) << "op: client->mknod(\"" << path << "\", " << mode << ");" << endl;
   tout << "mknod" << endl;
   tout << path << endl;
   tout << mode << endl;
@@ -2025,11 +2030,11 @@ int Client::_mknod(const char *path, mode_t mode, dev_t rdev)
   int res = reply->get_result();
   insert_trace(reply);  
 
-  dout(10) << "mknod result is " << res << endl;
-
   delete reply;
 
   trim_cache();
+
+  dout(3) << "mknod(\"" << path << "\", " << mode << ") = " << res << endl;
   return res;
 }
 
@@ -2038,7 +2043,7 @@ int Client::_mknod(const char *path, mode_t mode, dev_t rdev)
   
 int Client::getdir(const char *relpath, list<string>& contents)
 {
-  dout(3) << "getdir " << relpath << endl;
+  dout(3) << "getdir(" << relpath << ")" << endl;
 
   DIR *d;
   int r = opendir(relpath, &d);
@@ -2078,17 +2083,14 @@ int Client::opendir(const char *name, DIR **dirpp)
   if (r < 0) {
     dout(3) << "opendir " << name << " err = " << r << endl;
     delete dirp;
-    return r;
+  } else {
+    // yay!
+    *((DirResult**)dirpp) = dirp;
+    dout(3) << "opendir(" << name << ") = " << dirp << endl;
   }
-  
-  // yay!
-  *((DirResult**)dirpp) = dirp;
-  
-  dout(3) << "opendir " << name << " = " << *dirpp << endl;
-  return 0;
+  return r;
 }
 
-
 void Client::_readdir_add_dirent(DirResult *dirp, const string& name, Inode *in)
 {
   struct stat st;
@@ -2103,7 +2105,7 @@ void Client::_readdir_add_dirent(DirResult *dirp, const string& name, unsigned c
   struct stat st;
   memset(&st, 0, sizeof(st));
   st.st_mode = DT_TO_MODE(d_type);
-  int stmask = InodeStat::MASK_TYPE;
+  int stmask = STAT_MASK_TYPE;
   frag_t fg = dirp->frag();
   dirp->buffer[fg].push_back(DirEntry(name, st, stmask));
   dout(10) << "_readdir_add_dirent added " << name << ", size now " << dirp->buffer[fg].size() << endl;
@@ -2306,11 +2308,13 @@ void Client::_readdir_fill_dirent(struct dirent *de, DirEntry *entry, off_t off)
   de->d_reclen = 1;
   de->d_type = MODE_TO_DT(entry->st.st_mode);
   strncpy(de->d_name, entry->d_name.c_str(), 256);
+  dout(10) << "_readdir_fill_dirent " << de->d_name << " " << de->d_ino
+          << " type " << (int)de->d_type << " at off " << off << endl;
 }
 
 int Client::closedir(DIR *dir) 
 {
-  dout(3) << "closedir " << dir << endl;
+  dout(3) << "closedir(" << dir << ") = 0" << endl;
 
   DirResult *dirp = (DirResult*)dir;
   if (dirp->inode) {
@@ -2325,6 +2329,7 @@ int Client::closedir(DIR *dir)
 
 void Client::rewinddir(DIR *dirp)
 {
+  dout(3) << "rewinddir(" << dirp << ")" << endl;
   DirResult *d = (DirResult*)dirp;
   d->offset = 0;
   d->buffer.clear();
@@ -2333,11 +2338,13 @@ void Client::rewinddir(DIR *dirp)
 off_t Client::telldir(DIR *dirp)
 {
   DirResult *d = (DirResult*)dirp;
+  dout(3) << "telldir(" << dirp << ") = " << d->offset << endl;
   return d->offset;
 }
 
 void Client::seekdir(DIR *dirp, off_t offset)
 {
+  dout(3) << "seekdir(" << dirp << ", " << offset << ")" << endl;
   DirResult *d = (DirResult*)dirp;
   d->offset = offset;
 }
@@ -2358,20 +2365,19 @@ int Client::open(const char *relpath, int flags, mode_t mode)
 
   Fh *fh;
   int r = _open(abspath.c_str(), flags, mode, &fh);
-  if (r < 0) return r;  // error
-
-  // allocate a integer file descriptor
-  assert(fh);
-  int fd = get_fh();
-  assert(fh_map.count(fd) == 0);
-  fh_map[fd] = fh;
-  dout(3) << "open allocated fd " << fd << " -> " << fh << endl;
-  return fd;
+  if (r >= 0) {
+    // allocate a integer file descriptor
+    assert(fh);
+    r = get_fh();
+    assert(fh_map.count(r) == 0);
+    fh_map[r] = fh;
+  } 
+  dout(3) << "open(" << relpath << ", " << flags << ") = " << r << endl;
+  return r;
 }
 
 int Client::_open(const char *path, int flags, mode_t mode, Fh **fhp) 
 {
-  dout(3) << "op: fh = client->open(\"" << path << "\", " << flags << ");" << endl;
   tout << "open" << endl;
   tout << path << endl;
   tout << flags << endl;
@@ -2401,6 +2407,8 @@ int Client::_open(const char *path, int flags, mode_t mode, Fh **fhp)
     if (fhp) *fhp = f;
     f->mode = cmode;
 
+    tout << (long)f << endl;
+
     // inode
     f->inode = inode_map[reply->get_ino()];
     assert(f->inode);
@@ -2452,6 +2460,7 @@ int Client::_open(const char *path, int flags, mode_t mode, Fh **fhp)
     dout(3) << "open success, fh is " << f << " combined caps " << cap_string(f->inode->file_caps()) << endl;
   } else {
     dout(0) << "open failure result " << result << endl;
+    tout << 0 << endl;
   }
 
   delete reply;
@@ -2493,6 +2502,7 @@ void Client::close_safe(Inode *in)
 int Client::close(fh_t fd)
 {
   Mutex::Locker lock(client_lock);
+  dout(3) << "close(" << fd << ")" << endl;
   assert(fh_map.count(fd));
   Fh *fh = fh_map[fd];
   _release(fh);
@@ -2504,7 +2514,7 @@ int Client::_release(Fh *f)
 {
   //dout(3) << "op: client->close(open_files[ " << fh << " ]);" << endl;
   //dout(3) << "op: open_files.erase( " << fh << " );" << endl;
-  dout(3) << "_release " << f << endl;
+  dout(5) << "_release " << f << endl;
   tout << "close" << endl;
   tout << f << endl;
 
@@ -2564,8 +2574,7 @@ int Client::_release(Fh *f)
 
 off_t Client::lseek(fh_t fh, off_t offset, int whence)
 {
-  client_lock.Lock();
-  dout(3) << "op: client->lseek(" << fh << ", " << offset << ", " << whence << ");" << endl;
+  Mutex::Locker lock(client_lock);
 
   assert(fh_map.count(fh));
   Fh *f = fh_map[fh];
@@ -2589,8 +2598,8 @@ off_t Client::lseek(fh_t fh, off_t offset, int whence)
   }
   
   off_t pos = f->pos;
-  client_lock.Unlock();
 
+  dout(3) << "lseek(" << fh << ", " << offset << ", " << whence << ") = " << pos << endl;
   return pos;
 }
 
@@ -2662,7 +2671,6 @@ int Client::_read(Fh *f, off_t offset, off_t size, bufferlist *bl)
     dout(10) << "file size: " << in->inode.size << endl;
     if (offset > 0 && offset >= in->inode.size) {
       if (movepos) unlock_fh_pos(f);
-      client_lock.Unlock();
       return 0;
     }
     if (offset + size > (off_t)in->inode.size) 
@@ -2671,7 +2679,6 @@ int Client::_read(Fh *f, off_t offset, off_t size, bufferlist *bl)
     if (size == 0) {
       dout(10) << "read is size=0, returning 0" << endl;
       if (movepos) unlock_fh_pos(f);
-      client_lock.Unlock();
       return 0;
     }
   } else {
index 6f8b5288e58d0938972a3f5f33dab1a8788aa6dc..ce9e169e35fb3fc0fec282b5084f753d9bbe91ff 100644 (file)
@@ -331,12 +331,12 @@ class Client : public Dispatcher {
 
   struct DirResult {
     static const int SHIFT = 28;
-    static const int MASK = 0xfffffff;
+    static const int64_t MASK = (1 << SHIFT) - 1;
     static const off_t END = 1ULL << (SHIFT + 32);
 
     string path;
     Inode *inode;
-    off_t offset;   // high bits: frag_t, low bits: an offset
+    int64_t offset;   // high bits: frag_t, low bits: an offset
     map<frag_t, vector<DirEntry> > buffer;
 
     DirResult(const char *p, Inode *in=0) : path(p), inode(in), offset(0) { 
@@ -358,6 +358,7 @@ class Client : public Dispatcher {
     }
     void set_frag(frag_t f) {
       offset = (uint64_t)f << SHIFT;
+      assert(sizeof(offset) == 8);
     }
     void set_end() { offset = END; }
     bool at_end() { return (offset == END); }
@@ -494,8 +495,8 @@ protected:
     put_inode(in);               // unpin inode
   }
 
-  int get_cache_size() { return lru.lru_get_size(); }
-  void set_cache_size(int m) { lru.lru_set_max(m); }
+  //int get_cache_size() { return lru.lru_get_size(); }
+  //void set_cache_size(int m) { lru.lru_set_max(m); }
 
   Dentry* link(Dir *dir, const string& name, Inode *in) {
     Dentry *dn = new Dentry;
index dfb72651f4e1d7dd32bd2d47b7815746de1c483d..7155034a9803ea1c5b2b751413d27538bd96e2b3 100644 (file)
@@ -2024,6 +2024,10 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data)
     f >> mtime;
     f.seekg(1, ios::cur);
     getline(f, filename);
+
+    // remove leading ./
+    if (filename[0] == '.' && filename[1] == '/')
+      filename = filename.substr(2);
     
     // parse the mode
     assert(modestring.length() == 10);
index 8dbc6928837d373ec96128d5ffe44b1a4b36af27..55cc31e4bdf1760236cefd80ef8d2576f6c4c71b 100644 (file)
@@ -140,7 +140,7 @@ md_config_t g_conf = {
   mon_allow_mds_bully: true,   // allow a booting mds to (forcibly) claim an mds #
 
   // --- client ---
-  client_cache_size: 300,
+  client_cache_size: 1000,
   client_cache_mid: .5,
   client_cache_stat_ttl: 0, // seconds until cached stat results become invalid
   client_cache_readdir_ttl: 1,  // 1 second only
index bdaf9f2b10a81692d24a7b50b480c5b07f033834..7c6c0a1a6c34ea57a350947180f145090fdf45f8 100644 (file)
@@ -18,6 +18,7 @@
 #include <stdint.h>
 #include <map>
 #include <list>
+#include <iostream>
 #include "buffer.h"
 
 /*
@@ -83,7 +84,8 @@ class frag_t {
   // accessors
   unsigned value() const { return _enc & 0xffffff; }
   unsigned bits() const { return _enc >> 24; }
-  unsigned mask() const { return 0xffffffffUL >> (32-bits()); }
+  unsigned mask() const { return 0xffffffffULL >> (32-bits()); }
+
   operator _frag_t() const { return _enc; }
 
   // tests
@@ -103,7 +105,7 @@ class frag_t {
   }
 
   // splitting
-  void split(int nb, list<frag_t>& fragments) const {
+  void split(int nb, std::list<frag_t>& fragments) const {
     assert(nb > 0);
     unsigned nway = 1 << nb;
     for (unsigned i=0; i<nway; i++) 
@@ -146,9 +148,9 @@ class frag_t {
   }
 };
 
-inline ostream& operator<<(ostream& out, frag_t hb)
+inline std::ostream& operator<<(std::ostream& out, frag_t hb)
 {
-  return out << hex << hb.value() << dec << "/" << hb.bits();
+  return out << std::hex << hb.value() << std::dec << "/" << hb.bits();
 }
 
 
@@ -183,7 +185,7 @@ class fragtree_t {
 
   
   bool is_leaf(frag_t x) const {
-    list<frag_t> ls;
+    std::list<frag_t> ls;
     get_leaves_under_split(x, ls);
     if (!ls.empty() &&
        ls.front() == x)
@@ -194,15 +196,15 @@ class fragtree_t {
   /**
    * get_leaves -- list all leaves
    */
-  void get_leaves(list<frag_t>& ls) const {
+  void get_leaves(std::list<frag_t>& ls) const {
     return get_leaves_under_split(frag_t(), ls);
   }
 
   /**
    * get_leaves_under_split -- list all leaves under a known split point (or root)
    */
-  void get_leaves_under_split(frag_t under, list<frag_t>& ls) const {
-    list<frag_t> q;
+  void get_leaves_under_split(frag_t under, std::list<frag_t>& ls) const {
+    std::list<frag_t> q;
     q.push_back(under);
     while (!q.empty()) {
       frag_t t = q.front();
@@ -260,8 +262,8 @@ class fragtree_t {
   /**
    * get_leaves_under(x, ls) -- search for any leaves fully contained by x
    */
-  void get_leaves_under(frag_t x, list<frag_t>& ls) const {
-    list<frag_t> q;
+  void get_leaves_under(frag_t x, std::list<frag_t>& ls) const {
+    std::list<frag_t> q;
     q.push_back(get_branch(x));
     while (!q.empty()) {
       frag_t t = q.front();
@@ -281,7 +283,7 @@ class fragtree_t {
    * contains(fg) -- does fragtree contain the specific frag @x
    */
   bool contains(frag_t x) const {
-    list<frag_t> q;
+    std::list<frag_t> q;
     q.push_back(get_branch(x));
     while (!q.empty()) {
       frag_t t = q.front();
@@ -353,10 +355,10 @@ class fragtree_t {
   void try_assimilate_children(frag_t x) {
     int nb = get_split(x);
     if (!nb) return;
-    list<frag_t> children;
+    std::list<frag_t> children;
     x.split(nb, children);
     int childbits = 0;
-    for (list<frag_t>::iterator p = children.begin();
+    for (std::list<frag_t>::iterator p = children.begin();
         p != children.end();
         ++p) {
       int cb = get_split(*p);
@@ -365,7 +367,7 @@ class fragtree_t {
       childbits = cb;
     }
     // all children are split with childbits!
-    for (list<frag_t>::iterator p = children.begin();
+    for (std::list<frag_t>::iterator p = children.begin();
         p != children.end();
         ++p)
       _splits.erase(*p);
@@ -393,9 +395,9 @@ class fragtree_t {
       merge(parent, nb);
       split(parent, spread);
 
-      list<frag_t> subs;
+      std::list<frag_t> subs;
       parent.split(spread, subs);
-      for (list<frag_t>::iterator p = subs.begin();
+      for (std::list<frag_t>::iterator p = subs.begin();
           p != subs.end();
           ++p) 
        split(*p, nb - spread);
@@ -403,7 +405,7 @@ class fragtree_t {
 
     // x is now a leaf or split.  
     // hoover up any children.
-    list<frag_t> q;
+    std::list<frag_t> q;
     q.push_back(x);
     while (!q.empty()) {
       frag_t t = q.front();
@@ -444,9 +446,9 @@ class fragtree_t {
     ::_decode(_splits, bl, off);
   }
 
-  void print(ostream& out) {
+  void print(std::ostream& out) {
     out << "fragtree_t(";
-    list<frag_t> q;
+    std::list<frag_t> q;
     q.push_back(frag_t());
     while (!q.empty()) {
       frag_t t = q.front();
@@ -468,11 +470,11 @@ class fragtree_t {
   }
 };
 
-inline ostream& operator<<(ostream& out, fragtree_t& ft)
+inline std::ostream& operator<<(std::ostream& out, fragtree_t& ft)
 {
   out << "fragtree_t(";
   
-  list<frag_t> q;
+  std::list<frag_t> q;
   q.push_back(frag_t());
   while (!q.empty()) {
     frag_t t = q.front();
@@ -492,12 +494,12 @@ inline ostream& operator<<(ostream& out, fragtree_t& ft)
  * fragset_t -- a set of fragments
  */
 class fragset_t {
-  set<frag_t> _set;
+  std::set<frag_t> _set;
 
 public:
-  set<frag_t> &get() { return _set; }
-  set<frag_t>::iterator begin() { return _set.begin(); }
-  set<frag_t>::iterator end() { return _set.end(); }
+  std::set<frag_t> &get() { return _set; }
+  std::set<frag_t>::iterator begin() { return _set.begin(); }
+  std::set<frag_t>::iterator end() { return _set.end(); }
 
   bool empty() const { return _set.empty(); }
 
@@ -517,7 +519,7 @@ public:
   void simplify() {
     while (1) {
       bool clean = true;
-      set<frag_t>::iterator p = _set.begin();
+      std::set<frag_t>::iterator p = _set.begin();
       while (p != _set.end()) {
        if (!p->is_root() &&
            _set.count(p->get_sibling())) {
@@ -535,7 +537,7 @@ public:
   }
 };
 
-inline ostream& operator<<(ostream& out, fragset_t& fs) 
+inline std::ostream& operator<<(std::ostream& out, fragset_t& fs) 
 {
   return out << "fragset_t(" << fs.get() << ")";
 }
index 225204f151a0ab6e8451935ea97886d6b92b69a0..9b3a563fc22e3caa0f58308c657548ddcea14751 100644 (file)
@@ -129,7 +129,7 @@ class LRU {
   LRU(int max = 0) {
     lru_num = 0;
     lru_num_pinned = 0;
-    lru_midpoint = .9;
+    lru_midpoint = .6;
     lru_max = max;
   }
 
index b2179e197b7569d116d102096d84f546e918f6a9..eb293d7cc0bde16c562ac8267fc7bb8411f71c9b 100644 (file)
@@ -210,20 +210,21 @@ namespace __gnu_cxx {
 #define FILE_MODE_RW         (1|2)
 #define FILE_MODE_LAZY       4
 
-#define INODE_MASK_INO        1    // inode
-#define INODE_MASK_TYPE       2   // file type bits of the mode
-#define INODE_MASK_BASE       4   // ino, layout, symlink value
-#define INODE_MASK_AUTH       8   // uid, gid, mode
-#define INODE_MASK_LINK       16   // nlink, anchored
-#define INODE_MASK_FILE       32  // mtime, size.
-// atime?
-
-#define INODE_MASK_ALL_STAT  (INODE_MASK_BASE|INODE_MASK_AUTH|INODE_MASK_LINK|INODE_MASK_FILE)
-
-#define INODE_MASK_SIZE       INODE_MASK_FILE // size, blksize, blocks
-#define INODE_MASK_MTIME      INODE_MASK_FILE // mtime
-#define INODE_MASK_ATIME      INODE_MASK_FILE // atime
-#define INODE_MASK_CTIME      (INODE_MASK_FILE|INODE_MASK_AUTH|INODE_MASK_LINK) // ctime
+/** stat masks
+ */
+#define STAT_MASK_INO        1   // inode nmber
+#define STAT_MASK_TYPE       2   // file type bits of the mode
+#define STAT_MASK_BASE       4   // layout, symlink value
+#define STAT_MASK_AUTH       8   // uid, gid, mode
+#define STAT_MASK_LINK       16   // nlink, anchored
+#define STAT_MASK_FILE       32  // mtime, size.
+
+#define STAT_MASK_ALL        63
+
+#define STAT_MASK_SIZE       STAT_MASK_FILE // size, blksize, blocks
+#define STAT_MASK_MTIME      STAT_MASK_FILE // mtime
+#define STAT_MASK_ATIME      STAT_MASK_FILE // atime
+#define STAT_MASK_CTIME      (STAT_MASK_FILE|STAT_MASK_AUTH|STAT_MASK_LINK) // ctime
 
 inline int DT_TO_MODE(int dt) {
   switch (dt) {
index 41df4ae2ee017e3e4c5673f47700211c7cfcc707..7fef5a7f930d22634d68a03ab34fd9fb168fef32 100644 (file)
@@ -133,7 +133,7 @@ inline std::ostream& operator<<(std::ostream& out, const utime_t& t)
     time_t tt = t.sec();
     localtime_r(&tt, &bdt);
     out << std::setw(2) << (bdt.tm_year-100)  // 2007 -> '07'
-       << std::setw(2) << bdt.tm_mon
+       << std::setw(2) << (bdt.tm_mon+1)
        << std::setw(2) << bdt.tm_mday
        << "."
        << std::setw(2) << bdt.tm_hour
index 89480467f20ce1956c8a11d23d96068e6f0b9588..86893a67271cf2106019f187a6b183fa00d3be03 100644 (file)
@@ -801,7 +801,10 @@ void CDir::_fetched(bufferlist &bl)
           << ", " << len << " bytes"
           << endl;
   
-  while (off < len) {
+  int32_t n;
+  ::_decode(n, bl, off);
+
+  for (int i=0; i<n; i++) {
     off_t dn_offset = off;
 
     // marker
@@ -1052,7 +1055,9 @@ void CDir::_commit(version_t want)
   bufferlist bl;
 
   ::_encode(version, bl);
-  
+  int32_t n = nitems;
+  ::_encode(n, bl);
+
   for (CDir_map_t::iterator it = items.begin();
        it != items.end();
        it++) {
@@ -1061,6 +1066,8 @@ void CDir::_commit(version_t want)
     if (dn->is_null()) 
       continue;  // skip negative entries
     
+    n--;
+
     // primary or remote?
     if (dn->is_remote()) {
       inodeno_t ino = dn->get_remote_ino();
@@ -1091,6 +1098,7 @@ void CDir::_commit(version_t want)
       in->dirfragtree._encode(bl);
     }
   }
+  assert(n == 0);
 
   // write it.
   cache->mds->objecter->write( get_ondisk_object(),
index d19cf66b832b93c83a28e3c6191bec654628bca2..45d3f6ecbf4ca51f72e055440ad8e9b99e941450 100644 (file)
@@ -378,7 +378,11 @@ void CInode::make_anchor_trace(vector<Anchor>& trace)
 void CInode::name_stray_dentry(string& dname)
 {
   char s[20];
+#ifdef __LP64__
   sprintf(s, "%ld", inode.ino.val);
+#else
+  sprintf(s, "%lld", inode.ino.val);
+#endif
   dname = s;
 }
 
index b67d78e85d7cc84a8a16762b0ad8d94321740120..13fc4594ae7743ae46a2c98f32f9e5776de2e6f6 100644 (file)
@@ -1288,7 +1288,7 @@ void MDS::ms_handle_failure(Message *m, const entity_inst_t& inst)
   mds_lock.Lock();
   dout(10) << "handle_ms_failure to " << inst << " on " << *m << endl;
   
-  if (m->get_type() == MSG_CLIENT_RECONNECT
+  if (m->get_type() == MSG_MDS_MAP && m->get_dest().is_client()
     server->client_reconnect_failure(m->get_dest().num());
 
   delete m;
index 0e2fc79d33822be7b38be01f08b11f4ebe008099..caf26002619595341bd2d66131b2535d50dfba1c 100644 (file)
@@ -1282,12 +1282,12 @@ void Server::handle_client_stat(MDRequest *mdr)
   set<SimpleLock*> xlocks = mdr->xlocks;
   
   int mask = req->args.stat.mask;
-  if (mask & INODE_MASK_LINK) rdlocks.insert(&ref->linklock);
-  if (mask & INODE_MASK_AUTH) rdlocks.insert(&ref->authlock);
+  if (mask & STAT_MASK_LINK) rdlocks.insert(&ref->linklock);
+  if (mask & STAT_MASK_AUTH) rdlocks.insert(&ref->authlock);
   if (ref->is_file() && 
-      mask & INODE_MASK_FILE) rdlocks.insert(&ref->filelock);
+      mask & STAT_MASK_FILE) rdlocks.insert(&ref->filelock);
   if (ref->is_dir() &&
-      mask & INODE_MASK_MTIME) rdlocks.insert(&ref->dirlock);
+      mask & STAT_MASK_MTIME) rdlocks.insert(&ref->dirlock);
 
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
@@ -1470,11 +1470,10 @@ int Server::encode_dir_contents(CDir *dir,
       assert(dn->is_remote());
       dout(12) << "including inode-less (remote) dentry " << *dn << endl;
       st = new InodeStat;
-      st->mask = 0;
+      st->mask = STAT_MASK_INO | STAT_MASK_TYPE;
       memset(&st->inode, 0, sizeof(st->inode));
       st->inode.ino = dn->get_remote_ino();
       st->inode.mode = DT_TO_MODE(dn->get_remote_d_type());
-      st->mask = InodeStat::MASK_INO | InodeStat::MASK_TYPE;
     }
 
     dnls.push_back( it->first );
index cb16a4b05d8acf9d8d799f690252b26406b0aa06..0341385ccc3fce17f5577ddc57df0e8bda56a80e 100644 (file)
@@ -35,6 +35,7 @@ using namespace std;
 #define MDS_INO_ROOT              1
 #define MDS_INO_PGTABLE           2
 #define MDS_INO_ANCHORTABLE       3
+#define MDS_INO_PG                4       // this should match osd/osd_types.h PG_INO
 #define MDS_INO_LOG_OFFSET        0x100
 #define MDS_INO_IDS_OFFSET        0x200
 #define MDS_INO_CLIENTMAP_OFFSET  0x300
index eff1636ce0e18480fb258aa2f74901e52af7ed79..24b7eae8976b754945207cdbda570e29e9d43bb8 100644 (file)
@@ -52,14 +52,6 @@ class CInode;
 
 class InodeStat {
  public:
-  const static int MASK_INO = 1;
-  const static int MASK_TYPE = 2;
-  const static int MASK_BASE = 4;
-  const static int MASK_AUTH = 8;
-  const static int MASK_LINK = 16;
-  const static int MASK_FILE = 32;
-  const static int MASK_ALL = 0xffff;
-
   inode_t inode;
   string  symlink;   // symlink content (if symlink)
   fragtree_t dirfragtree;
@@ -73,12 +65,13 @@ class InodeStat {
  public:
   InodeStat() {}
   InodeStat(CInode *in, int whoami) :
-    inode(in->inode)
+    inode(in->inode),
+    mask(STAT_MASK_INO|STAT_MASK_TYPE|STAT_MASK_BASE)
   {
-    // inode.mask
-    if (!in->authlock.can_rdlock(0)) mask &= ~MASK_AUTH;
-    if (!in->linklock.can_rdlock(0)) mask &= ~MASK_LINK;
-    if (!in->filelock.can_rdlock(0)) mask &= ~MASK_FILE;
+    // mask
+    if (in->authlock.can_rdlock(0)) mask |= STAT_MASK_AUTH;
+    if (in->linklock.can_rdlock(0)) mask |= STAT_MASK_LINK;
+    if (in->filelock.can_rdlock(0)) mask |= STAT_MASK_FILE;
     
     // symlink content?
     if (in->is_symlink()) 
index f6c7cc116c3ed3eb5366853583ce31f541868b56..c945357c11586a9d1e5508027730c33abf885957 100644 (file)
@@ -307,10 +307,11 @@ int FakeStore::write(object_t oid,
                      const bufferlist& bl, 
                      Context *onsafe)
 {
-  dout(20) << "write " << oid << " len " << len << " off " << offset << endl;
-
   char fn[200];
   get_oname(oid,fn);
+
+  dout(20) << "write " << fn << " len " << len << " off " << offset << endl;
+
   
   ::mknod(fn, 0644, 0);  // in case it doesn't exist yet.
 
@@ -547,10 +548,9 @@ int FakeStore::list_collections(list<coll_t>& ls)
   struct dirent *de;
   while ((de = ::readdir(dir)) != 0) {
     // parse
+    errno = 0;
     coll_t c = strtoll(de->d_name, 0, 16);
-    dout(0) << " got " << c << " errno " << errno << " on " << de->d_name << endl;
-    if (errno) continue;
-    ls.push_back(c);
+    if (c) ls.push_back(c);
   }
   
   ::closedir(dir);
index da36465391644ed5e7952ad890fa81161301479a..b761ae36d3d0e6da910a1ec439aa587db4e4923c 100644 (file)
@@ -67,7 +67,7 @@ typedef uint64_t coll_t;        // collection id
 
 // pg stuff
 
-#define PG_INO 1
+#define PG_INO 4    // this should match mds/mdstypes.h MDS_INO_PG
 
 typedef uint16_t ps_t;
 typedef uint8_t pruleset_t;