]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: export file locks together with inode
authorYan, Zheng <zheng.z.yan@intel.com>
Wed, 5 Mar 2014 06:39:05 +0000 (14:39 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Wed, 19 Mar 2014 03:35:56 +0000 (11:35 +0800)
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Migrator.cc
src/mds/flock.h

index 93b8492f46cd814f5233e0d01e2d765971c85947..122fd5247481d558fb2a7998bc186362e87f2d6f 100644 (file)
@@ -3228,7 +3228,7 @@ void CInode::_decode_locks_rejoin(bufferlist::iterator& p, list<Context*>& waite
 
 void CInode::encode_export(bufferlist& bl)
 {
-  ENCODE_START(4, 4, bl)
+  ENCODE_START(5, 4, bl)
   _encode_base(bl);
 
   ::encode(state, bl);
@@ -3256,8 +3256,12 @@ void CInode::encode_export(bufferlist& bl)
   ::encode(bounding, bl);
 
   _encode_locks_full(bl);
-  get(PIN_TEMPEXPORTING);
+
+  ::encode(fcntl_locks, bl);
+  ::encode(flock_locks, bl);
   ENCODE_FINISH(bl);
+
+  get(PIN_TEMPEXPORTING);
 }
 
 void CInode::finish_export(utime_t now)
@@ -3277,7 +3281,7 @@ void CInode::finish_export(utime_t now)
 void CInode::decode_import(bufferlist::iterator& p,
                           LogSegment *ls)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(4, 4, 4, p);
+  DECODE_START_LEGACY_COMPAT_LEN(5, 4, 4, p);
 
   _decode_base(p);
 
@@ -3346,5 +3350,11 @@ void CInode::decode_import(bufferlist::iterator& p,
   }
 
   _decode_locks_full(p);
+
+  if (struct_v >= 5) {
+    ::decode(fcntl_locks, p);
+    ::decode(flock_locks, p);
+  }
+
   DECODE_FINISH(p);
 }
index 3977859821de11acda66525221fad1f5319531bf..7d2dd659b5968aadde9d2b8a30ab30923e5fc249 100644 (file)
@@ -390,6 +390,11 @@ protected:
   ceph_lock_state_t fcntl_locks;
   ceph_lock_state_t flock_locks;
 
+  void clear_file_locks() {
+    fcntl_locks.clear();
+    flock_locks.clear();
+  }
+
   // LogSegment dlists i (may) belong to
 public:
   elist<CInode*>::item item_dirty;
index 233a5116410a094ea35648d3bcce9026e2375fc0..1a4422182b3e09df558bb28f38b59a462fdb9bd4 100644 (file)
@@ -1346,6 +1346,8 @@ void Migrator::finish_export_inode(CInode *in, utime_t now, int peer,
 
   in->clear_dirty_parent();
 
+  in->clear_file_locks();
+
   // waiters
   in->take_waiting(CInode::WAIT_ANY_MASK, finished);
 
@@ -2361,6 +2363,8 @@ void Migrator::import_reverse(CDir *dir)
        in->dirfragtreelock.clear_gather();
        in->filelock.clear_gather();
 
+       in->clear_file_locks();
+
        // non-bounding dir?
        list<CDir*> dfs;
        in->get_dirfrags(dfs);
index a98446d9b39696a04b4e2326f9bb5bff6e6bff3e..4791b850c4f4f2a30ac437bbbc011077552bd7e1 100644 (file)
@@ -198,10 +198,20 @@ public:
   void encode(bufferlist& bl) const {
     ::encode(held_locks, bl);
     ::encode(waiting_locks, bl);
+    ::encode(client_held_lock_counts, bl);
+    ::encode(client_waiting_lock_counts, bl);
   }
   void decode(bufferlist::iterator& bl) {
     ::decode(held_locks, bl);
     ::decode(waiting_locks, bl);
+    ::decode(client_held_lock_counts, bl);
+    ::decode(client_waiting_lock_counts, bl);
+  }
+  void clear() {
+    held_locks.clear();
+    waiting_locks.clear();
+    client_held_lock_counts.clear();
+    client_waiting_lock_counts.clear();
   }
 };
 WRITE_CLASS_ENCODER(ceph_lock_state_t)