[PATCH] device-mapper: store bdev while frozen

Store the struct block_device while device is frozen, saving us one call to
bdget_disk().

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>
This commit is contained in:
Alasdair G Kergon 2005-05-05 16:16:03 -07:00 committed by Linus Torvalds
parent d17d7fa44d
commit d1782a3b0a

View file

@ -97,6 +97,7 @@ struct mapped_device {
* freeze/thaw support require holding onto a super block * freeze/thaw support require holding onto a super block
*/ */
struct super_block *frozen_sb; struct super_block *frozen_sb;
struct block_device *frozen_bdev;
}; };
#define MIN_IOS 256 #define MIN_IOS 256
@ -990,19 +991,17 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
*/ */
static int __lock_fs(struct mapped_device *md) static int __lock_fs(struct mapped_device *md)
{ {
struct block_device *bdev;
if (test_and_set_bit(DMF_FS_LOCKED, &md->flags)) if (test_and_set_bit(DMF_FS_LOCKED, &md->flags))
return 0; return 0;
bdev = bdget_disk(md->disk, 0); md->frozen_bdev = bdget_disk(md->disk, 0);
if (!bdev) { if (!md->frozen_bdev) {
DMWARN("bdget failed in __lock_fs"); DMWARN("bdget failed in __lock_fs");
return -ENOMEM; return -ENOMEM;
} }
WARN_ON(md->frozen_sb); WARN_ON(md->frozen_sb);
md->frozen_sb = freeze_bdev(bdev); md->frozen_sb = freeze_bdev(md->frozen_bdev);
/* 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. We'll bdput * to go away while it is locked. We'll bdput
* in __unlock_fs * in __unlock_fs
@ -1012,21 +1011,15 @@ static int __lock_fs(struct mapped_device *md)
static int __unlock_fs(struct mapped_device *md) static int __unlock_fs(struct mapped_device *md)
{ {
struct block_device *bdev;
if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags)) if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags))
return 0; return 0;
bdev = bdget_disk(md->disk, 0); thaw_bdev(md->frozen_bdev, md->frozen_sb);
if (!bdev) { bdput(md->frozen_bdev);
DMWARN("bdget failed in __unlock_fs");
return -ENOMEM;
}
thaw_bdev(bdev, md->frozen_sb);
md->frozen_sb = NULL; md->frozen_sb = NULL;
bdput(bdev); md->frozen_bdev = NULL;
bdput(bdev);
return 0; return 0;
} }