[PATCH] device-mapper: handle __lock_fs error
authorAlasdair G Kergon <agk@redhat.com>
Thu, 5 May 2005 23:16:05 +0000 (16:16 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 5 May 2005 23:36:45 +0000 (16:36 -0700)
Handle error from __lock_fs()

Signed-Off-By: Alasdair G Kergon <agk@redhat.com>
From: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/md/dm.c

index 9687a084b5ff653c52a61a879267c46c72cab689..83f53a46c2d462b81b975c24d87de45f58dc932a 100644 (file)
@@ -1048,6 +1048,7 @@ int dm_suspend(struct mapped_device *md)
 {
        struct dm_table *map;
        DECLARE_WAITQUEUE(wait, current);
+       int error;
 
        /* Flush I/O to the device. */
        down_read(&md->lock);
@@ -1056,25 +1057,29 @@ int dm_suspend(struct mapped_device *md)
                return -EINVAL;
        }
 
+       error = __lock_fs(md);
+       if (error) {
+               up_read(&md->lock);
+               return error;
+       }
+
        map = dm_get_table(md);
        if (map)
                dm_table_presuspend_targets(map);
-       __lock_fs(md);
 
        up_read(&md->lock);
 
        /*
-        * First we set the BLOCK_IO flag so no more ios will be
-        * mapped.
+        * First we set the BLOCK_IO flag so no more ios will be mapped.
+        *
+        * 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.
         */
        down_write(&md->lock);
        if (test_bit(DMF_BLOCK_IO, &md->flags)) {
-               /*
-                * If we get here we know another thread is
-                * trying to suspend as well, so we leave the fs
-                * locked for this thread.
-                */
                up_write(&md->lock);
+               if (map)
+                       dm_table_put(map);
                return -EINVAL;
        }
 
@@ -1107,6 +1112,7 @@ int dm_suspend(struct mapped_device *md)
 
        /* 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);