From f3d2dbf8bf1bb95549416c4b35649d38b3f20d17 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 17 Nov 2008 16:46:38 -0800 Subject: [PATCH] mds: unqueue recovery on purging inodes If an inode is queued for file size recovery when it is purged, unqueue it. This catches the log replay case where client reconnect queues up the inode. Also, in eval_stray, skip inodes that are queued. This should avoid a recovery running concurrently with the purge (which could be problematic, as it would carry a pointer to *in). --- src/mds/MDCache.cc | 12 ++++++++++++ src/mds/MDCache.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index e1440ff484432..1967d1de3b2eb 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -3925,6 +3925,14 @@ void MDCache::_queue_file_recover(CInode *in) file_recover_queue.insert(in); } +void MDCache::unqueue_file_recover(CInode *in) +{ + dout(15) << "unqueue_file_recover " << *in << dendl; + in->state_clear(CInode::STATE_RECOVERING); + in->auth_unpin(this); + file_recover_queue.erase(in); +} + /* * called after recovery to recover file sizes for previously opened (for write) * files. that is, those where max_size > size. @@ -6331,6 +6339,8 @@ void MDCache::eval_stray(CDentry *dn) if (dn->is_replicated() || in->is_any_caps()) return; // wait if (!in->dirfrags.empty()) return; // wait for dirs to close/trim if (dn->state_test(CDentry::STATE_PURGING)) return; // already purging + if (in->state_test(CInode::STATE_NEEDSRECOVER) || + in->state_test(CInode::STATE_RECOVERING)) return; // don't mess with file size probing purge_stray(dn); } else if (in->inode.nlink == 1) { @@ -6437,6 +6447,8 @@ void MDCache::_purge_stray_logged(CDentry *dn, version_t pdv, LogSegment *ls) CInode *in = dn->inode; if (in->is_dirty()) in->mark_clean(); + if (in->state_test(CInode::STATE_RECOVERING)) + unqueue_file_recover(in); if (dn->is_dirty()) dn->mark_clean(); remove_inode(in); diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 17bd319ea6a5a..c29b9906fd0f7 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -696,6 +696,7 @@ public: set file_recovering; void queue_file_recover(CInode *in); + void unqueue_file_recover(CInode *in); void _queued_file_recover_cow(CInode *in, Mutation *mut); void _queue_file_recover(CInode *in); void identify_files_to_recover(); -- 2.39.5