Commit 1ea0654e authored by Bart Van Assche's avatar Bart Van Assche Committed by Mike Snitzer

dm: verify suspend_locking assumptions at runtime

Ensure that the assumptions about the caller holding suspend_lock
are checked at runtime if lockdep is enabled.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 73cbca6a
...@@ -1680,6 +1680,8 @@ static void suspend_targets(struct dm_table *t, enum suspend_mode mode) ...@@ -1680,6 +1680,8 @@ static void suspend_targets(struct dm_table *t, enum suspend_mode mode)
int i = t->num_targets; int i = t->num_targets;
struct dm_target *ti = t->targets; struct dm_target *ti = t->targets;
lockdep_assert_held(&t->md->suspend_lock);
while (i--) { while (i--) {
switch (mode) { switch (mode) {
case PRESUSPEND: case PRESUSPEND:
...@@ -1727,6 +1729,8 @@ int dm_table_resume_targets(struct dm_table *t) ...@@ -1727,6 +1729,8 @@ int dm_table_resume_targets(struct dm_table *t)
{ {
int i, r = 0; int i, r = 0;
lockdep_assert_held(&t->md->suspend_lock);
for (i = 0; i < t->num_targets; i++) { for (i = 0; i < t->num_targets; i++) {
struct dm_target *ti = t->targets + i; struct dm_target *ti = t->targets + i;
......
...@@ -1698,6 +1698,8 @@ static void event_callback(void *context) ...@@ -1698,6 +1698,8 @@ static void event_callback(void *context)
*/ */
static void __set_size(struct mapped_device *md, sector_t size) static void __set_size(struct mapped_device *md, sector_t size)
{ {
lockdep_assert_held(&md->suspend_lock);
set_capacity(md->disk, size); set_capacity(md->disk, size);
i_size_write(md->bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); i_size_write(md->bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
...@@ -2147,8 +2149,6 @@ static void unlock_fs(struct mapped_device *md) ...@@ -2147,8 +2149,6 @@ static void unlock_fs(struct mapped_device *md)
* If __dm_suspend returns 0, the device is completely quiescent * If __dm_suspend returns 0, the device is completely quiescent
* now. There is no request-processing activity. All new requests * now. There is no request-processing activity. All new requests
* are being added to md->deferred list. * are being added to md->deferred list.
*
* Caller must hold md->suspend_lock
*/ */
static int __dm_suspend(struct mapped_device *md, struct dm_table *map, static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
unsigned suspend_flags, long task_state, unsigned suspend_flags, long task_state,
...@@ -2364,6 +2364,8 @@ static void __dm_internal_suspend(struct mapped_device *md, unsigned suspend_fla ...@@ -2364,6 +2364,8 @@ static void __dm_internal_suspend(struct mapped_device *md, unsigned suspend_fla
{ {
struct dm_table *map = NULL; struct dm_table *map = NULL;
lockdep_assert_held(&md->suspend_lock);
if (md->internal_suspend_count++) if (md->internal_suspend_count++)
return; /* nested internal suspend */ return; /* nested internal suspend */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment