From 64bbb0b89920d0af36c7697eff0243b921110a1b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 5 Aug 2008 09:36:09 -0700 Subject: [PATCH] mds: send snap updates on snaplock update --- src/mds/CInode.cc | 11 ++++++---- src/mds/MDCache.cc | 55 ++++++++++++++++++++++++++++++++++++++++------ src/mds/MDCache.h | 3 ++- src/mds/Server.cc | 46 ++------------------------------------ src/mds/Server.h | 1 - src/vstartnew.sh | 4 ++-- 6 files changed, 61 insertions(+), 59 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 51907b59839bc..10b2ee157a497 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -838,11 +838,14 @@ void CInode::decode_lock_state(int type, bufferlist& bl) case CEPH_LOCK_ISNAP: { - bool had = snaprealm ? true:false; + snapid_t seq = 0; + if (snaprealm) + seq = snaprealm->seq; decode_snap(p); - if (!had && snaprealm) { - assert(!is_auth()); - mdcache->do_realm_split_notify(this); + if (snaprealm && snaprealm->seq != seq) { + if (!seq) + mdcache->do_realm_split_notify(this); + mdcache->do_realm_invalidate_and_update_notify(this, CEPH_SNAP_OP_UPDATE); } } break; diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 4cc111b5d90ab..85e9bf0815d6c 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -3541,7 +3541,7 @@ void MDCache::process_reconnected_caps() } reconnected_caps.clear(); - send_realm_splits(splits); + send_snaps(splits); } void MDCache::prepare_realm_split(SnapRealm *realm, int client, inodeno_t ino, @@ -3563,17 +3563,19 @@ void MDCache::prepare_realm_split(SnapRealm *realm, int client, inodeno_t ino, snap->split_inos.push_back(ino); } -void MDCache::send_realm_splits(map& splits) +void MDCache::send_snaps(map& splits) { - dout(10) << "send_realm_splits" << dendl; + dout(10) << "send_snaps" << dendl; for (map::iterator p = splits.begin(); p != splits.end(); p++) { Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(p->first)); if (session) { - dout(10) << " client" << p->first << " split " << p->second->split - << " inos " << p->second->split_inos << dendl; + dout(10) << " client" << p->first + << " split " << p->second->split + << " inos " << p->second->split_inos + << dendl; mds->send_message_client(p->second, session->inst); } else { dout(10) << " no session for client" << p->first << dendl; @@ -3705,7 +3707,7 @@ void MDCache::open_snap_parents() } } - send_realm_splits(splits); + send_snaps(splits); if (gather->get_num()) { dout(10) << "open_snap_parents - waiting for " << gather->get_num() << dendl; @@ -6160,7 +6162,46 @@ void MDCache::do_realm_split_notify(CInode *in) q.push_back(*p); } - send_realm_splits(updates); + send_snaps(updates); +} + +void MDCache::do_realm_invalidate_and_update_notify(CInode *in, int snapop) +{ + dout(10) << "do_realm_invalidate_and_update_notify " << *in->snaprealm << " " << *in << dendl; + + bufferlist snapbl; + in->snaprealm->build_snap_trace(snapbl); + + map updates; + list q; + q.push_back(in->snaprealm); + while (!q.empty()) { + SnapRealm *realm = q.front(); + q.pop_front(); + + dout(10) << " realm " << *realm + << " on " << *realm->inode << dendl; + realm->invalidate_cached_snaps(); + + for (map >::iterator p = realm->client_caps.begin(); + p != realm->client_caps.end(); + p++) { + assert(!p->second.empty()); + if (updates.count(p->first) == 0) { + MClientSnap *update = updates[p->first] = new MClientSnap(snapop); + update->bl = snapbl; + } + } + + // notify for active children, too. + dout(10) << " " << realm << " open_children are " << realm->open_children << dendl; + for (set::iterator p = realm->open_children.begin(); + p != realm->open_children.end(); + p++) + q.push_back(*p); + } + + send_snaps(updates); } void MDCache::_snaprealm_create_finish(MDRequest *mdr, Mutation *mut, CInode *in) diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 68e8609257599..da146020fe8fe 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -666,7 +666,8 @@ public: void prepare_realm_split(SnapRealm *realm, int client, inodeno_t ino, map& splits); void do_realm_split_notify(CInode *in); - void send_realm_splits(map& splits); + void do_realm_invalidate_and_update_notify(CInode *in, int snapop); + void send_snaps(map& splits); void rejoin_import_cap(CInode *in, int client, ceph_mds_cap_reconnect& icr, int frommds); void finish_snaprealm_reconnect(int client, SnapRealm *realm, snapid_t seq); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 696675ec7de4c..2e4134410365d 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -5067,7 +5067,7 @@ void Server::_mksnap_finish(MDRequest *mdr, CInode *diri, SnapInfo &info) diri->snaprealm->last_created = snapid; dout(10) << "snaprealm now " << *diri->snaprealm << dendl; - _invalidate_and_send_snap_updates(diri, CEPH_SNAP_OP_CREATE); + mdcache->do_realm_invalidate_and_update_notify(diri, CEPH_SNAP_OP_CREATE); // yay mdr->ref = diri; @@ -5078,48 +5078,6 @@ void Server::_mksnap_finish(MDRequest *mdr, CInode *diri, SnapInfo &info) reply_request(mdr, reply); } -void Server::_invalidate_and_send_snap_updates(CInode *diri, int snapop) -{ - bufferlist snapbl; - diri->snaprealm->build_snap_trace(snapbl); - - map updates; - list q; - q.push_back(diri->snaprealm); - while (!q.empty()) { - SnapRealm *realm = q.front(); - q.pop_front(); - - dout(10) << " realm " << *realm - << " on " << *realm->inode << dendl; - realm->invalidate_cached_snaps(); - - for (map >::iterator p = realm->client_caps.begin(); - p != realm->client_caps.end(); - p++) { - assert(!p->second.empty()); - if (updates.count(p->first) == 0) { - MClientSnap *update = updates[p->first] = new MClientSnap(snapop); - update->bl = snapbl; - } - } - - // notify for active children, too. - dout(10) << " " << realm << " open_children are " << realm->open_children << dendl; - for (set::iterator p = realm->open_children.begin(); - p != realm->open_children.end(); - p++) - q.push_back(*p); - } - - // send - for (map::iterator p = updates.begin(); - p != updates.end(); - p++) - mds->send_message_client(p->second, p->first); -} - - // RMSNAP @@ -5243,7 +5201,7 @@ void Server::_rmsnap_finish(MDRequest *mdr, CInode *diri, snapid_t snapid) diri->snaprealm->seq = stid; dout(10) << "snaprealm now " << *diri->snaprealm << dendl; - _invalidate_and_send_snap_updates(diri, CEPH_SNAP_OP_DESTROY); + mdcache->do_realm_invalidate_and_update_notify(diri, CEPH_SNAP_OP_DESTROY); // yay mdr->ref = diri; diff --git a/src/mds/Server.h b/src/mds/Server.h index 8fa30a54ceef2..35ab1555989ee 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -159,7 +159,6 @@ public: void handle_client_lssnap(MDRequest *mdr); void handle_client_mksnap(MDRequest *mdr); void _mksnap_finish(MDRequest *mdr, CInode *diri, SnapInfo &info); - void _invalidate_and_send_snap_updates(CInode *diri, int snapop); void handle_client_rmsnap(MDRequest *mdr); void _rmsnap_finish(MDRequest *mdr, CInode *diri, snapid_t snapid); diff --git a/src/vstartnew.sh b/src/vstartnew.sh index 8488f8b6052c1..ebf928d4946a5 100755 --- a/src/vstartnew.sh +++ b/src/vstartnew.sh @@ -44,8 +44,8 @@ done # mds ARGS="--mds_cache_size 500 --mds_log_max_segments 2 --debug_ms 1 --debug_mds 20" $CEPH_BIN/cmds -d $ARGS --mds_log_max_segments 2 --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20 -#$CEPH_BIN/cmds -d $ARGS --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20 -#./cmonctl mds set_max_mds 2 +$CEPH_BIN/cmds -d $ARGS --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20 +./cmonctl mds set_max_mds 2 echo "started. stop.sh to stop. see out/* (e.g. 'tail -f out/????') for debug output." -- 2.39.5