]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
untested auth_pin changes; ctime changes (i am an idiot)
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Thu, 22 Feb 2007 04:37:22 +0000 (04:37 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Thu, 22 Feb 2007 04:37:22 +0000 (04:37 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1116 29311d96-e01e-0410-9327-a35deaab8ce9

branches/sage/cephmds2/client/Client.cc
branches/sage/cephmds2/include/types.h
branches/sage/cephmds2/mds/CDir.cc
branches/sage/cephmds2/mds/CDir.h
branches/sage/cephmds2/mds/CInode.cc
branches/sage/cephmds2/mds/CInode.h
branches/sage/cephmds2/mds/MDCache.cc
branches/sage/cephmds2/mds/Migrator.cc
branches/sage/cephmds2/mds/Server.cc

index b9556623d63748849ab9760f90a0d46688125223..f2f8f07432d4d32f7773ab6169c4ac70124c4c4a 100644 (file)
@@ -1471,7 +1471,7 @@ void Client::fill_stat(inode_t& inode, struct stat *st)
   st->st_nlink = inode.nlink;
   st->st_uid = inode.uid;
   st->st_gid = inode.gid;
-  st->st_ctime = inode.ctime;
+  st->st_ctime = MAX(inode.ctime, inode.mtime);
   st->st_atime = inode.atime;
   st->st_mtime = inode.mtime;
   st->st_size = inode.size;
@@ -1489,7 +1489,7 @@ void Client::fill_statlite(inode_t& inode, struct statlite *st)
   st->st_gid = inode.gid;
 #ifndef DARWIN
   // FIXME what's going on here with darwin?
-  st->st_ctime = inode.ctime;
+  st->st_ctime = MAX(inode.ctime, inode.mtime);
   st->st_atime = inode.atime;
   st->st_mtime = inode.mtime;
 #endif
index b09ee2d4726bed16f7c5be3c3563d55f6d322a01..e16fc17f2ccad5fe2a5e2b9236299555cb1ad370 100644 (file)
@@ -215,11 +215,12 @@ namespace __gnu_cxx {
 #define FILE_MODE_RW         (1|2)
 #define FILE_MODE_LAZY       4
 
-#define INODE_MASK_BASE       1  // ino, ctime, nlink
+#define INODE_MASK_BASE       1  // ino, nlink
 #define INODE_MASK_PERM       2  // uid, gid, mode
 #define INODE_MASK_SIZE       4  // size, blksize, blocks
-#define INODE_MASK_MTIME      8  // mtime
-#define INODE_MASK_ATIME      16 // atime
+#define INODE_MASK_CTIME      8  // ctime
+#define INODE_MASK_MTIME      16  // mtime
+#define INODE_MASK_ATIME      32 // atime
 
 #define INODE_MASK_ALL_STAT  (INODE_MASK_BASE|INODE_MASK_PERM|INODE_MASK_SIZE|INODE_MASK_MTIME)
 //#define INODE_MASK_ALL_STAT  (INODE_MASK_BASE|INODE_MASK_PERM|INODE_MASK_SIZE|INODE_MASK_MTIME|INODE_MASK_ATIME)
@@ -227,11 +228,11 @@ namespace __gnu_cxx {
 struct inode_t {
   // base (immutable)
   inodeno_t ino;   // NOTE: ino _must_ come first for MDStore.cc to behave!!
-  time_t    ctime;
 
-  // other
+  // other.
   FileLayout layout;  // ?immutable?
   int        nlink;   // base, 
+  time_t     ctime;   // inode change time
 
   // hard/perm (namespace permissions)
   mode_t     mode;
@@ -240,8 +241,9 @@ struct inode_t {
 
   // file (data access)
   off_t      size;
-  time_t     atime, mtime;      // maybe atime different?  "lazy"?
-  
+  time_t     mtime;   // file data modify time.
+  time_t     atime;   // file data access time.
   int        mask;
 
   // special stuff
index 13256cc1b3b447bafd8e67a10e567deea169a171..1abbe04a8593e86966c15e9b0924ec1d3e4a181e 100644 (file)
@@ -612,19 +612,25 @@ void CDir::set_dir_auth_pending(int d2)
  * AUTH PINS
  */
 
-void CDir::auth_pin() {
+void CDir::auth_pin() 
+{
   if (auth_pins == 0)
     get(PIN_AUTHPIN);
   auth_pins++;
 
   dout(7) << "auth_pin on " << *this << " count now " << auth_pins << " + " << nested_auth_pins << endl;
-  
-  inode->nested_auth_pins++;
-  if (inode->parent)
-    inode->parent->dir->adjust_nested_auth_pins( 1 );
+
+  // nest pins?
+  if (!is_subtree_root()) {
+    assert(!is_import());
+    inode->nested_auth_pins++;
+    if (inode->parent)
+      inode->parent->dir->adjust_nested_auth_pins( 1 );
+  }
 }
 
-void CDir::auth_unpin() {
+void CDir::auth_unpin() 
+{
   auth_pins--;
   if (auth_pins == 0)
     put(PIN_AUTHPIN);
@@ -636,9 +642,12 @@ void CDir::auth_unpin() {
   if (auth_pins + nested_auth_pins == 0)
     on_freezeable();
   
-  inode->nested_auth_pins--;
-  if (inode->parent)
-    inode->parent->dir->adjust_nested_auth_pins( -1 );
+  // nest?
+  if (!is_subtree_root()) {
+    inode->nested_auth_pins--;
+    if (inode->parent)
+      inode->parent->dir->adjust_nested_auth_pins( -1 );
+  }
 }
 
 void CDir::adjust_nested_auth_pins(int inc) 
index 0941cf1b599c0695dfbc95ffbe1040714d914d95..fe40bfc6e199b6fabb799f0dddacfe5d1cd8820e 100644 (file)
@@ -332,6 +332,14 @@ class CDir : public MDSCacheObject {
   void set_dir_auth(int d, int d2=CDIR_AUTH_UNKNOWN);
   void set_dir_auth_pending(int d2);
 
+  bool is_subtree_root() {
+    if (dir_auth != CDIR_AUTH_PARENT ||
+       dir_auth_pending != CDIR_AUTH_PARENT)
+      return true;
+    else 
+      return false;
+  }
+
  
 
   // for giving to clients
@@ -422,6 +430,7 @@ class CDir : public MDSCacheObject {
   // -- auth pins --
   bool can_auth_pin() { return !(is_frozen() || is_freezing()); }
   int is_auth_pinned() { return auth_pins; }
+  int get_cum_auth_pins() { return auth_pins + nested_auth_pins; }
   void auth_pin();
   void auth_unpin();
   void adjust_nested_auth_pins(int inc);
index 1ec367db74a0815addf3c597d74fdb7c7e22e39e..b7e68f866b8d8c576d018a17677baa717c27a537 100644 (file)
@@ -449,26 +449,28 @@ bool CInode::can_auth_pin() {
   return true;
 }
 
-void CInode::auth_pin() {
+void CInode::auth_pin() 
+{
   if (auth_pins == 0)
     get(PIN_AUTHPIN);
   auth_pins++;
 
   dout(7) << "auth_pin on " << *this << " count now " << auth_pins << " + " << nested_auth_pins << endl;
-
+  
   if (parent)
     parent->dir->adjust_nested_auth_pins( 1 );
 }
 
-void CInode::auth_unpin() {
+void CInode::auth_unpin() 
+{
   auth_pins--;
   if (auth_pins == 0)
     put(PIN_AUTHPIN);
-
+  
   dout(7) << "auth_unpin on " << *this << " count now " << auth_pins << " + " << nested_auth_pins << endl;
-
+  
   assert(auth_pins >= 0);
-
+  
   if (parent)
     parent->dir->adjust_nested_auth_pins( -1 );
 }
index 56a4149cebe3895b9c01fd9802674a3e49eaabd9..fa48764830d206daa040b18a78d12a41c14d0f0a 100644 (file)
@@ -186,7 +186,7 @@ protected:
 
 
  private:
-  // lock nesting
+  // auth pin
   int auth_pins;
   int nested_auth_pins;
 
index b09d7751f9f71c7233252a360a4e370cbbd74a11..f1fc11e2bd118775a951c8cb384d20c43e93e558 100644 (file)
@@ -1461,8 +1461,8 @@ CInode *MDCache::create_root_inode()
   // make it up (FIXME)
   root->inode.mode = 0755 | INODE_MODE_DIR;
   root->inode.size = 0;
-  root->inode.ctime = 0;
-  root->inode.mtime = g_clock.gettime();
+  root->inode.ctime = 
+    root->inode.mtime = g_clock.gettime();
   
   root->inode.nlink = 1;
   root->inode.layout = g_OSD_MDDirLayout;
index 39c728352f71ce3c1a0d5e7c812c1a16b6a60e58..b6778622e7471f20d0ce52e06d6b15a60d8abe05 100644 (file)
@@ -663,6 +663,8 @@ void Migrator::export_dir_go(CDir *dir)
   assert(export_bounds.count(dir) == 1);
   assert(export_data.count(dir) == 0);
 
+  assert(dir->get_cum_auth_pins() == 0);
+
   // update imports/exports
   CDir *containing_import = cache->get_auth_container(dir);
 
@@ -1058,6 +1060,8 @@ void Migrator::reverse_export(CDir *dir)
   if (dir != im)
     dout(10) << "  under " << *im << endl;
   
+  assert(dir->get_cum_auth_pins() == 0);
+
   // bounds
   for (set<CDir*>::iterator p = bounds.begin();
        p != bounds.end();
@@ -1613,6 +1617,8 @@ void Migrator::handle_export_dir(MExportDir *m)
   if (dir != im)
     dout(10) << "  under " << *im << endl;
 
+  assert(dir->get_cum_auth_pins() == 0);
+
   // bounds
   for (list<inodeno_t>::iterator it = m->get_exports().begin();
        it != m->get_exports().end();
@@ -1633,6 +1639,9 @@ void Migrator::handle_export_dir(MExportDir *m)
           ++q) 
        mds->mdcache->nested_exports[im].insert(*q);
       mds->mdcache->nested_exports.erase(bd);  
+
+      // adjust nested auth pins
+      bdi->adjust_nested_auth_pins(bd->get_cum_auth_pins());
     } else {
       // not me anymore.  now an export.
       mds->mdcache->exports.insert(bd);
index e9e41414ac2bf58b7ecddc540c78e1f4eb1f8d20..e7fbccc361c491275c85e3ec9d1a8593c65eb6d2 100644 (file)
@@ -620,6 +620,7 @@ void Server::handle_client_utime(MClientRequest *req,
   inode_t *pi = le->metablob.add_dentry(cur->parent, true);
   pi->mtime = mtime;
   pi->atime = mtime;
+  pi->ctime = g_clock.gettime();
   pi->version = pdv;
   
   mdlog->submit_entry(le);
@@ -683,6 +684,7 @@ void Server::handle_client_chmod(MClientRequest *req,
   inode_t *pi = le->metablob.add_dentry(cur->parent, true);
   pi->mode = mode;
   pi->version = pdv;
+  pi->ctime = g_clock.gettime();
   
   mdlog->submit_entry(le);
   mdlog->wait_for_sync(fin);
@@ -742,6 +744,7 @@ void Server::handle_client_chown(MClientRequest *req,
   if (uid >= 0) pi->uid = uid;
   if (gid >= 0) pi->gid = gid;
   pi->version = pdv;
+  pi->ctime = g_clock.gettime();
   
   mdlog->submit_entry(le);
   mdlog->wait_for_sync(fin);