|
@@ -19,6 +19,7 @@
|
|
#ifndef __BTRFS_I__
|
|
#ifndef __BTRFS_I__
|
|
#define __BTRFS_I__
|
|
#define __BTRFS_I__
|
|
|
|
|
|
|
|
+#include <linux/hash.h>
|
|
#include "extent_map.h"
|
|
#include "extent_map.h"
|
|
#include "extent_io.h"
|
|
#include "extent_io.h"
|
|
#include "ordered-data.h"
|
|
#include "ordered-data.h"
|
|
@@ -179,6 +180,25 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode)
|
|
return container_of(inode, struct btrfs_inode, vfs_inode);
|
|
return container_of(inode, struct btrfs_inode, vfs_inode);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static inline unsigned long btrfs_inode_hash(u64 objectid,
|
|
|
|
+ const struct btrfs_root *root)
|
|
|
|
+{
|
|
|
|
+ u64 h = objectid ^ (root->objectid * GOLDEN_RATIO_PRIME);
|
|
|
|
+
|
|
|
|
+#if BITS_PER_LONG == 32
|
|
|
|
+ h = (h >> 32) ^ (h & 0xffffffff);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ return (unsigned long)h;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline void btrfs_insert_inode_hash(struct inode *inode)
|
|
|
|
+{
|
|
|
|
+ unsigned long h = btrfs_inode_hash(inode->i_ino, BTRFS_I(inode)->root);
|
|
|
|
+
|
|
|
|
+ __insert_inode_hash(inode, h);
|
|
|
|
+}
|
|
|
|
+
|
|
static inline u64 btrfs_ino(struct inode *inode)
|
|
static inline u64 btrfs_ino(struct inode *inode)
|
|
{
|
|
{
|
|
u64 ino = BTRFS_I(inode)->location.objectid;
|
|
u64 ino = BTRFS_I(inode)->location.objectid;
|