]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add policylock to the inodes.
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 22 Sep 2010 21:48:39 +0000 (14:48 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Wed, 22 Sep 2010 21:48:39 +0000 (14:48 -0700)
This will be used to cover per-directory default file distribution
policies, and maybe other things that come up.

src/include/ceph_fs.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/Migrator.cc
src/mds/SimpleLock.h

index 8c06e0de1e4341cc5ba569ca49e316fa04fb51f5..ba122f3794f51d653f1578fe214c77ff96bda9fc 100644 (file)
@@ -262,6 +262,7 @@ extern const char *ceph_mds_state_name(int s);
 #define CEPH_LOCK_IXATTR      2048
 #define CEPH_LOCK_IFLOCK      4096  /* advisory file locks */
 #define CEPH_LOCK_INO         8192  /* immutable inode bits; not a lock */
+#define CEPH_LOCK_IPOLICY     16384 /* policy lock on dirs. MDS internal */
 
 /* client_session ops */
 enum {
index f8799cf6122260932544814037f99b36280bbf62..99e8237d2febb93eaf79afb8e464da7fcd3a2156 100644 (file)
@@ -58,6 +58,7 @@ LockType CInode::xattrlock_type(CEPH_LOCK_IXATTR);
 LockType CInode::snaplock_type(CEPH_LOCK_ISNAP);
 LockType CInode::nestlock_type(CEPH_LOCK_INEST);
 LockType CInode::flocklock_type(CEPH_LOCK_IFLOCK);
+LockType CInode::policylock_type(CEPH_LOCK_IPOLICY);
 
 //int cinode_pins[CINODE_NUM_PINS];  // counts
 ostream& CInode::print_db_line_prefix(ostream& out)
@@ -164,6 +165,8 @@ ostream& operator<<(ostream& out, CInode& in)
       out << " " << in.snaplock;
     if (!in.nestlock.is_sync_and_unlocked())
       out << " " << in.nestlock;
+    if (!in.policylock.is_sync_and_unlocked())
+      out << " " << in.policylock;
   } else  {
     if (!in.flocklock.is_sync_and_unlocked())
       out << " " << in.flocklock;
@@ -2146,6 +2149,7 @@ void CInode::_encode_locks_full(bufferlist& bl)
   ::encode(snaplock, bl);
   ::encode(nestlock, bl);
   ::encode(flocklock, bl);
+  ::encode(policylock, bl);
 }
 void CInode::_decode_locks_full(bufferlist::iterator& p)
 {
@@ -2157,6 +2161,7 @@ void CInode::_decode_locks_full(bufferlist::iterator& p)
   ::decode(snaplock, p);
   ::decode(nestlock, p);
   ::decode(flocklock, p);
+  ::decode(policylock, p);
 }
 
 void CInode::_encode_locks_state_for_replica(bufferlist& bl)
@@ -2169,6 +2174,7 @@ void CInode::_encode_locks_state_for_replica(bufferlist& bl)
   xattrlock.encode_state_for_replica(bl);
   snaplock.encode_state_for_replica(bl);
   flocklock.encode_state_for_replica(bl);
+  policylock.encode_state_for_replica(bl);
 }
 void CInode::_decode_locks_state(bufferlist::iterator& p, bool is_new)
 {
@@ -2180,6 +2186,7 @@ void CInode::_decode_locks_state(bufferlist::iterator& p, bool is_new)
   xattrlock.decode_state(p, is_new);
   snaplock.decode_state(p, is_new);
   flocklock.decode_state(p, is_new);
+  policylock.decode_state(p, is_new);
 }
 void CInode::_decode_locks_rejoin(bufferlist::iterator& p, list<Context*>& waiters)
 {
@@ -2191,6 +2198,7 @@ void CInode::_decode_locks_rejoin(bufferlist::iterator& p, list<Context*>& waite
   xattrlock.decode_state_rejoin(p, waiters);
   snaplock.decode_state_rejoin(p, waiters);
   flocklock.decode_state_rejoin(p, waiters);
+  policylock.decode_state_rejoin(p, waiters);
 }
 
 
index cacd9a6a13de7fe88a5b0745f4a6c1dfb40b0ade..08ff5fbd6d8bd0b355c51db98f56ca51f138f613 100644 (file)
@@ -400,6 +400,7 @@ private:
     snaplock(this, &snaplock_type),
     nestlock(this, &nestlock_type),
     flocklock(this, &flocklock_type),
+    policylock(this, &policylock_type),
     loner_cap(-1), want_loner_cap(-1)
   {
     g_num_ino++;
@@ -573,6 +574,7 @@ public:
   static LockType snaplock_type;
   static LockType nestlock_type;
   static LockType flocklock_type;
+  static LockType policylock_type;
 
   LocalLock  versionlock;
   SimpleLock authlock;
@@ -583,6 +585,7 @@ public:
   SimpleLock snaplock;
   ScatterLock nestlock;
   SimpleLock flocklock;
+  SimpleLock policylock;
 
   SimpleLock* get_lock(int type) {
     switch (type) {
@@ -594,6 +597,7 @@ public:
     case CEPH_LOCK_ISNAP: return &snaplock;
     case CEPH_LOCK_INEST: return &nestlock;
     case CEPH_LOCK_IFLOCK: return &flocklock;
+    case CEPH_LOCK_IPOLICY: return &policylock;
     }
     return 0;
   }
@@ -929,6 +933,7 @@ public:
     snaplock.replicate_relax();
     nestlock.replicate_relax();
     flocklock.replicate_relax();
+    policylock.replicate_relax();
   }
 
 
index 9714f4f44ff161359cb2ff9bdcb448b7fbc3c1fe..f4d8b2d99baf6adc1c8ffe7b3b9c02efde66eb94 100644 (file)
@@ -630,6 +630,8 @@ bool Locker::eval(CInode *in, int mask)
     eval_any(&in->nestlock, &need_issue);
   if (mask & CEPH_LOCK_IFLOCK)
     eval_any(&in->flocklock, &need_issue);
+  if (mask & CEPH_LOCK_IPOLICY)
+    eval_any(&in->policylock, &need_issue);
 
   // drop loner?
   if (in->is_auth() && in->get_loner() >= 0 && in->get_wanted_loner() < 0) {
@@ -2592,6 +2594,7 @@ SimpleLock *Locker::get_lock(int lock_type, MDSCacheObjectInfo &info)
   case CEPH_LOCK_IXATTR:
   case CEPH_LOCK_ISNAP:
   case CEPH_LOCK_IFLOCK:
+  case CEPH_LOCK_IPOLICY:
     {
       CInode *in = mdcache->get_inode(info.ino, info.snapid);
       if (!in) {
@@ -2607,6 +2610,7 @@ SimpleLock *Locker::get_lock(int lock_type, MDSCacheObjectInfo &info)
       case CEPH_LOCK_IXATTR: return &in->xattrlock;
       case CEPH_LOCK_ISNAP: return &in->snaplock;
       case CEPH_LOCK_IFLOCK: return &in->flocklock;
+      case CEPH_LOCK_IPOLICY: return &in->policylock;
       }
     }
 
@@ -2639,6 +2643,7 @@ void Locker::handle_lock(MLock *m)
   case CEPH_LOCK_ISNAP:
   case CEPH_LOCK_IXATTR:
   case CEPH_LOCK_IFLOCK:
+  case CEPH_LOCK_IPOLICY:
     handle_simple_lock(lock, m);
     break;
     
index 95710178519bec8b12db3eab3fffbe2d594e4bc2..78d7c7fce2be4355d0090e3031178ffe877b8571 100644 (file)
@@ -5319,6 +5319,7 @@ void MDCache::inode_remove_replica(CInode *in, int from)
 
   if (in->nestlock.remove_replica(from)) mds->locker->eval_gather(&in->nestlock);
   if (in->flocklock.remove_replica(from)) mds->locker->eval_gather(&in->flocklock);
+  if (in->policylock.remove_replica(from)) mds->locker->eval_gather(&in->policylock);
 
   // trim?
   maybe_eval_stray(in);
index c9c6ad4bdefdbd71b492555e349d37fed3c28882..0b46daa5b0f0e06e11e41145e228ad7a6b1850e1 100644 (file)
@@ -1027,6 +1027,7 @@ void Migrator::finish_export_inode(CInode *in, utime_t now, list<Context*>& fini
   in->nestlock.export_twiddle();
   in->xattrlock.export_twiddle();
   in->snaplock.export_twiddle();
+  in->policylock.export_twiddle();
   
   // mark auth
   assert(in->is_auth());
index 2e06b279d7331a85d62127a2d52f834943a62802..2e385a93835465366111fea408651844cb1ab2c6 100644 (file)
@@ -33,6 +33,7 @@ inline const char *get_lock_type_name(int t) {
   case CEPH_LOCK_ISNAP: return "isnap";
   case CEPH_LOCK_INO: return "ino";
   case CEPH_LOCK_IFLOCK: return "iflock";
+  case CEPH_LOCK_IPOLICY: return "ipolicy";
   default: assert(0); return 0;
   }
 }
@@ -60,6 +61,7 @@ struct LockType {
     case CEPH_LOCK_IXATTR:
     case CEPH_LOCK_ISNAP:
     case CEPH_LOCK_IFLOCK:
+    case CEPH_LOCK_IPOLICY:
       sm = &sm_simplelock;
       break;
     case CEPH_LOCK_IDFT:
@@ -238,6 +240,7 @@ public:
     case CEPH_LOCK_ISNAP:    return 8 + 8*SimpleLock::WAIT_BITS;
     case CEPH_LOCK_INEST:    return 8 + 9*SimpleLock::WAIT_BITS;
     case CEPH_LOCK_IFLOCK:   return 8 +10*SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_IPOLICY:  return 8 +11*SimpleLock::WAIT_BITS;
     default:
       assert(0);
     }