summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2013-09-04 15:14:11 +0800
committerYan, Zheng <zheng.z.yan@intel.com>2013-09-22 14:14:20 +0800
commit945eb3cbfc5d9e4578305b937bc9eb6097de1b1d (patch)
tree5caf43f9966aae5a2fdad17cabdab5617de519be
parent7be9b92d2ed40311fa3b3e1eb0fb2147315ab4c7 (diff)
downloadceph-945eb3cbfc5d9e4578305b937bc9eb6097de1b1d.tar.gz
mds: remove dirfrags when purging stray directory
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
-rw-r--r--src/mds/MDCache.cc33
-rw-r--r--src/mds/MDCache.h1
2 files changed, 18 insertions, 16 deletions
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index 5893e874d3d..9dc1229fbb9 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -9280,14 +9280,6 @@ void MDCache::fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Conte
mds->objecter->getxattr(oid, object_locator_t(pool), "parent", CEPH_NOSNAP, &bl, 0, fin);
}
-void MDCache::remove_backtrace(inodeno_t ino, int64_t pool, Context *fin)
-{
- SnapContext snapc;
- object_t oid = CInode::get_object_name(ino, frag_t(), "");
- mds->objecter->removexattr(oid, object_locator_t(pool), "parent", snapc,
- ceph_clock_now(g_ceph_context), 0, NULL, fin);
-}
-
class C_MDC_PurgeStrayPurged : public Context {
MDCache *cache;
CDentry *dn;
@@ -9326,15 +9318,28 @@ void MDCache::purge_stray(CDentry *dn)
// that is implicit in the dentry's presence and non-use in the stray
// dir. on recovery, we'll need to re-eval all strays anyway.
+ SnapContext nullsnapc;
+ C_GatherBuilder gather(g_ceph_context, new C_MDC_PurgeStrayPurged(this, dn));
+
if (in->is_dir()) {
- dout(10) << "purge_stray dir ... implement me!" << dendl; // FIXME XXX
- // remove the backtrace
- remove_backtrace(in->ino(), mds->mdsmap->get_metadata_pool(),
- new C_MDC_PurgeStrayPurged(this, dn));
+ object_locator_t oloc(mds->mdsmap->get_metadata_pool());
+ list<frag_t> ls;
+ if (!in->dirfragtree.is_leaf(frag_t()))
+ in->dirfragtree.get_leaves(ls);
+ ls.push_back(frag_t());
+ for (list<frag_t>::iterator p = ls.begin();
+ p != ls.end();
+ ++p) {
+ object_t oid = CInode::get_object_name(in->inode.ino, *p, "");
+ dout(10) << "purge_stray remove dirfrag " << oid << dendl;
+ mds->objecter->remove(oid, oloc, nullsnapc, ceph_clock_now(g_ceph_context),
+ 0, NULL, gather.new_sub());
+ }
+ assert(gather.has_subs());
+ gather.activate();
return;
}
- SnapContext nullsnap;
const SnapContext *snapc;
SnapRealm *realm = in->find_snaprealm();
if (realm) {
@@ -9346,8 +9351,6 @@ void MDCache::purge_stray(CDentry *dn)
assert(in->last == CEPH_NOSNAP);
}
- C_GatherBuilder gather(g_ceph_context, new C_MDC_PurgeStrayPurged(this, dn));
-
if (in->is_file()) {
uint64_t period = (uint64_t)in->inode.layout.fl_object_size *
(uint64_t)in->inode.layout.fl_stripe_count;
diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h
index f8764a658fe..d8f2a9486fb 100644
--- a/src/mds/MDCache.h
+++ b/src/mds/MDCache.h
@@ -885,7 +885,6 @@ public:
}
protected:
void fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Context *fin);
- void remove_backtrace(inodeno_t ino, int64_t pool, Context *fin);
void purge_stray(CDentry *dn);
void _purge_stray_purged(CDentry *dn, int r=0);
void _purge_stray_logged(CDentry *dn, version_t pdv, LogSegment *ls);