From 4973560ebc70f231ea9c747ec230934eeab1c268 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 5 Mar 2014 14:39:05 +0800 Subject: [PATCH] mds: export file locks together with inode Signed-off-by: Yan, Zheng --- src/mds/CInode.cc | 16 +++++++++++++--- src/mds/CInode.h | 5 +++++ src/mds/Migrator.cc | 4 ++++ src/mds/flock.h | 10 ++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 93b8492f46cd8..122fd5247481d 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -3228,7 +3228,7 @@ void CInode::_decode_locks_rejoin(bufferlist::iterator& p, list& 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); } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 3977859821de1..7d2dd659b5968 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -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::item item_dirty; diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 233a5116410a0..1a4422182b3e0 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -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 dfs; in->get_dirfrags(dfs); diff --git a/src/mds/flock.h b/src/mds/flock.h index a98446d9b3969..4791b850c4f4f 100644 --- a/src/mds/flock.h +++ b/src/mds/flock.h @@ -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) -- 2.39.5