From df50b8be7c508516f8c025b0ac8a6221bb8ac9f1 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 5 Aug 2020 15:33:10 +0800 Subject: [PATCH] mds: disallow creating snapshot on descendent directory of subvolume Signed-off-by: "Yan, Zheng" (cherry picked from commit 34c6b4437a2e8a49bb76e86d07cd86b740e3f581) --- src/mds/Server.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 4d9e65349ec3..ecbd380df6a5 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -9739,6 +9739,12 @@ void Server::handle_client_mksnap(MDRequestRef& mdr) if (!check_access(mdr, diri, MAY_WRITE|MAY_SNAPSHOT)) return; + if (inodeno_t subvol_ino = diri->find_snaprealm()->get_subvolume_ino(); + (subvol_ino && subvol_ino != diri->ino())) { + respond_to_request(mdr, -EPERM); + return; + } + // check if we can create any more snapshots // we don't allow any more if we are already at or beyond the limit if (diri->snaprealm && -- 2.47.3