aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 0e4c8d3ca9fb..9687a084b5ff 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -991,22 +991,38 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
991 */ 991 */
992static int __lock_fs(struct mapped_device *md) 992static int __lock_fs(struct mapped_device *md)
993{ 993{
994 int error = -ENOMEM;
995
994 if (test_and_set_bit(DMF_FS_LOCKED, &md->flags)) 996 if (test_and_set_bit(DMF_FS_LOCKED, &md->flags))
995 return 0; 997 return 0;
996 998
997 md->frozen_bdev = bdget_disk(md->disk, 0); 999 md->frozen_bdev = bdget_disk(md->disk, 0);
998 if (!md->frozen_bdev) { 1000 if (!md->frozen_bdev) {
999 DMWARN("bdget failed in __lock_fs"); 1001 DMWARN("bdget failed in __lock_fs");
1000 return -ENOMEM; 1002 goto out;
1001 } 1003 }
1002 1004
1003 WARN_ON(md->frozen_sb); 1005 WARN_ON(md->frozen_sb);
1006
1004 md->frozen_sb = freeze_bdev(md->frozen_bdev); 1007 md->frozen_sb = freeze_bdev(md->frozen_bdev);
1008 if (IS_ERR(md->frozen_sb)) {
1009 error = PTR_ERR(md->frozen_sb);
1010 goto out_bdput;
1011 }
1012
1005 /* don't bdput right now, we don't want the bdev 1013 /* don't bdput right now, we don't want the bdev
1006 * to go away while it is locked. We'll bdput 1014 * to go away while it is locked. We'll bdput
1007 * in __unlock_fs 1015 * in __unlock_fs
1008 */ 1016 */
1009 return 0; 1017 return 0;
1018
1019out_bdput:
1020 bdput(md->frozen_bdev);
1021 md->frozen_sb = NULL;
1022 md->frozen_bdev = NULL;
1023out:
1024 clear_bit(DMF_FS_LOCKED, &md->flags);
1025 return error;
1010} 1026}
1011 1027
1012static void __unlock_fs(struct mapped_device *md) 1028static void __unlock_fs(struct mapped_device *md)