summaryrefslogtreecommitdiff
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2005-05-05 16:16:03 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-05 16:36:45 -0700
commitd1782a3b0a15d9ac497a8f47931c4536bfe8d18e (patch)
tree76ce9caa1d4c4a1b34ee060fa9f165385a9f1a7e /drivers/md/dm.c
parentd17d7fa44dbe1f12031773e27eda9e939024a037 (diff)
[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>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 243ff6884e8..ea180af6d22 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -97,6 +97,7 @@ struct mapped_device {
* freeze/thaw support require holding onto a super block
*/
struct super_block *frozen_sb;
+ struct block_device *frozen_bdev;
};
#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)
{
- struct block_device *bdev;
-
if (test_and_set_bit(DMF_FS_LOCKED, &md->flags))
return 0;
- bdev = bdget_disk(md->disk, 0);
- if (!bdev) {
+ md->frozen_bdev = bdget_disk(md->disk, 0);
+ if (!md->frozen_bdev) {
DMWARN("bdget failed in __lock_fs");
return -ENOMEM;
}
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
* to go away while it is locked. We'll bdput
* in __unlock_fs
@@ -1012,21 +1011,15 @@ static int __lock_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))
return 0;
- bdev = bdget_disk(md->disk, 0);
- if (!bdev) {
- DMWARN("bdget failed in __unlock_fs");
- return -ENOMEM;
- }
+ thaw_bdev(md->frozen_bdev, md->frozen_sb);
+ bdput(md->frozen_bdev);
- thaw_bdev(bdev, md->frozen_sb);
md->frozen_sb = NULL;
- bdput(bdev);
- bdput(bdev);
+ md->frozen_bdev = NULL;
+
return 0;
}