// purge stale snaps?
// only if we have past_parents open!
+ bool force_dirty = false;
const set<snapid_t> *snaps = NULL;
SnapRealm *realm = inode->find_snaprealm();
if (!realm->have_past_parents_open()) {
dout(10) << " snap_purged_thru " << fnode.snap_purged_thru
<< " < " << realm->get_last_destroyed()
<< ", snap purge based on " << *snaps << dendl;
- fnode.snap_purged_thru = realm->get_last_destroyed();
+ if (get_num_snap_items() == 0) {
+ fnode.snap_purged_thru = realm->get_last_destroyed();
+ force_dirty = true;
+ }
}
bool stray = inode->is_stray();
::decode(d_type, q);
if (stale) {
- if (!dn)
+ if (!dn) {
stale_items.insert(p->first);
+ force_dirty = true;
+ }
continue;
}
inode_data.decode_bare(q);
if (stale) {
- if (!dn)
+ if (!dn) {
stale_items.insert(p->first);
+ force_dirty = true;
+ }
continue;
}
}
// dirty myself to remove stale snap dentries
- if (!stale_items.empty() && !inode->mdcache->is_readonly())
+ if (force_dirty && !is_dirty() && !inode->mdcache->is_readonly())
log_mark_dirty();
auth_unpin(this);
dout(10) << " snap_purged_thru " << fnode.snap_purged_thru
<< " < " << realm->get_last_destroyed()
<< ", snap purge based on " << *snaps << dendl;
+ // fnode.snap_purged_thru = realm->get_last_destroyed();
}
set<string> to_remove;
snapid_t snapid = mdr->snapid;
dout(10) << "snapid " << snapid << dendl;
- // purge stale snap data?
- const set<snapid_t> *snaps = 0;
SnapRealm *realm = diri->find_snaprealm();
- if (realm->get_last_destroyed() > dir->fnode.snap_purged_thru) {
- snaps = &realm->get_snaps();
- dout(10) << " last_destroyed " << realm->get_last_destroyed() << " > " << dir->fnode.snap_purged_thru
- << ", doing snap purge with " << *snaps << dendl;
- dir->fnode.snap_purged_thru = realm->get_last_destroyed();
- assert(snapid == CEPH_NOSNAP || snaps->count(snapid)); // just checkin'!
- }
unsigned max = req->head.args.readdir.max_entries;
if (!max)
if (dnl->is_null())
continue;
- if (snaps && dn->last != CEPH_NOSNAP)
- if (dir->try_trim_snap_dentry(dn, *snaps))
- continue;
+
if (dn->last < snapid || dn->first > snapid) {
dout(20) << "skipping non-overlapping snap " << *dn << dendl;
continue;
::encode(complete, dirbl);
dirbl.claim_append(dnbl);
- if (snaps)
- dir->log_mark_dirty();
-
// yay, reply
dout(10) << "reply to " << *req << " readdir num=" << numfiles
<< " bytes=" << dirbl.length()