if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
return;
- if (_dir_is_nonempty(mdr, cur)) {
- respond_to_request(mdr, -ENOTEMPTY);
- return;
- }
- if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
+ if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
respond_to_request(mdr, -ENOTEMPTY);
return;
}
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
return;
- if (_dir_is_nonempty(mdr, cur)) {
- respond_to_request(mdr, -ENOTEMPTY);
- return;
- }
- if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
+ if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
respond_to_request(mdr, -ENOTEMPTY);
return;
}
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
return;
- if (_dir_is_nonempty(mdr, cur)) {
- respond_to_request(mdr, -ENOTEMPTY);
- return;
- }
- if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
+ if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
respond_to_request(mdr, -ENOTEMPTY);
return;
}
if (!xlock_policylock(mdr, cur, false, false, std::move(lov)))
return;
- if (_dir_is_nonempty(mdr, cur)) {
- respond_to_request(mdr, -ENOTEMPTY);
- return;
- }
- if (cur->snaprealm && cur->snaprealm->srnode.snaps.size()) {
+ if (_dir_is_nonempty(mdr, cur) || _dir_has_snaps(mdr, cur)) {
respond_to_request(mdr, -ENOTEMPTY);
return;
}
return false;
}
+bool Server::_dir_has_snaps(const MDRequestRef& mdr, CInode *diri)
+{
+ dout(10) << __func__ << ": " << *diri << dendl;
+ ceph_assert(diri->is_auth());
+ ceph_assert(diri->snaplock.can_read(mdr->get_client()));
+
+ SnapRealm *realm = diri->find_snaprealm();
+ return !realm->get_snaps().empty();
+}
+
bool Server::_dir_is_nonempty(const MDRequestRef& mdr, CInode *in)
{
dout(10) << "dir_is_nonempty " << *in << dendl;
void handle_client_unlink(const MDRequestRef& mdr);
bool _dir_is_nonempty_unlocked(const MDRequestRef& mdr, CInode *rmdiri);
bool _dir_is_nonempty(const MDRequestRef& mdr, CInode *rmdiri);
+ bool _dir_has_snaps(const MDRequestRef& mdr, CInode *diri);
void _unlink_local(const MDRequestRef& mdr, CDentry *dn, CDentry *straydn);
void _unlink_local_finish(const MDRequestRef& mdr,
CDentry *dn, CDentry *straydn,