switch (m->op) {
case POOL_OP_CREATE_SNAP:
case POOL_OP_DELETE_SNAP:
- if (!pp.removed_snaps.empty()) {
+ if (pp.is_unmanaged_snaps_mode()) {
ret = -EINVAL;
goto out;
}
case POOL_OP_CREATE_UNMANAGED_SNAP:
case POOL_OP_DELETE_UNMANAGED_SNAP:
- if (!pp.snaps.empty()) {
+ if (pp.is_pool_snaps_mode()) {
ret = -EINVAL;
goto out;
}
return removed_snaps.empty() && get_snap_seq() > 0;
}
+bool pg_pool_t::is_unmanaged_snaps_mode() const
+{
+ return removed_snaps.size() && get_snap_seq() > 0;
+}
+
bool pg_pool_t::is_removed_snap(snapid_t s) const
{
if (is_pool_snaps_mode())
void pg_pool_t::add_snap(const char *n, utime_t stamp)
{
- assert(removed_snaps.empty());
+ assert(!is_unmanaged_snaps_mode());
snapid_t s = get_snap_seq() + 1;
snap_seq = s;
snaps[s].snapid = s;
void pg_pool_t::add_unmanaged_snap(uint64_t& snapid)
{
if (removed_snaps.empty()) {
- assert(snaps.empty());
+ assert(!is_pool_snaps_mode());
removed_snaps.insert(snapid_t(1));
snap_seq = 1;
}
void pg_pool_t::remove_unmanaged_snap(snapid_t s)
{
- assert(snaps.empty());
+ assert(is_unmanaged_snaps_mode());
removed_snaps.insert(s);
snap_seq = snap_seq + 1;
removed_snaps.insert(get_snap_seq());
* - removal governed by removed_snaps
*
* we know which mode we're using based on whether removed_snaps is empty.
+ * If nothing has been created, both functions report false.
*/
bool is_pool_snaps_mode() const;
+ bool is_unmanaged_snaps_mode() const;
bool is_removed_snap(snapid_t s) const;
/*