1 #ifndef _LINUX_BLOCKGROUP_LOCK_H
2 #define _LINUX_BLOCKGROUP_LOCK_H
4 * Per-blockgroup locking for ext2 and ext3.
6 * Simple hashed spinlocking.
9 #include <linux/spinlock.h>
10 #include <linux/cache.h>
15 * We want a power-of-two. Is there a better way than this?
19 #define NR_BG_LOCKS 128
21 #define NR_BG_LOCKS 64
23 #define NR_BG_LOCKS 32
25 #define NR_BG_LOCKS 16
32 #else /* CONFIG_SMP */
34 #endif /* CONFIG_SMP */
38 } ____cacheline_aligned_in_smp;
40 struct blockgroup_lock {
41 struct bgl_lock locks[NR_BG_LOCKS];
44 static inline void bgl_lock_init(struct blockgroup_lock *bgl)
48 for (i = 0; i < NR_BG_LOCKS; i++)
49 spin_lock_init(&bgl->locks[i].lock);
53 * The accessor is a macro so we can embed a blockgroup_lock into different
56 static inline spinlock_t *
57 bgl_lock_ptr(struct blockgroup_lock *bgl, unsigned int block_group)
59 return &bgl->locks[(block_group) & (NR_BG_LOCKS-1)].lock;