[PATCH 12/17] zram: Add zram_table_lock
From: Matthew Wilcox (Oracle)
Date: Thu Apr 08 2021 - 23:00:16 EST
Allow lockdep to track the zram bit spin locks.
Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
drivers/block/zram/zram_drv.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index cf8deecc39ef..8b678cc6ed21 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -59,20 +59,22 @@ static void zram_free_page(struct zram *zram, size_t index);
static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
u32 index, int offset, struct bio *bio);
+static DEFINE_SPLIT_LOCK(zram_table_lock);
static int zram_slot_trylock(struct zram *zram, u32 index)
{
- return bit_spin_trylock(ZRAM_LOCK, &zram->table[index].flags);
+ return bit_spin_trylock(ZRAM_LOCK, &zram->table[index].flags,
+ &zram_table_lock);
}
static void zram_slot_lock(struct zram *zram, u32 index)
{
- bit_spin_lock(ZRAM_LOCK, &zram->table[index].flags);
+ bit_spin_lock(ZRAM_LOCK, &zram->table[index].flags, &zram_table_lock);
}
static void zram_slot_unlock(struct zram *zram, u32 index)
{
- bit_spin_unlock(ZRAM_LOCK, &zram->table[index].flags);
+ bit_spin_unlock(ZRAM_LOCK, &zram->table[index].flags, &zram_table_lock);
}
static inline bool init_done(struct zram *zram)
--
2.30.2