From 53348ab67f0f3e691cfeb6b02d80b868fdb98d89 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" <zyan@redhat.com> Date: Wed, 5 Aug 2020 15:37:20 +0800 Subject: [PATCH] mds: disallow across subvolume rename Signed-off-by: "Yan, Zheng" <zyan@redhat.com> --- src/mds/Server.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index f3c07a28edc..0655da9d1b3 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -7878,6 +7878,21 @@ void Server::handle_client_rename(MDRequestRef& mdr) } */ + SnapRealm *dest_realm = nullptr; + SnapRealm *src_realm = nullptr; + if (!linkmerge) { + dest_realm = destdir->inode->find_snaprealm(); + if (srcdir->inode == destdir->inode) + src_realm = dest_realm; + else + src_realm = srcdir->inode->find_snaprealm(); + if (src_realm != dest_realm && + src_realm->get_subvolume_ino() != dest_realm->get_subvolume_ino()) { + respond_to_request(mdr, -EXDEV); + return; + } + } + ceph_assert(g_conf()->mds_kill_rename_at != 1); // -- open all srcdn inode frags, if any -- @@ -7927,7 +7942,6 @@ void Server::handle_client_rename(MDRequestRef& mdr) oldin->clear_snaprealm_global(new_srnode); mdr->more()->desti_srnode = new_srnode; } else if (destdnl->is_primary()) { - SnapRealm *dest_realm = destdir->inode->find_snaprealm(); snapid_t follows = dest_realm->get_newest_seq(); if (oldin->snaprealm || follows + 1 > oldin->get_oldest_snap()) { sr_t *new_srnode = oldin->prepare_new_srnode(follows); @@ -7937,13 +7951,11 @@ void Server::handle_client_rename(MDRequestRef& mdr) } } if (!mdr->more()->srci_srnode) { - SnapRealm *dest_realm = destdir->inode->find_snaprealm(); if (srci->is_projected_snaprealm_global()) { sr_t *new_srnode = srci->prepare_new_srnode(0); srci->record_snaprealm_parent_dentry(new_srnode, dest_realm, srcdn, srcdnl->is_primary()); mdr->more()->srci_srnode = new_srnode; } else if (srcdnl->is_primary()) { - SnapRealm *src_realm = srcdir->inode->find_snaprealm(); snapid_t follows = src_realm->get_newest_seq(); if (src_realm != dest_realm && (srci->snaprealm || follows + 1 > srci->get_oldest_snap())) {