From: Xiubo Li Date: Fri, 12 Aug 2022 00:41:53 +0000 (+0800) Subject: mds: clear the STATE_UNLINKING state when the unlink fails X-Git-Tag: v17.2.6~78^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bd7197236f947d2e1d92b1aa9cd3d22ec4892c29;p=ceph.git mds: clear the STATE_UNLINKING state when the unlink fails Signed-off-by: Xiubo Li (cherry picked from commit 417f24782cfcf45827dff74adf8df2283b2a2c72) --- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 3e3e8f371c6d9..6d2842e206788 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -6658,6 +6658,7 @@ bool Server::is_unlink_pending(CDentry *dn) void Server::wait_for_pending_unlink(CDentry *dn, MDRequestRef& mdr) { + dout(20) << __func__ << " dn " << *dn << dendl; mds->locker->drop_locks(mdr.get()); auto fin = new C_MDS_RetryRequest(mdcache, mdr); dn->get(CDentry::PIN_PURGING); @@ -7744,11 +7745,13 @@ void Server::handle_client_unlink(MDRequestRef& mdr) if (rmdir) { // do empty directory checks if (_dir_is_nonempty_unlocked(mdr, in)) { - respond_to_request(mdr, -CEPHFS_ENOTEMPTY); + dn->state_clear(CDentry::STATE_UNLINKING); + respond_to_request(mdr, -CEPHFS_ENOTEMPTY); return; } } else { dout(7) << "handle_client_unlink on dir " << *in << ", returning error" << dendl; + dn->state_clear(CDentry::STATE_UNLINKING); respond_to_request(mdr, -CEPHFS_EISDIR); return; } @@ -7756,6 +7759,7 @@ void Server::handle_client_unlink(MDRequestRef& mdr) if (rmdir) { // unlink dout(7) << "handle_client_rmdir on non-dir " << *in << ", returning error" << dendl; + dn->state_clear(CDentry::STATE_UNLINKING); respond_to_request(mdr, -CEPHFS_ENOTDIR); return; } @@ -7763,8 +7767,10 @@ void Server::handle_client_unlink(MDRequestRef& mdr) CInode *diri = dn->get_dir()->get_inode(); if ((!mdr->has_more() || mdr->more()->witnessed.empty())) { - if (!check_access(mdr, diri, MAY_WRITE)) + if (!check_access(mdr, diri, MAY_WRITE)) { + dn->state_clear(CDentry::STATE_UNLINKING); return; + } } // -- create stray dentry? -- @@ -7803,6 +7809,7 @@ void Server::handle_client_unlink(MDRequestRef& mdr) if (in->is_dir() && _dir_is_nonempty(mdr, in)) { respond_to_request(mdr, -CEPHFS_ENOTEMPTY); + dn->state_clear(CDentry::STATE_UNLINKING); return; }