Skip to content

Commit b8fd8e7

Browse files
committed
mds: check for snapshots on parent snaprealms
The code was incorrectly only looking at snapshots in the current snaprealm. Fixes: https://tracker.ceph.com/issues/70912 Signed-off-by: Patrick Donnelly <[email protected]>
1 parent 58e5c94 commit b8fd8e7

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

src/mds/Server.cc

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6595,11 +6595,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
65956595
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
65966596
return;
65976597

6598-
if (_dir_is_nonempty(mdr, cur)) {
6599-
respond_to_request(mdr, -ENOTEMPTY);
6600-
return;
6601-
}
6602-
if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
6598+
if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
66036599
respond_to_request(mdr, -ENOTEMPTY);
66046600
return;
66056601
}
@@ -6627,11 +6623,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
66276623
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
66286624
return;
66296625

6630-
if (_dir_is_nonempty(mdr, cur)) {
6631-
respond_to_request(mdr, -ENOTEMPTY);
6632-
return;
6633-
}
6634-
if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
6626+
if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
66356627
respond_to_request(mdr, -ENOTEMPTY);
66366628
return;
66376629
}
@@ -6664,11 +6656,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
66646656
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
66656657
return;
66666658

6667-
if (_dir_is_nonempty(mdr, cur)) {
6668-
respond_to_request(mdr, -ENOTEMPTY);
6669-
return;
6670-
}
6671-
if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
6659+
if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
66726660
respond_to_request(mdr, -ENOTEMPTY);
66736661
return;
66746662
}
@@ -6692,11 +6680,7 @@ void Server::handle_client_setvxattr(const MDRequestRef& mdr, CInode *cur)
66926680
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
66936681
return;
66946682

6695-
if (_dir_is_nonempty(mdr, cur)) {
6696-
respond_to_request(mdr, -ENOTEMPTY);
6697-
return;
6698-
}
6699-
if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
6683+
if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
67006684
respond_to_request(mdr, -ENOTEMPTY);
67016685
return;
67026686
}
@@ -9225,6 +9209,16 @@ bool Server::_dir_is_nonempty_unlocked(const MDRequestRef& mdr, CInode *in)
92259209
return false;
92269210
}
92279211

9212+
bool Server::_dir_has_snaps(const MDRequestRef& mdr, CInode *diri)
9213+
{
9214+
dout(10) << __func__ << ": " << *diri << dendl;
9215+
ceph_assert(diri->is_auth());
9216+
ceph_assert(diri->snaplock.can_read(mdr->get_client()));
9217+
9218+
SnapRealm *realm = diri->find_snaprealm();
9219+
return !realm->get_snaps().empty();
9220+
}
9221+
92289222
bool Server::_dir_is_nonempty(const MDRequestRef& mdr, CInode *in)
92299223
{
92309224
dout(10) << "dir_is_nonempty " << *in << dendl;

src/mds/Server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class Server {
302302
void handle_client_unlink(const MDRequestRef& mdr);
303303
bool _dir_is_nonempty_unlocked(const MDRequestRef& mdr, CInode *rmdiri);
304304
bool _dir_is_nonempty(const MDRequestRef& mdr, CInode *rmdiri);
305+
bool _dir_has_snaps(const MDRequestRef& mdr, CInode *diri);
305306
void _unlink_local(const MDRequestRef& mdr, CDentry *dn, CDentry *straydn);
306307
void _unlink_local_finish(const MDRequestRef& mdr,
307308
CDentry *dn, CDentry *straydn,

0 commit comments

Comments
 (0)