lkml.org 
[lkml]   [2005]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] device-mapper: [1/5] 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>
--- diff/drivers/md/dm.c 2005-04-04 17:39:06.000000000 +0100
+++ source/drivers/md/dm.c 2005-04-21 16:06:40.000000000 +0100
@@ -97,6 +97,7 @@
* 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 @@
*/
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 __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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-05-04 19:08    [W:0.035 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site