Skip to content

Commit

Permalink
mds: retry rdlock_path_pin_ref if needs to fwd request to auth
Browse files Browse the repository at this point in the history
In case the _open() is called from _openc() the first
rdlock_path_pin_ref() will do nothing because the _openc() will
set the MutationImpl::PATH_LOCKED flag. And then we need to retry
it.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
  • Loading branch information
lxbsz committed Jul 19, 2023
1 parent 4e5d800 commit 96048af
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4368,7 +4368,7 @@ void Server::handle_client_open(MDRequestRef& mdr)
respond_to_request(mdr, -CEPHFS_EINVAL);
return;
}

bool need_auth = !file_mode_is_readonly(cmode) ||
(flags & (CEPH_O_TRUNC | CEPH_O_DIRECTORY));

Expand All @@ -4377,13 +4377,14 @@ void Server::handle_client_open(MDRequestRef& mdr)
respond_to_request(mdr, -CEPHFS_EROFS);
return;
}

CInode *cur = rdlock_path_pin_ref(mdr, need_auth);
if (!cur)
return;

if (cur->is_frozen() || cur->state_test(CInode::STATE_EXPORTINGCAPS)) {
ceph_assert(!need_auth);
// In case the _open() is called from _openc() the previous rdlock_path_pin_ref()
// will fail to forward the request to auth MDS, we need to retry it here.
if (need_auth || cur->is_frozen() || cur->state_test(CInode::STATE_EXPORTINGCAPS)) {
mdr->locking_state &= ~(MutationImpl::PATH_LOCKED | MutationImpl::ALL_LOCKED);
CInode *cur = rdlock_path_pin_ref(mdr, true);
if (!cur)
Expand All @@ -4402,7 +4403,7 @@ void Server::handle_client_open(MDRequestRef& mdr)
<< ", filemode = " << cmode
<< ", need_auth = " << need_auth
<< dendl;

// regular file?
/*if (!cur->inode.is_file() && !cur->inode.is_dir()) {
dout(7) << "not a file or dir " << *cur << dendl;
Expand All @@ -4428,7 +4429,7 @@ void Server::handle_client_open(MDRequestRef& mdr)
respond_to_request(mdr, -CEPHFS_EPERM);
return;
}

// snapped data is read only
if (mdr->snapid != CEPH_NOSNAP &&
((cmode & CEPH_FILE_MODE_WR) || req->may_write())) {
Expand Down

0 comments on commit 96048af

Please sign in to comment.