]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: clear the STATE_UNLINKING state when the unlink fails 48452/head
authorXiubo Li <xiubli@redhat.com>
Fri, 12 Aug 2022 00:41:53 +0000 (08:41 +0800)
committerXiubo Li <xiubli@redhat.com>
Wed, 12 Oct 2022 02:48:13 +0000 (10:48 +0800)
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 417f24782cfcf45827dff74adf8df2283b2a2c72)

src/mds/Server.cc

index 3e3e8f371c6d9b6d94beff9b31edee427c5292b7..6d2842e206788ca476d05e4d373212695de7d868 100644 (file)
@@ -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;
   }