From 3e66de21824f7c1dcced59c74e0905ac2e5d34ec Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 25 Dec 2016 16:45:09 +0000 Subject: [PATCH] mds: create purge queue if it's not found Signed-off-by: John Spray --- qa/tasks/cephfs/test_strays.py | 13 +++++++++++++ src/mds/PurgeQueue.cc | 18 +++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/qa/tasks/cephfs/test_strays.py b/qa/tasks/cephfs/test_strays.py index 24d8c9715e46a..4484f8d8cee47 100644 --- a/qa/tasks/cephfs/test_strays.py +++ b/qa/tasks/cephfs/test_strays.py @@ -881,3 +881,16 @@ class TestStrays(CephFSTestCase): path=self.mount_a.mountpoint, file_count=LOW_LIMIT ))) + + def test_purge_queue_upgrade(self): + """ + That when starting on a system with no purge queue in the metadata + pool, we silently create one. + :return: + """ + + self.mds_cluster.mds_stop() + self.mds_cluster.mds_fail() + self.fs.rados(["rm", "500.00000000"]) + self.mds_cluster.mds_restart() + self.fs.wait_for_daemons() \ No newline at end of file diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc index 7e57eabc7fa81..5249073dfa8c2 100644 --- a/src/mds/PurgeQueue.cc +++ b/src/mds/PurgeQueue.cc @@ -54,8 +54,6 @@ void PurgeItem::decode(bufferlist::iterator &p) DECODE_FINISH(p); } -// TODO: implement purge queue creation on startup -// if we are on a filesystem created before purge queues existed // TODO: when we're deactivating, lift all limits on // how many OSD ops we're allowed to emit at a time to // race through the queue as fast as we can. @@ -128,12 +126,18 @@ void PurgeQueue::open(Context *completion) Mutex::Locker l(lock); journaler.recover(new FunctionContext([this, completion](int r){ - Mutex::Locker l(lock); - dout(4) << "open complete" << dendl; - if (r == 0) { - journaler.set_writeable(); + if (r == -ENOENT) { + dout(1) << "Purge Queue not found, assuming this is an upgrade and " + "creating it." << dendl; + create(completion); + } else { + Mutex::Locker l(lock); + dout(4) << "open complete" << dendl; + if (r == 0) { + journaler.set_writeable(); + } + completion->complete(r); } - completion->complete(r); })); } -- 2.39.5