mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
mds: fix purging stale snapshot dentries
When fetching dirfrag, record stale snap dentries in CDir. So that CDir::_omap_commit can remove these stale dentires from OMAP. Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
parent
c173ceafad
commit
142a99d7c4
@ -1634,8 +1634,10 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
|
||||
* doesn't exist) but for which no explicit negative dentry is in
|
||||
* the cache.
|
||||
*/
|
||||
CDentry *dn = NULL;
|
||||
if (!stale)
|
||||
CDentry *dn;
|
||||
if (stale)
|
||||
dn = lookup_exact_snap(dname, last);
|
||||
else
|
||||
dn = lookup(dname, last);
|
||||
|
||||
if (type == 'L') {
|
||||
@ -1645,8 +1647,11 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
|
||||
::decode(ino, q);
|
||||
::decode(d_type, q);
|
||||
|
||||
if (stale)
|
||||
if (stale) {
|
||||
if (!dn)
|
||||
stale_items.insert(p->first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dn) {
|
||||
if (dn->get_linkage()->get_inode() == 0) {
|
||||
@ -1675,8 +1680,11 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
|
||||
InodeStore inode_data;
|
||||
inode_data.decode_bare(q);
|
||||
|
||||
if (stale)
|
||||
if (stale) {
|
||||
if (!dn)
|
||||
stale_items.insert(p->first);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool undef_inode = false;
|
||||
if (dn) {
|
||||
@ -1797,6 +1805,10 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
|
||||
cache->opened_undef_inode(in);
|
||||
}
|
||||
|
||||
// dirty myself to remove stale snap dentries
|
||||
if (!stale_items.empty() && !inode->mdcache->is_readonly())
|
||||
log_mark_dirty();
|
||||
|
||||
auth_unpin(this);
|
||||
|
||||
// kick waiters
|
||||
@ -1894,6 +1906,16 @@ void CDir::_omap_commit(int op_prio)
|
||||
object_t oid = get_ondisk_object();
|
||||
object_locator_t oloc(cache->mds->mdsmap->get_metadata_pool());
|
||||
|
||||
if (!stale_items.empty()) {
|
||||
for (compact_set<string>::iterator p = stale_items.begin();
|
||||
p != stale_items.end();
|
||||
++p) {
|
||||
to_remove.insert(*p);
|
||||
write_size += (*p).length();
|
||||
}
|
||||
stale_items.clear();
|
||||
}
|
||||
|
||||
for (map_t::iterator p = items.begin();
|
||||
p != items.end(); ) {
|
||||
CDentry *dn = p->second;
|
||||
|
@ -247,6 +247,7 @@ protected:
|
||||
version_t committing_version;
|
||||
version_t committed_version;
|
||||
|
||||
compact_set<string> stale_items;
|
||||
|
||||
// lock nesting, freeze
|
||||
static int num_frozen_trees;
|
||||
|
Loading…
Reference in New Issue
Block a user