Skip to content

Commit

Permalink
mds: clear the STATE_UNLINKING state when the unlink fails
Browse files Browse the repository at this point in the history
Signed-off-by: Xiubo Li <xiubli@redhat.com>
  • Loading branch information
lxbsz committed Aug 12, 2022
1 parent d4b9431 commit 417f247
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mds/Server.cc
Expand Up @@ -6732,6 +6732,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);
Expand Down Expand Up @@ -7818,27 +7819,32 @@ 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;
}
} else {
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;
}
}

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? --
Expand Down Expand Up @@ -7877,6 +7883,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;
}

Expand Down

0 comments on commit 417f247

Please sign in to comment.