Commit b84b0287 authored by Alasdair G Kergon's avatar Alasdair G Kergon Committed by Linus Torvalds

[PATCH] device-mapper: tidy dm_suspend

Tidy dm_suspend.
Signed-Off-By: default avatarAlasdair G Kergon <agk@redhat.com>
From: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 354e0071
...@@ -1048,20 +1048,16 @@ int dm_suspend(struct mapped_device *md) ...@@ -1048,20 +1048,16 @@ int dm_suspend(struct mapped_device *md)
{ {
struct dm_table *map; struct dm_table *map;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
int error; int error = -EINVAL;
/* Flush I/O to the device. */ /* Flush I/O to the device. */
down_read(&md->lock); down_read(&md->lock);
if (test_bit(DMF_BLOCK_IO, &md->flags)) { if (test_bit(DMF_BLOCK_IO, &md->flags))
up_read(&md->lock); goto out_read_unlock;
return -EINVAL;
}
error = __lock_fs(md); error = __lock_fs(md);
if (error) { if (error)
up_read(&md->lock); goto out_read_unlock;
return error;
}
map = dm_get_table(md); map = dm_get_table(md);
if (map) if (map)
...@@ -1075,15 +1071,14 @@ int dm_suspend(struct mapped_device *md) ...@@ -1075,15 +1071,14 @@ int dm_suspend(struct mapped_device *md)
* If the flag is already set we know another thread is trying to * If the flag is already set we know another thread is trying to
* suspend as well, so we leave the fs locked for this thread. * suspend as well, so we leave the fs locked for this thread.
*/ */
error = -EINVAL;
down_write(&md->lock); down_write(&md->lock);
if (test_bit(DMF_BLOCK_IO, &md->flags)) { if (test_and_set_bit(DMF_BLOCK_IO, &md->flags)) {
up_write(&md->lock);
if (map) if (map)
dm_table_put(map); dm_table_put(map);
return -EINVAL; goto out_write_unlock;
} }
set_bit(DMF_BLOCK_IO, &md->flags);
add_wait_queue(&md->wait, &wait); add_wait_queue(&md->wait, &wait);
up_write(&md->lock); up_write(&md->lock);
...@@ -1111,13 +1106,9 @@ int dm_suspend(struct mapped_device *md) ...@@ -1111,13 +1106,9 @@ int dm_suspend(struct mapped_device *md)
remove_wait_queue(&md->wait, &wait); remove_wait_queue(&md->wait, &wait);
/* were we interrupted ? */ /* were we interrupted ? */
if (atomic_read(&md->pending)) { error = -EINTR;
/* FIXME Undo the presuspend_targets */ if (atomic_read(&md->pending))
__unlock_fs(md); goto out_unfreeze;
clear_bit(DMF_BLOCK_IO, &md->flags);
up_write(&md->lock);
return -EINTR;
}
set_bit(DMF_SUSPENDED, &md->flags); set_bit(DMF_SUSPENDED, &md->flags);
...@@ -1128,6 +1119,18 @@ int dm_suspend(struct mapped_device *md) ...@@ -1128,6 +1119,18 @@ int dm_suspend(struct mapped_device *md)
up_write(&md->lock); up_write(&md->lock);
return 0; return 0;
out_unfreeze:
/* FIXME Undo dm_table_presuspend_targets */
__unlock_fs(md);
clear_bit(DMF_BLOCK_IO, &md->flags);
out_write_unlock:
up_write(&md->lock);
return error;
out_read_unlock:
up_read(&md->lock);
return error;
} }
int dm_resume(struct mapped_device *md) int dm_resume(struct mapped_device *md)
......
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