fixes for undeletable empty directory
cover fixes for undeletable empty directory
From: "Yan, Zheng" <[email protected]>
These two patches fix MDS restart issues that may corrupt the fragstat accounting and cause undeletable empty directory. These two patches, together with the patch "mds: fix journaling issue regarding rstat accounting", have passed overnight "fsstress + restart MDS every 120s" test. No undeletable directory was found.
These patches are also in:
git://github.com/ukernel/ceph.git wip-mds
Regards
Yan, Zheng
PATCH 1/2 mds: don't create bloom filter for incomplete dir
From: "Yan, Zheng" <[email protected]>
Creating bloom filter for incomplete dir that was added by log replay will confuse subsequent dir lookup and can create null dentry for existing file. The erroneous null dentry confuses the fragstat accounting and causes undeletable empty directory.
The fix is check if the dir is complete before creating the bloom filter. For the MDCache::trim_non_auth{,_subtree} cases, just do not call CDir::add_to_bloom because bloom filter is useless for replica.
--- src/mds/CDir.cc | 6 +++++- src/mds/MDCache.cc | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-)
src/mds/CDir.cc +5 -1
@@ -615,8 +615,12 @@ void CDir::unlink_inode_work( CDentry *dn ) void CDir::add_to_bloom(CDentry *dn) { - if (!bloom) + if (!bloom) { + /* not create bloom filter for incomplete dir that was added by log replay */ + if (!is_complete()) + return; bloom = new bloom_filter(100, 0.05, 0); + } /* This size and false positive probability is completely random.*/ bloom->insert(dn->name.c_str(), dn->name.size()); }
src/mds/MDCache.cc +7 -5
@@ -5498,9 +5498,10 @@ void MDCache::trim_dentry(CDentry *dn, map<int, MCacheExpire*>& expiremap) // adjust the dir state // NOTE: we can safely remove a clean, null dentry without effecting // directory completeness. - // (do this _before_ we unlink the inode, below!) + // (check this _before_ we unlink the inode, below!) + bool clear_complete = false; if (!(dnl->is_null() && dn->is_clean())) - dir->state_clear(CDir::STATE_COMPLETE); + clear_complete = true; // unlink the dentry if (dnl->is_remote()) {
@@ -5520,6 +5521,9 @@ void MDCache::trim_dentry(CDentry *dn, map<int, MCacheExpire*>& expiremap) // remove dentry dir->add_to_bloom(dn); dir->remove_dentry(dn); + + if (clear_complete) + dir->state_clear(CDir::STATE_COMPLETE); // reexport? if (dir->get_num_head_items() == 0 && dir->is_subtree_root())
@@ -5708,9 +5712,8 @@ void MDCache::trim_non_auth() else { assert(dnl->is_null()); } - dir->add_to_bloom(dn); + dir->remove_dentry(dn); - // adjust the dir state dir->state_clear(CDir::STATE_COMPLETE); // dir incomplete! }
@@ -5811,7 +5814,6 @@ bool MDCache::trim_non_auth_subtree(CDir *dir) dout(20) << "trim_non_auth_subtree(" << dir << ") removing inode " << in << " with dentry" << dn << dendl; dir->unlink_inode(dn); remove_inode(in); - dir->add_to_bloom(dn); dir->remove_dentry(dn); } else { dout(20) << "trim_non_auth_subtree(" << dir << ") keeping inode " << in << " with dentry " << dn <<dendl;
Signature · 1 line
1.7.11.7
PATCH 2/2 mds: journal remote inode's projected parent
In reply to Yan, ZhengFrom: "Yan, Zheng" <[email protected]>
Server::_rename_prepare() adds remote inode's parent instead of projected parent to the journal. So during journal replay, the journal entry for the rename operation will wrongly revert the remote inode's projected rename. This issue can be reproduced by:
touch file1
ln file1 file2
rm file1
mv file2 file3
After journal replay, file1 reappears and directory's fragstat gets corrupted.
--- src/mds/Server.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
src/mds/Server.cc +8 -7
@@ -5719,9 +5719,10 @@ void Server::_rename_prepare(MDRequest *mdr, } else if (destdnl->is_remote()) { if (oldin->is_auth()) { // auth for targeti - metablob->add_dir_context(oldin->get_parent_dir()); - mdcache->journal_cow_dentry(mdr, metablob, oldin->parent, CEPH_NOSNAP, 0, destdnl); - metablob->add_primary_dentry(oldin->parent, true, oldin); + metablob->add_dir_context(oldin->get_projected_parent_dir()); + mdcache->journal_cow_dentry(mdr, metablob, oldin->get_projected_parent_dn(), + CEPH_NOSNAP, 0, destdnl); + metablob->add_primary_dentry(oldin->get_projected_parent_dn(), true, oldin); } if (destdn->is_auth()) { // auth for dn, not targeti
@@ -5740,10 +5741,10 @@ void Server::_rename_prepare(MDRequest *mdr, if (destdn->is_auth()) metablob->add_remote_dentry(destdn, true, srcdnl->get_remote_ino(), srcdnl->get_remote_d_type()); - if (srci->get_parent_dn()->is_auth()) { // it's remote - metablob->add_dir_context(srci->get_parent_dir()); - mdcache->journal_cow_dentry(mdr, metablob, srci->get_parent_dn(), CEPH_NOSNAP, 0, srcdnl); - metablob->add_primary_dentry(srci->get_parent_dn(), true, srci); + if (srci->get_projected_parent_dn()->is_auth()) { // it's remote + metablob->add_dir_context(srci->get_projected_parent_dir()); + mdcache->journal_cow_dentry(mdr, metablob, srci->get_projected_parent_dn(), CEPH_NOSNAP, 0, srcdnl); + metablob->add_primary_dentry(srci->get_projected_parent_dn(), true, srci); } } else { if (destdn->is_auth() && !destdnl->is_null())
Signature · 1 line
1.7.11.7
Am 04.12.2012 09:09, schrieb Yan, Zheng:
Quoted 7 lines
These two patches fix MDS restart issues that may corrupt the fragstat accounting and cause undeletable empty directory. These two patches, together with the patch "mds: fix journaling issue regarding rstat accounting", have passed overnight "fsstress + restart MDS every 120s" test. No undeletable directory was found.
These patches are also in:
git://github.com/ukernel/ceph.gitwip-mds
Thank you very much for working on MDS issues, your work gave me some hope that our very long standing crashes at MDS failover could be fixed soon.
Right now, we have our four node test cluster running with 0.55 and your latest patches. Hopefully, today's stress test will work fine.
One question: with your latest patches, is a multiple MDS setup stable in your tests? So far, we only tried with max mds = 1. As our work load writes many small files, some load sharing for MDS would be nice to have. I would be willing to help with tests and reports, if needed.
Amon Ott
Signature · 17 lines
Dr. Amon Ott m-privacy GmbH Tel: +49 30 24342334 Am Köllnischen Park 1 Fax: +49 30 99296856 10179 Berlin http://www.m-privacy.de Amtsgericht Charlottenburg, HRB 84946 Geschäftsführer: Dipl.-Kfm. Holger Maczkowsky, Roman Maczkowsky GnuPG-Key-ID: 0x2DD3A649 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Amon Ott
Am 04.12.2012 09:09, schrieb Yan, Zheng:
Quoted 5 lines
These two patches fix MDS restart issues that may corrupt the fragstat accounting and cause undeletable empty directory. These two patches, together with the patch "mds: fix journaling issue regarding rstat accounting", have passed overnight "fsstress + restart MDS every 120s" test. No undeletable directory was found.
Quoted 6 lines
Quoted 2 lines
These patches are also in:
git://github.com/ukernel/ceph.gitwip-mdsThank you very much for working on MDS issues, your work gave me some hope that our very long standing crashes at MDS failover could be fixed soon.
Hi,
Sorry for the delay
Quoted 9 lines
Right now, we have our four node test cluster running with 0.55 and your latest patches. Hopefully, today's stress test will work fine.
One question: with your latest patches, is a multiple MDS setup stable in your tests? So far, we only tried with max mds = 1. As our work load writes many small files, some load sharing for MDS would be nice to have. I would be willing to help with tests and reports, if needed.
No, multiple MDS setup is still unstable.
Regards
Yan, Zheng
Quoted 2 lines
Amon Ott