From: Sage Weil Date: Mon, 3 May 2010 23:41:16 +0000 (-0700) Subject: mds: add removal snap_seq to removed_snaps X-Git-Tag: v0.22~582^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ec68dcbd7bde29696e99a79bc99ac6dab643e00;p=ceph.git mds: add removal snap_seq to removed_snaps This prevents lots of fragmentation in removed_snaps interval set. --- diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index 2434b6821245..b576c76c0062 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -75,12 +75,14 @@ void SnapServer::_prepare(bufferlist &bl, __u64 reqid, int bymds) ::decode(ino, p); // not used, currently. ::decode(snapid, p); version++; - pending_destroy[version] = snapid; - dout(10) << "prepare v" << version << " destroy " << snapid << dendl; // bump last_snap... we use it as a version value on the snaprealm. - bl.clear(); ++last_snap; + + pending_destroy[version] = pair(snapid, last_snap); + dout(10) << "prepare v" << version << " destroy " << snapid << " seq " << last_snap << dendl; + + bl.clear(); ::encode(last_snap, bl); } break; @@ -107,14 +109,17 @@ void SnapServer::_commit(version_t tid) } else if (pending_destroy.count(tid)) { - snapid_t sn = pending_destroy[tid]; - dout(7) << "commit " << tid << " destroy " << sn << dendl; + snapid_t sn = pending_destroy[tid].first; + snapid_t seq = pending_destroy[tid].second; + dout(7) << "commit " << tid << " destroy " << sn << " seq " << seq << dendl; snaps.erase(sn); for (vector<__u32>::const_iterator p = mds->mdsmap->get_data_pg_pools().begin(); p != mds->mdsmap->get_data_pg_pools().end(); - p++) + p++) { need_to_purge[*p].insert(sn); + need_to_purge[*p].insert(seq); + } pending_destroy.erase(tid); } diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index 8380786b8d69..a8783f1c63d0 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -29,7 +29,7 @@ protected: map > need_to_purge; map pending_create; - map pending_destroy; + map > pending_destroy; // (removed_snap, seq) set pending_noop; version_t last_checked_osdmap; @@ -40,7 +40,7 @@ public: void reset_state(); void encode_server_state(bufferlist& bl) { - __u8 v = 1; + __u8 v = 2; ::encode(v, bl); ::encode(last_snap, bl); ::encode(snaps, bl); @@ -56,7 +56,14 @@ public: ::decode(snaps, bl); ::decode(need_to_purge, bl); ::decode(pending_create, bl); - ::decode(pending_destroy, bl); + if (v >= 2) + ::decode(pending_destroy, bl); + else { + map t; + ::decode(t, bl); + for (map::iterator p = t.begin(); p != t.end(); p++) + pending_destroy[p->first].first = p->second; + } ::decode(pending_noop, bl); }