]> git.hungrycats.org Git - linux/commitdiff
[PATCH] dm: dm_suspend locking fix
authorJoe Thornber <joe@fib011235813.fsnet.co.uk>
Mon, 16 Dec 2002 01:16:36 +0000 (17:16 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Mon, 16 Dec 2002 01:16:36 +0000 (17:16 -0800)
dm_suspend(): Stop holding the read lock around the while loop that
waits for pending io to complete.

drivers/md/dm.c

index 00d299a4fcd42b07a10b785f38ecdef61bcbbc3d..e7a4aa84775e7f1d07f54228044253f0d34664d8 100644 (file)
@@ -715,15 +715,13 @@ int dm_suspend(struct mapped_device *md)
        }
 
        set_bit(DMF_BLOCK_IO, &md->flags);
+       add_wait_queue(&md->wait, &wait);
        up_write(&md->lock);
 
        /*
         * Then we wait for the already mapped ios to
         * complete.
         */
-       down_read(&md->lock);
-
-       add_wait_queue(&md->wait, &wait);
        while (1) {
                set_current_state(TASK_INTERRUPTIBLE);
 
@@ -734,11 +732,11 @@ int dm_suspend(struct mapped_device *md)
        }
 
        current->state = TASK_RUNNING;
-       remove_wait_queue(&md->wait, &wait);
-       up_read(&md->lock);
 
-       /* set_bit is atomic */
+       down_write(&md->lock);
+       remove_wait_queue(&md->wait, &wait);
        set_bit(DMF_SUSPENDED, &md->flags);
+       up_write(&md->lock);
 
        return 0;
 }