#include "MDLog.h"
#include "LogSegment.h"
+#include "include/bloom_filter.hpp"
#include "include/Context.h"
#include "common/Clock.h"
CDir::CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth) :
dirty_rstat_inodes(member_offset(CInode, dirty_rstat_item)),
- item_dirty(this), item_new(this)
+ item_dirty(this), item_new(this), bloom(NULL)
{
g_num_dir++;
g_num_dira++;
}
}
+void CDir::add_to_bloom(CDentry *dn)
+{
+ if (!bloom)
+ bloom = new bloom_filter(100, 0.05, 0);
+ /* This size and false positive probability is completely random.*/
+ bloom->insert(dn->name.c_str(), dn->name.size());
+}
+
+bool CDir::is_in_bloom(const string& name)
+{
+ if (!bloom)
+ return false;
+ return bloom->contains(name.c_str(), name.size());
+}
+
void CDir::remove_null_dentries() {
dout(12) << "remove_null_dentries " << *this << dendl;
mdlog->wait_for_sync(new C_Dir_Dirty(this, pv, mdlog->get_current_segment()));
}
-
+void CDir::mark_complete() {
+ state_set(STATE_COMPLETE);
+ delete bloom;
+ bloom = NULL;
+}
void CDir::first_get()
{
class MDCache;
class MDCluster;
class Context;
+class bloom_filter;
class ObjectOperation;
friend class CDirDiscover;
friend class CDirExport;
+ bloom_filter *bloom;
+ /* If you set up the bloom filter, you must keep it accurate!
+ * It's deleted when you mark_complete() and is deliberately not serialized.*/
+
public:
CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth);
~CDir() {
void link_primary_inode( CDentry *dn, CInode *in );
void unlink_inode( CDentry *dn );
void try_remove_unlinked_dn(CDentry *dn);
+
+ void add_to_bloom(CDentry *dn);
+ bool is_in_bloom(const string& name);
+ bool has_bloom() { return (bloom ? true : false); }
private:
void link_inode_work( CDentry *dn, CInode *in );
void unlink_inode_work( CDentry *dn );
version_t get_committed_version() { return committed_version; }
void set_committed_version(version_t v) { committed_version = v; }
- void mark_complete() { state_set(STATE_COMPLETE); }
+ void mark_complete();
// -- reference counting --