aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2006-01-06 03:20:05 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:00 -0500
commite39e2e95eb8bd536b61654e8fda1516d0a6a3cd1 (patch)
treed962d4aa2fd61243db6f627672e80749b00ee4b5 /drivers
parenta1a190807074bd6ad8771e00b00752771ae586cb (diff)
[PATCH] device-mapper: rename frozen_bdev
Rename frozen_bdev to suspended_bdev and move the bdget outside lockfs. (This prepares for making lockfs optional.) Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 9e8c1edd89d..fc335e09d07 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -97,7 +97,7 @@ struct mapped_device {
97 * freeze/thaw support require holding onto a super block 97 * freeze/thaw support require holding onto a super block
98 */ 98 */
99 struct super_block *frozen_sb; 99 struct super_block *frozen_sb;
100 struct block_device *frozen_bdev; 100 struct block_device *suspended_bdev;
101}; 101};
102 102
103#define MIN_IOS 256 103#define MIN_IOS 256
@@ -836,9 +836,9 @@ static void __set_size(struct mapped_device *md, sector_t size)
836{ 836{
837 set_capacity(md->disk, size); 837 set_capacity(md->disk, size);
838 838
839 down(&md->frozen_bdev->bd_inode->i_sem); 839 down(&md->suspended_bdev->bd_inode->i_sem);
840 i_size_write(md->frozen_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); 840 i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
841 up(&md->frozen_bdev->bd_inode->i_sem); 841 up(&md->suspended_bdev->bd_inode->i_sem);
842} 842}
843 843
844static int __bind(struct mapped_device *md, struct dm_table *t) 844static int __bind(struct mapped_device *md, struct dm_table *t)
@@ -1010,43 +1010,27 @@ out:
1010 */ 1010 */
1011static int lock_fs(struct mapped_device *md) 1011static int lock_fs(struct mapped_device *md)
1012{ 1012{
1013 int r = -ENOMEM; 1013 int r;
1014
1015 md->frozen_bdev = bdget_disk(md->disk, 0);
1016 if (!md->frozen_bdev) {
1017 DMWARN("bdget failed in lock_fs");
1018 goto out;
1019 }
1020 1014
1021 WARN_ON(md->frozen_sb); 1015 WARN_ON(md->frozen_sb);
1022 1016
1023 md->frozen_sb = freeze_bdev(md->frozen_bdev); 1017 md->frozen_sb = freeze_bdev(md->suspended_bdev);
1024 if (IS_ERR(md->frozen_sb)) { 1018 if (IS_ERR(md->frozen_sb)) {
1025 r = PTR_ERR(md->frozen_sb); 1019 r = PTR_ERR(md->frozen_sb);
1026 goto out_bdput; 1020 md->frozen_sb = NULL;
1021 return r;
1027 } 1022 }
1028 1023
1029 /* don't bdput right now, we don't want the bdev 1024 /* don't bdput right now, we don't want the bdev
1030 * to go away while it is locked. We'll bdput 1025 * to go away while it is locked.
1031 * in unlock_fs
1032 */ 1026 */
1033 return 0; 1027 return 0;
1034
1035out_bdput:
1036 bdput(md->frozen_bdev);
1037 md->frozen_sb = NULL;
1038 md->frozen_bdev = NULL;
1039out:
1040 return r;
1041} 1028}
1042 1029
1043static void unlock_fs(struct mapped_device *md) 1030static void unlock_fs(struct mapped_device *md)
1044{ 1031{
1045 thaw_bdev(md->frozen_bdev, md->frozen_sb); 1032 thaw_bdev(md->suspended_bdev, md->frozen_sb);
1046 bdput(md->frozen_bdev);
1047
1048 md->frozen_sb = NULL; 1033 md->frozen_sb = NULL;
1049 md->frozen_bdev = NULL;
1050} 1034}
1051 1035
1052/* 1036/*
@@ -1072,6 +1056,13 @@ int dm_suspend(struct mapped_device *md)
1072 /* This does not get reverted if there's an error later. */ 1056 /* This does not get reverted if there's an error later. */
1073 dm_table_presuspend_targets(map); 1057 dm_table_presuspend_targets(map);
1074 1058
1059 md->suspended_bdev = bdget_disk(md->disk, 0);
1060 if (!md->suspended_bdev) {
1061 DMWARN("bdget failed in dm_suspend");
1062 r = -ENOMEM;
1063 goto out;
1064 }
1065
1075 /* Flush I/O to the device. */ 1066 /* Flush I/O to the device. */
1076 r = lock_fs(md); 1067 r = lock_fs(md);
1077 if (r) 1068 if (r)
@@ -1124,6 +1115,11 @@ int dm_suspend(struct mapped_device *md)
1124 r = 0; 1115 r = 0;
1125 1116
1126out: 1117out:
1118 if (r && md->suspended_bdev) {
1119 bdput(md->suspended_bdev);
1120 md->suspended_bdev = NULL;
1121 }
1122
1127 dm_table_put(map); 1123 dm_table_put(map);
1128 up(&md->suspend_lock); 1124 up(&md->suspend_lock);
1129 return r; 1125 return r;
@@ -1154,6 +1150,9 @@ int dm_resume(struct mapped_device *md)
1154 1150
1155 unlock_fs(md); 1151 unlock_fs(md);
1156 1152
1153 bdput(md->suspended_bdev);
1154 md->suspended_bdev = NULL;
1155
1157 clear_bit(DMF_SUSPENDED, &md->flags); 1156 clear_bit(DMF_SUSPENDED, &md->flags);
1158 1157
1159 dm_table_unplug_all(map); 1158 dm_table_unplug_all(map);