From 34c6b4437a2e8a49bb76e86d07cd86b740e3f581 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" --- src/mds/Server.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 10ff327119c..f3c07a28edc 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -9937,6 +9937,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.39.5