aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-29 09:38:00 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:02 -0400
commita236aed14ccb0661611d4416f6b573d892bdc60a (patch)
treeb275333ab5bfaa9ea68756aa0a5c6d5c6fef5405 /fs/btrfs/disk-io.c
parent4235298e4fc3c1a09f659cfe2fd285024eeb2241 (diff)
Btrfs: Deal with failed writes in mirrored configurations
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1c7d84aff864..e35e70165b53 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1385,7 +1385,10 @@ int write_all_supers(struct btrfs_root *root)
1385 struct buffer_head *bh; 1385 struct buffer_head *bh;
1386 int ret; 1386 int ret;
1387 int do_barriers; 1387 int do_barriers;
1388 int max_errors;
1389 int total_errors = 0;
1388 1390
1391 max_errors = btrfs_super_num_devices(&root->fs_info->super_copy) - 1;
1389 do_barriers = !btrfs_test_opt(root, NOBARRIER); 1392 do_barriers = !btrfs_test_opt(root, NOBARRIER);
1390 1393
1391 sb = root->fs_info->sb_buffer; 1394 sb = root->fs_info->sb_buffer;
@@ -1433,8 +1436,14 @@ int write_all_supers(struct btrfs_root *root)
1433 } else { 1436 } else {
1434 ret = submit_bh(WRITE, bh); 1437 ret = submit_bh(WRITE, bh);
1435 } 1438 }
1436 BUG_ON(ret); 1439 if (ret)
1440 total_errors++;
1437 } 1441 }
1442 if (total_errors > max_errors) {
1443 printk("btrfs: %d errors while writing supers\n", total_errors);
1444 BUG();
1445 }
1446 total_errors = 0;
1438 1447
1439 list_for_each(cur, head) { 1448 list_for_each(cur, head) {
1440 dev = list_entry(cur, struct btrfs_device, dev_list); 1449 dev = list_entry(cur, struct btrfs_device, dev_list);
@@ -1454,13 +1463,17 @@ int write_all_supers(struct btrfs_root *root)
1454 wait_on_buffer(bh); 1463 wait_on_buffer(bh);
1455 BUG_ON(!buffer_uptodate(bh)); 1464 BUG_ON(!buffer_uptodate(bh));
1456 } else { 1465 } else {
1457 BUG(); 1466 total_errors++;
1458 } 1467 }
1459 1468
1460 } 1469 }
1461 dev->pending_io = NULL; 1470 dev->pending_io = NULL;
1462 brelse(bh); 1471 brelse(bh);
1463 } 1472 }
1473 if (total_errors > max_errors) {
1474 printk("btrfs: %d errors while writing supers\n", total_errors);
1475 BUG();
1476 }
1464 return 0; 1477 return 0;
1465} 1478}
1466 1479