-/** _dir_is_not_empty
- *
- * check if a directory is non-empty (i.e. we can rmdir it), and make
- * sure it is part of the same subtree (i.e. local) so that rmdir will
- * occur locally.
+/** _dir_is_nonempty[_unlocked]
*
- * this is a fastpath check. we can't really be sure until we rdlock
- * the filelock.
+ * check if a directory is non-empty (i.e. we can rmdir it).
*
- * @param in is the inode being rmdir'd. return true if it is
- * definitely not empty.
+ * the unlocked varient this is a fastpath check. we can't really be
+ * sure until we rdlock the filelock.
*/
-bool Server::_dir_is_nonempty(MDRequest *mdr, CInode *in)
+bool Server::_dir_is_nonempty_unlocked(MDRequest *mdr, CInode *in)
{
- dout(10) << "dir_is_nonempty " << *in << dendl;
+ dout(10) << "dir_is_nonempty_unlocked " << *in << dendl;
assert(in->is_auth());
- if (in->snaprealm && in->snaprealm->snaps.size())
-
+ if (in->snaprealm && in->snaprealm->srnode.snaps.size())
- return true; //in a snapshot!
+ return true; // in a snapshot!
list<frag_t> frags;
in->dirfragtree.get_leaves(frags);
CDir *dir = in->get_or_open_dirfrag(mdcache, *p);
assert(dir);
- // does the frag _look_ empty?
- if (dir->inode->get_projected_inode()->dirstat.size() > 0) {
- dout(10) << "dir_is_nonempty projected dir size still "
- << dir->inode->get_projected_inode()->dirstat.size()
- << " on " << *dir->inode
- << dendl;
- return true;
+ // is the frag obviously non-empty?
+ if (dir->is_auth()) {
+ if (dir->get_projected_fnode()->fragstat.size()) {
+ dout(10) << "dir_is_nonempty_unlocked dirstat has "
+ << dir->get_projected_fnode()->fragstat.size() << " items " << *dir << dendl;
+ return true;
+ }
}
+ }
- // not dir auth?
- if (!dir->is_auth()) {
- dout(10) << "dir_is_nonempty non-auth dirfrag for " << *dir << dendl;
- }
+ return false;
+}
+
+bool Server::_dir_is_nonempty(MDRequest *mdr, CInode *in)
+{
+ dout(10) << "dir_is_nonempty " << *in << dendl;
+ assert(in->is_auth());
+
- if (in->snaprealm && in->snaprealm->snaps.size())
++ if (in->snaprealm && in->snaprealm->srnode.snaps.size())
+ return true; // in a snapshot!
+
+ if (in->get_projected_inode()->dirstat.size() > 0) {
+ dout(10) << "dir_is_nonempty projected dir size still "
+ << in->get_projected_inode()->dirstat.size()
+ << " on " << *in
+ << dendl;
+ return true;
}
return false;