From bd3c8bc1b96304e2af7f375502ef4d1264f14b6b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 14 Aug 2014 14:52:40 -0700 Subject: [PATCH] mds/RecoveryQueue: add method to prioritize a file recovery; fix logging Add a prioritize() method to make file recovery start immediately for the given inode. Note that this doesn't respect the max recovery limit: if someone stats it, they are blocking, and we start the recovery immediately. Also fix up the dout logging a bit so that everything is prefixed consistently. Signed-off-by: Sage Weil --- src/mds/RecoveryQueue.cc | 72 +++++++++++++++++++++++++--------------- src/mds/RecoveryQueue.h | 7 ++-- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/mds/RecoveryQueue.cc b/src/mds/RecoveryQueue.cc index d4a5b264086ee..90ae65edf8e8c 100644 --- a/src/mds/RecoveryQueue.cc +++ b/src/mds/RecoveryQueue.cc @@ -22,7 +22,8 @@ #define dout_subsys ceph_subsys_mds - +#undef dout_prefix +#define dout_prefix *_dout << "mds." << mds->get_nodeid() << " RecoveryQueue::" << __func__ << " " class C_MDC_Recover : public MDSIOContextBase { protected: @@ -52,39 +53,58 @@ public: */ void RecoveryQueue::advance() { - dout(10) << "RecoveryQueue::advance " << file_recover_queue.size() << " queued, " + dout(10) << file_recover_queue.size() << " queued, " << file_recovering.size() << " recovering" << dendl; while (file_recovering.size() < g_conf->mds_max_file_recover && !file_recover_queue.empty()) { - CInode *in = *file_recover_queue.begin(); - file_recover_queue.erase(in); + _start(*file_recover_queue.begin()); + } +} - inode_t *pi = in->get_projected_inode(); +void RecoveryQueue::_start(CInode *in) +{ + file_recover_queue.erase(in); - // blech - if (pi->client_ranges.size() && !pi->get_max_size()) { - mds->clog.warn() << "bad client_range " << pi->client_ranges - << " on ino " << pi->ino << "\n"; - } + inode_t *pi = in->get_projected_inode(); - if (pi->client_ranges.size() && pi->get_max_size()) { - dout(10) << "do_file_recover starting " << in->inode.size << " " << pi->client_ranges - << " " << *in << dendl; - file_recovering.insert(in); - - C_MDC_Recover *fin = new C_MDC_Recover(this, in); - mds->filer->probe(in->inode.ino, &in->inode.layout, in->last, - pi->get_max_size(), &fin->size, &fin->mtime, false, - 0, fin); - } else { - dout(10) << "do_file_recover skipping " << in->inode.size - << " " << *in << dendl; - in->state_clear(CInode::STATE_RECOVERING); - mds->locker->eval(in, CEPH_LOCK_IFILE); - in->auth_unpin(this); - } + // blech + if (pi->client_ranges.size() && !pi->get_max_size()) { + mds->clog.warn() << "bad client_range " << pi->client_ranges + << " on ino " << pi->ino << "\n"; } + + if (pi->client_ranges.size() && pi->get_max_size()) { + dout(10) << "starting " << in->inode.size << " " << pi->client_ranges + << " " << *in << dendl; + file_recovering.insert(in); + + C_MDC_Recover *fin = new C_MDC_Recover(this, in); + mds->filer->probe(in->inode.ino, &in->inode.layout, in->last, + pi->get_max_size(), &fin->size, &fin->mtime, false, + 0, fin); + } else { + dout(10) << "skipping " << in->inode.size << " " << *in << dendl; + in->state_clear(CInode::STATE_RECOVERING); + mds->locker->eval(in, CEPH_LOCK_IFILE); + in->auth_unpin(this); + } +} + +void RecoveryQueue::prioritize(CInode *in) +{ + if (file_recovering.count(in)) { + dout(10) << "already working on " << *in << dendl; + return; + } + + if (file_recover_queue.count(in)) { + dout(20) << *in << dendl; + _start(in); + return; + } + + dout(10) << "not queued " << *in << dendl; } diff --git a/src/mds/RecoveryQueue.h b/src/mds/RecoveryQueue.h index 72d94acabaf37..41b2dcf0fedbf 100644 --- a/src/mds/RecoveryQueue.h +++ b/src/mds/RecoveryQueue.h @@ -23,12 +23,15 @@ class CInode; class MDS; class RecoveryQueue { - public: +public: void enqueue(CInode *in); void advance(); + void prioritize(CInode *in); ///< do this inode now/soon RecoveryQueue(MDS *mds_) : mds(mds_) {} - private: +private: + void _start(CInode *in); ///< start recovering this file + std::set file_recover_queue; std::set file_recovering; void _recovered(CInode *in, int r, uint64_t size, utime_t mtime); -- 2.39.5