Skip to content

Commit 5ad0df3

Browse files
committed
mds: generate correct path for unlinked snapped files
A snapped unlinked directory is moved to the stray directory. Files in that directory will not have correct stray_prior_path set because the snapshot was naturally taken before the file is unlinked. Use the parent directory's stray_prior_path for cephx path access controls. Fixes: https://tracker.ceph.com/issues/66828 Signed-off-by: Patrick Donnelly <[email protected]>
1 parent 6138176 commit 5ad0df3

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/mds/SessionMap.cc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,11 +1047,28 @@ int Session::check_access(CInode *in, unsigned mask,
10471047
<< dendl;
10481048

10491049
string path;
1050-
CInode *diri = NULL;
1051-
if (!in->is_base())
1052-
diri = in->get_projected_parent_dn()->get_dir()->get_inode();
1053-
if (diri && diri->is_stray()){
1054-
path = in->get_projected_inode()->stray_prior_path;
1050+
if (!in->is_base()) {
1051+
auto* dn = in->get_projected_parent_dn();
1052+
auto* pdiri = dn->get_dir()->get_inode();
1053+
if (pdiri) {
1054+
if (pdiri->is_stray()) {
1055+
path = in->get_projected_inode()->stray_prior_path;
1056+
} else if (!pdiri->is_base()) {
1057+
/* is the pdiri in the stray (is this inode in a snapshotted deleted directory?) */
1058+
auto* gpdiri = pdiri->get_projected_parent_dn()->get_dir()->get_inode();
1059+
/* stray_prior_path will not necessarily be part of the inode because
1060+
* it's set on unlink but that happens after the snapshot, naturally.
1061+
* We need to construct it manually.
1062+
*/
1063+
if (gpdiri->is_stray()) {
1064+
/* just check access on the parent dir */
1065+
path = pdiri->get_projected_inode()->stray_prior_path;
1066+
}
1067+
}
1068+
}
1069+
}
1070+
1071+
if (!path.empty()) {
10551072
dout(20) << __func__ << " stray_prior_path " << path << dendl;
10561073
} else {
10571074
in->make_path_string(path, true);

0 commit comments

Comments
 (0)