]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/blockgroup_lock.h
crypto: ccp - Fix XTS-AES-128 support on v5 CCPs
[mirror_ubuntu-artful-kernel.git] / include / linux / blockgroup_lock.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_BLOCKGROUP_LOCK_H
2#define _LINUX_BLOCKGROUP_LOCK_H
3/*
4 * Per-blockgroup locking for ext2 and ext3.
5 *
6 * Simple hashed spinlocking.
7 */
8
1da177e4
LT
9#include <linux/spinlock.h>
10#include <linux/cache.h>
11
12#ifdef CONFIG_SMP
7c5f6b32 13#define NR_BG_LOCKS (4 << ilog2(NR_CPUS < 32 ? NR_CPUS : 32))
1da177e4 14#else
1da177e4 15#define NR_BG_LOCKS 1
7c5f6b32 16#endif
1da177e4
LT
17
18struct bgl_lock {
19 spinlock_t lock;
20} ____cacheline_aligned_in_smp;
21
22struct blockgroup_lock {
23 struct bgl_lock locks[NR_BG_LOCKS];
24};
25
26static inline void bgl_lock_init(struct blockgroup_lock *bgl)
27{
28 int i;
29
30 for (i = 0; i < NR_BG_LOCKS; i++)
31 spin_lock_init(&bgl->locks[i].lock);
32}
33
c644f0e4
PE
34static inline spinlock_t *
35bgl_lock_ptr(struct blockgroup_lock *bgl, unsigned int block_group)
36{
9e5ab85d 37 return &bgl->locks[block_group & (NR_BG_LOCKS-1)].lock;
c644f0e4 38}
1da177e4
LT
39
40#endif