Annotate the bitmap locking functions. Introduce a new token context lock because the struct drbd_device definition is not visible from the drbd_int.h header file. Annotate the declarations of bitmap locking functions with only the token context lock. Annotate the definitions of the bitmap locking functions with both the token context lock and the actual mutex. Reviewed-by: Christoph Hellwig Signed-off-by: Bart Van Assche --- drivers/block/drbd/drbd_bitmap.c | 6 ++++++ drivers/block/drbd/drbd_int.h | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index e332a96fe90c..d849bd780ca9 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c @@ -122,9 +122,12 @@ static void __bm_print_lock_info(struct drbd_device *device, const char *func) } void drbd_bm_lock(struct drbd_device *device, char *why, enum bm_flag flags) + __acquires(drbd_dev_bm_lock) + __acquires(&device->bitmap->bm_change) { struct drbd_bitmap *b = device->bitmap; + __acquire(drbd_dev_bm_lock); mutex_lock(&b->bm_change); if (BM_LOCKED_MASK & b->bm_flags) drbd_err(device, "FIXME bitmap already locked in bm_lock\n"); @@ -135,6 +138,8 @@ void drbd_bm_lock(struct drbd_device *device, char *why, enum bm_flag flags) } void drbd_bm_unlock(struct drbd_device *device) + __releases(drbd_dev_bm_lock) + __releases(&device->bitmap->bm_change) { struct drbd_bitmap *b = device->bitmap; @@ -145,6 +150,7 @@ void drbd_bm_unlock(struct drbd_device *device) b->bm_why = NULL; b->bm_task = NULL; mutex_unlock(&b->bm_change); + __release(drbd_dev_bm_lock); } /* we store some "meta" info about our pages in page->private */ diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 1f3f2157df8b..7e0e0a0f27ae 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -1337,8 +1337,12 @@ void drbd_bm_merge_lel(struct drbd_device *device, size_t offset, size_t number, void drbd_bm_get_lel(struct drbd_device *device, size_t offset, size_t number, unsigned long *buffer); -void drbd_bm_lock(struct drbd_device *device, char *why, enum bm_flag flags); -void drbd_bm_unlock(struct drbd_device *device); +token_context_lock(drbd_dev_bm_lock); + +void drbd_bm_lock(struct drbd_device *device, char *why, enum bm_flag flags) + __acquires(drbd_dev_bm_lock); +void drbd_bm_unlock(struct drbd_device *device) + __releases(drbd_dev_bm_lock); /* drbd_main.c */ extern struct kmem_cache *drbd_request_cache;