DMF_FS_LOCKED is no longer needed - remove it. Never call lock/unlock_fs with io_lock held. --- diff/drivers/md/dm.c 2005-07-06 19:40:14.000000000 +0100 +++ source/drivers/md/dm.c 2005-07-06 19:39:59.000000000 +0100 @@ -55,7 +55,6 @@ */ #define DMF_BLOCK_IO 0 #define DMF_SUSPENDED 1 -#define DMF_FS_LOCKED 2 struct mapped_device { struct rw_semaphore io_lock; @@ -984,16 +983,13 @@ * Functions to lock and unlock any filesystem running on the * device. */ -static int __lock_fs(struct mapped_device *md) +static int lock_fs(struct mapped_device *md) { int error = -ENOMEM; - if (test_and_set_bit(DMF_FS_LOCKED, &md->flags)) - return 0; - md->frozen_bdev = bdget_disk(md->disk, 0); if (!md->frozen_bdev) { - DMWARN("bdget failed in __lock_fs"); + DMWARN("bdget failed in lock_fs"); goto out; } @@ -1007,7 +1003,7 @@ /* don't bdput right now, we don't want the bdev * to go away while it is locked. We'll bdput - * in __unlock_fs + * in unlock_fs */ return 0; @@ -1016,15 +1012,11 @@ md->frozen_sb = NULL; md->frozen_bdev = NULL; out: - clear_bit(DMF_FS_LOCKED, &md->flags); return error; } -static void __unlock_fs(struct mapped_device *md) +static void unlock_fs(struct mapped_device *md) { - if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags)) - return; - thaw_bdev(md->frozen_bdev, md->frozen_sb); bdput(md->frozen_bdev); @@ -1056,7 +1048,7 @@ dm_table_presuspend_targets(map); /* Flush I/O to the device. */ - r = __lock_fs(md); + r = lock_fs(md); if (r) goto out; @@ -1093,9 +1085,9 @@ /* were we interrupted ? */ r = -EINTR; if (atomic_read(&md->pending)) { - __unlock_fs(md); - clear_bit(DMF_BLOCK_IO, &md->flags); up_write(&md->io_lock); + unlock_fs(md); + clear_bit(DMF_BLOCK_IO, &md->flags); goto out; } up_write(&md->io_lock); @@ -1126,15 +1118,16 @@ if (!map || !dm_table_get_size(map)) goto out; - down_write(&md->io_lock); dm_table_resume_targets(map); + + down_write(&md->io_lock); clear_bit(DMF_BLOCK_IO, &md->flags); def = bio_list_get(&md->deferred); __flush_deferred_io(md, def); up_write(&md->io_lock); - __unlock_fs(md); + unlock_fs(md); clear_bit(DMF_SUSPENDED, &md->flags);