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/config.h>
10 #include <linux/spinlock.h>
11 #include <linux/cache.h>
16 * We want a power-of-two. Is there a better way than this?
20 #define NR_BG_LOCKS 128
22 #define NR_BG_LOCKS 64
24 #define NR_BG_LOCKS 32
26 #define NR_BG_LOCKS 16
33 #else /* CONFIG_SMP */
35 #endif /* CONFIG_SMP */
39 } ____cacheline_aligned_in_smp;
41 struct blockgroup_lock {
42 struct bgl_lock locks[NR_BG_LOCKS];
45 static inline void bgl_lock_init(struct blockgroup_lock *bgl)
49 for (i = 0; i < NR_BG_LOCKS; i++)
50 spin_lock_init(&bgl->locks[i].lock);
54 * The accessor is a macro so we can embed a blockgroup_lock into different
57 #define sb_bgl_lock(sb, block_group) \
58 (&(sb)->s_blockgroup_lock.locks[(block_group) & (NR_BG_LOCKS-1)].lock)