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

[PATCH] device-mapper: make lock_fs optional

Devices only needs syncing when creating snapshots, so make this optional when
suspending a device.
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e39e2e95
...@@ -700,7 +700,7 @@ static int do_suspend(struct dm_ioctl *param) ...@@ -700,7 +700,7 @@ static int do_suspend(struct dm_ioctl *param)
return -ENXIO; return -ENXIO;
if (!dm_suspended(md)) if (!dm_suspended(md))
r = dm_suspend(md); r = dm_suspend(md, 1);
if (!r) if (!r)
r = __dev_status(md, param); r = __dev_status(md, param);
...@@ -738,7 +738,7 @@ static int do_resume(struct dm_ioctl *param) ...@@ -738,7 +738,7 @@ static int do_resume(struct dm_ioctl *param)
if (new_map) { if (new_map) {
/* Suspend if it isn't already suspended */ /* Suspend if it isn't already suspended */
if (!dm_suspended(md)) if (!dm_suspended(md))
dm_suspend(md); dm_suspend(md, 1);
r = dm_swap_table(md, new_map); r = dm_swap_table(md, new_map);
if (r) { if (r) {
......
...@@ -55,6 +55,7 @@ union map_info *dm_get_mapinfo(struct bio *bio) ...@@ -55,6 +55,7 @@ union map_info *dm_get_mapinfo(struct bio *bio)
*/ */
#define DMF_BLOCK_IO 0 #define DMF_BLOCK_IO 0
#define DMF_SUSPENDED 1 #define DMF_SUSPENDED 1
#define DMF_FROZEN 2
struct mapped_device { struct mapped_device {
struct rw_semaphore io_lock; struct rw_semaphore io_lock;
...@@ -1021,6 +1022,8 @@ static int lock_fs(struct mapped_device *md) ...@@ -1021,6 +1022,8 @@ static int lock_fs(struct mapped_device *md)
return r; return r;
} }
set_bit(DMF_FROZEN, &md->flags);
/* don't bdput right now, we don't want the bdev /* don't bdput right now, we don't want the bdev
* to go away while it is locked. * to go away while it is locked.
*/ */
...@@ -1029,8 +1032,12 @@ static int lock_fs(struct mapped_device *md) ...@@ -1029,8 +1032,12 @@ static int lock_fs(struct mapped_device *md)
static void unlock_fs(struct mapped_device *md) static void unlock_fs(struct mapped_device *md)
{ {
if (!test_bit(DMF_FROZEN, &md->flags))
return;
thaw_bdev(md->suspended_bdev, md->frozen_sb); thaw_bdev(md->suspended_bdev, md->frozen_sb);
md->frozen_sb = NULL; md->frozen_sb = NULL;
clear_bit(DMF_FROZEN, &md->flags);
} }
/* /*
...@@ -1040,7 +1047,7 @@ static void unlock_fs(struct mapped_device *md) ...@@ -1040,7 +1047,7 @@ static void unlock_fs(struct mapped_device *md)
* dm_bind_table, dm_suspend must be called to flush any in * dm_bind_table, dm_suspend must be called to flush any in
* flight bios and ensure that any further io gets deferred. * flight bios and ensure that any further io gets deferred.
*/ */
int dm_suspend(struct mapped_device *md) int dm_suspend(struct mapped_device *md, int do_lockfs)
{ {
struct dm_table *map = NULL; struct dm_table *map = NULL;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -1064,9 +1071,11 @@ int dm_suspend(struct mapped_device *md) ...@@ -1064,9 +1071,11 @@ int dm_suspend(struct mapped_device *md)
} }
/* Flush I/O to the device. */ /* Flush I/O to the device. */
if (do_lockfs) {
r = lock_fs(md); r = lock_fs(md);
if (r) if (r)
goto out; goto out;
}
/* /*
* 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.
......
...@@ -69,7 +69,7 @@ void dm_put(struct mapped_device *md); ...@@ -69,7 +69,7 @@ void dm_put(struct mapped_device *md);
/* /*
* A device can still be used while suspended, but I/O is deferred. * A device can still be used while suspended, but I/O is deferred.
*/ */
int dm_suspend(struct mapped_device *md); int dm_suspend(struct mapped_device *md, int with_lockfs);
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