* [PATCH] device-mapper: [5/5] Tidy dm_suspend
@ 2005-05-04 17:08 Alasdair G Kergon
0 siblings, 0 replies; only message in thread
From: Alasdair G Kergon @ 2005-05-04 17:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Christoph Hellwig
Tidy dm_suspend.
Signed-Off-By: Alasdair G Kergon <agk@redhat.com>
From: Christoph Hellwig <hch@lst.de>
--- diff/drivers/md/dm.c 2005-04-21 16:08:19.000000000 +0100
+++ source/drivers/md/dm.c 2005-04-21 16:09:16.000000000 +0100
@@ -1048,20 +1048,16 @@
{
struct dm_table *map;
DECLARE_WAITQUEUE(wait, current);
- int error;
+ int error = -EINVAL;
/* Flush I/O to the device. */
down_read(&md->lock);
- if (test_bit(DMF_BLOCK_IO, &md->flags)) {
- up_read(&md->lock);
- return -EINVAL;
- }
+ if (test_bit(DMF_BLOCK_IO, &md->flags))
+ goto out_read_unlock;
error = __lock_fs(md);
- if (error) {
- up_read(&md->lock);
- return error;
- }
+ if (error)
+ goto out_read_unlock;
map = dm_get_table(md);
if (map)
@@ -1075,15 +1071,14 @@
* 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.
*/
+ error = -EINVAL;
down_write(&md->lock);
- if (test_bit(DMF_BLOCK_IO, &md->flags)) {
- up_write(&md->lock);
+ if (test_and_set_bit(DMF_BLOCK_IO, &md->flags)) {
if (map)
dm_table_put(map);
- return -EINVAL;
+ goto out_write_unlock;
}
- set_bit(DMF_BLOCK_IO, &md->flags);
add_wait_queue(&md->wait, &wait);
up_write(&md->lock);
@@ -1111,13 +1106,9 @@
remove_wait_queue(&md->wait, &wait);
/* were we interrupted ? */
- if (atomic_read(&md->pending)) {
- /* FIXME Undo the presuspend_targets */
- __unlock_fs(md);
- clear_bit(DMF_BLOCK_IO, &md->flags);
- up_write(&md->lock);
- return -EINTR;
- }
+ error = -EINTR;
+ if (atomic_read(&md->pending))
+ goto out_unfreeze;
set_bit(DMF_SUSPENDED, &md->flags);
@@ -1128,6 +1119,18 @@
up_write(&md->lock);
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-04 17:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-04 17:08 [PATCH] device-mapper: [5/5] Tidy dm_suspend Alasdair G Kergon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).