2 * Per-blockgroup locking for ext2 and ext3.
4 * Simple hashed spinlocking.
7 #include <linux/config.h>
8 #include <linux/spinlock.h>
9 #include <linux/cache.h>
14 * We want a power-of-two. Is there a better way than this?
18 #define NR_BG_LOCKS 128
20 #define NR_BG_LOCKS 64
22 #define NR_BG_LOCKS 32
24 #define NR_BG_LOCKS 16
31 #else /* CONFIG_SMP */
33 #endif /* CONFIG_SMP */
37 } ____cacheline_aligned_in_smp;
39 struct blockgroup_lock {
40 struct bgl_lock locks[NR_BG_LOCKS];
43 static inline void bgl_lock_init(struct blockgroup_lock *bgl)
47 for (i = 0; i < NR_BG_LOCKS; i++)
48 spin_lock_init(&bgl->locks[i].lock);
52 * The accessor is a macro so we can embed a blockgroup_lock into different
55 #define sb_bgl_lock(sb, block_group) \
56 (&(sb)->s_blockgroup_lock.locks[(block_group) & (NR_BG_LOCKS-1)].lock)