aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/btrfs_inode.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/btrfs_inode.h')
-rw-r--r--fs/btrfs/btrfs_inode.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 71f074e1870b..ac0b39db27d1 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -19,6 +19,7 @@
19#ifndef __BTRFS_I__ 19#ifndef __BTRFS_I__
20#define __BTRFS_I__ 20#define __BTRFS_I__
21 21
22#include <linux/hash.h>
22#include "extent_map.h" 23#include "extent_map.h"
23#include "extent_io.h" 24#include "extent_io.h"
24#include "ordered-data.h" 25#include "ordered-data.h"
@@ -179,6 +180,25 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode)
179 return container_of(inode, struct btrfs_inode, vfs_inode); 180 return container_of(inode, struct btrfs_inode, vfs_inode);
180} 181}
181 182
183static inline unsigned long btrfs_inode_hash(u64 objectid,
184 const struct btrfs_root *root)
185{
186 u64 h = objectid ^ (root->objectid * GOLDEN_RATIO_PRIME);
187
188#if BITS_PER_LONG == 32
189 h = (h >> 32) ^ (h & 0xffffffff);
190#endif
191
192 return (unsigned long)h;
193}
194
195static inline void btrfs_insert_inode_hash(struct inode *inode)
196{
197 unsigned long h = btrfs_inode_hash(inode->i_ino, BTRFS_I(inode)->root);
198
199 __insert_inode_hash(inode, h);
200}
201
182static inline u64 btrfs_ino(struct inode *inode) 202static inline u64 btrfs_ino(struct inode *inode)
183{ 203{
184 u64 ino = BTRFS_I(inode)->location.objectid; 204 u64 ino = BTRFS_I(inode)->location.objectid;