From d6d2eb51cdd12c1fe09dcd48536a7d9a27814bc9 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Thu, 12 Apr 2018 10:22:11 +0800 Subject: [PATCH] mds: disallow multi-active MDS if snapshot was ever created by pre-mimic mds Signed-off-by: "Yan, Zheng" --- src/include/ceph_fs.h | 4 +++- src/mds/MDSMap.h | 3 +++ src/mon/FSCommands.cc | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 2be246397bd9f..d0f3b9abdaf39 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -236,8 +236,10 @@ struct ceph_mon_subscribe_ack { #define CEPH_MDSMAP_ALLOW_SNAPS (1<<1) /* cluster allowed to create snapshots */ /* deprecated #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) cluster allowed to have >1 active MDS */ /* deprecated #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) cluster allowed to fragment directories */ +#define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS (1<<4) /* cluster alllowed to enable MULTIMDS + and SNAPS at the same time */ -#define CEPH_MDSMAP_DEFAULTS (0) +#define CEPH_MDSMAP_DEFAULTS CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS /* * mds states diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index c92cf2bff2613..1c30686310ebb 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -281,6 +281,9 @@ public: } void clear_snaps_allowed() { clear_flag(CEPH_MDSMAP_ALLOW_SNAPS); } bool allows_snaps() const { return test_flag(CEPH_MDSMAP_ALLOW_SNAPS); } + bool was_snaps_ever_allowed() const { return ever_allowed_features & CEPH_MDSMAP_ALLOW_SNAPS; } + + bool allows_multimds_snaps() const { return test_flag(CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS); } epoch_t get_epoch() const { return epoch; } void inc_epoch() { epoch++; } diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 09c4892dd2de8..25792b97610a8 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -261,7 +261,15 @@ public: if (n <= 0) { ss << "You must specify at least one MDS"; return -EINVAL; - } else if (n > MAX_MDS) { + } + if (n > 1 && n > fs->mds_map.get_max_mds()) { + if (fs->mds_map.was_snaps_ever_allowed() && + !fs->mds_map.allows_multimds_snaps()) { + ss << "multi-active MDS is not allowed while there are snapshots possibly created by pre-mimic MDS"; + return -EINVAL; + } + } + if (n > MAX_MDS) { ss << "may not have more than " << MAX_MDS << " MDS ranks"; return -EINVAL; } -- 2.39.5