}
}
-bool CDir::is_freezing_tree() const
+pair<bool,bool> CDir::is_freezing_or_frozen_tree() const
{
- if (num_freezing_trees == 0)
- return false;
- const CDir *dir = this;
- while (1) {
- if (dir->is_freezing_tree_root()) return true;
- if (dir->is_subtree_root()) return false;
- if (dir->inode->parent)
- dir = dir->inode->parent->dir;
- else
- return false; // root on replica
- }
-}
+ if (!num_freezing_trees && !num_frozen_trees)
+ return make_pair(false, false);
-bool CDir::is_frozen_tree() const
-{
- if (num_frozen_trees == 0)
- return false;
+ bool freezing, frozen;
const CDir *dir = this;
while (1) {
- if (dir->is_frozen_tree_root()) return true;
- if (dir->is_subtree_root()) return false;
+ freezing = dir->is_freezing_tree_root();
+ frozen = dir->is_frozen_tree_root();
+ if (freezing || frozen)
+ break;
+ if (dir->is_subtree_root())
+ break;
if (dir->inode->parent)
dir = dir->inode->parent->dir;
else
- return false; // root on replica
+ break; // root on replica
}
+ return make_pair(freezing, frozen);
}
CDir *CDir::get_frozen_tree_root()
void abort_import();
// -- auth pins --
- bool can_auth_pin() const override { return is_auth() && !(is_frozen() || is_freezing()); }
+ bool can_auth_pin() const override {
+ if (!is_auth())
+ return false;
+ if (is_freezing_dir() || is_frozen_dir())
+ return false;
+ auto p = is_freezing_or_frozen_tree();
+ if (p.first || p.second)
+ return false;
+ return true;
+ }
int get_cum_auth_pins() const { return auth_pins + nested_auth_pins; }
int get_auth_pins() const { return auth_pins; }
int get_nested_auth_pins() const { return nested_auth_pins; }
void maybe_finish_freeze();
- bool is_freezing() const override { return is_freezing_tree() || is_freezing_dir(); }
- bool is_freezing_tree() const;
+ pair<bool,bool> is_freezing_or_frozen_tree() const;
+
+ bool is_freezing() const override { return is_freezing_dir() || is_freezing_tree(); }
+ bool is_freezing_tree() const {
+ if (!num_freezing_trees)
+ return false;
+ return is_freezing_or_frozen_tree().first;
+ }
bool is_freezing_tree_root() const { return state & STATE_FREEZINGTREE; }
bool is_freezing_dir() const { return state & STATE_FREEZINGDIR; }
bool is_frozen() const override { return is_frozen_dir() || is_frozen_tree(); }
- bool is_frozen_tree() const;
+ bool is_frozen_tree() const {
+ if (!num_frozen_trees)
+ return false;
+ return is_freezing_or_frozen_tree().second;
+ }
bool is_frozen_tree_root() const { return state & STATE_FROZENTREE; }
bool is_frozen_dir() const { return state & STATE_FROZENDIR; }