aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/check-integrity.c32
-rw-r--r--fs/btrfs/check-integrity.h2
-rw-r--r--fs/btrfs/extent_io.c12
-rw-r--r--fs/btrfs/scrub.c33
4 files changed, 20 insertions, 59 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index e0aab4456974..f85b1c409003 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -323,7 +323,6 @@ static void btrfsic_release_block_ctx(struct btrfsic_block_data_ctx *block_ctx);
323static int btrfsic_read_block(struct btrfsic_state *state, 323static int btrfsic_read_block(struct btrfsic_state *state,
324 struct btrfsic_block_data_ctx *block_ctx); 324 struct btrfsic_block_data_ctx *block_ctx);
325static void btrfsic_dump_database(struct btrfsic_state *state); 325static void btrfsic_dump_database(struct btrfsic_state *state);
326static void btrfsic_complete_bio_end_io(struct bio *bio, int err);
327static int btrfsic_test_for_metadata(struct btrfsic_state *state, 326static int btrfsic_test_for_metadata(struct btrfsic_state *state,
328 char **datav, unsigned int num_pages); 327 char **datav, unsigned int num_pages);
329static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, 328static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state,
@@ -1677,7 +1676,6 @@ static int btrfsic_read_block(struct btrfsic_state *state,
1677 for (i = 0; i < num_pages;) { 1676 for (i = 0; i < num_pages;) {
1678 struct bio *bio; 1677 struct bio *bio;
1679 unsigned int j; 1678 unsigned int j;
1680 DECLARE_COMPLETION_ONSTACK(complete);
1681 1679
1682 bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); 1680 bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i);
1683 if (!bio) { 1681 if (!bio) {
@@ -1688,8 +1686,6 @@ static int btrfsic_read_block(struct btrfsic_state *state,
1688 } 1686 }
1689 bio->bi_bdev = block_ctx->dev->bdev; 1687 bio->bi_bdev = block_ctx->dev->bdev;
1690 bio->bi_sector = dev_bytenr >> 9; 1688 bio->bi_sector = dev_bytenr >> 9;
1691 bio->bi_end_io = btrfsic_complete_bio_end_io;
1692 bio->bi_private = &complete;
1693 1689
1694 for (j = i; j < num_pages; j++) { 1690 for (j = i; j < num_pages; j++) {
1695 ret = bio_add_page(bio, block_ctx->pagev[j], 1691 ret = bio_add_page(bio, block_ctx->pagev[j],
@@ -1702,12 +1698,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
1702 "btrfsic: error, failed to add a single page!\n"); 1698 "btrfsic: error, failed to add a single page!\n");
1703 return -1; 1699 return -1;
1704 } 1700 }
1705 submit_bio(READ, bio); 1701 if (submit_bio_wait(READ, bio)) {
1706
1707 /* this will also unplug the queue */
1708 wait_for_completion(&complete);
1709
1710 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
1711 printk(KERN_INFO 1702 printk(KERN_INFO
1712 "btrfsic: read error at logical %llu dev %s!\n", 1703 "btrfsic: read error at logical %llu dev %s!\n",
1713 block_ctx->start, block_ctx->dev->name); 1704 block_ctx->start, block_ctx->dev->name);
@@ -1730,11 +1721,6 @@ static int btrfsic_read_block(struct btrfsic_state *state,
1730 return block_ctx->len; 1721 return block_ctx->len;
1731} 1722}
1732 1723
1733static void btrfsic_complete_bio_end_io(struct bio *bio, int err)
1734{
1735 complete((struct completion *)bio->bi_private);
1736}
1737
1738static void btrfsic_dump_database(struct btrfsic_state *state) 1724static void btrfsic_dump_database(struct btrfsic_state *state)
1739{ 1725{
1740 struct list_head *elem_all; 1726 struct list_head *elem_all;
@@ -2998,14 +2984,12 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
2998 return submit_bh(rw, bh); 2984 return submit_bh(rw, bh);
2999} 2985}
3000 2986
3001void btrfsic_submit_bio(int rw, struct bio *bio) 2987static void __btrfsic_submit_bio(int rw, struct bio *bio)
3002{ 2988{
3003 struct btrfsic_dev_state *dev_state; 2989 struct btrfsic_dev_state *dev_state;
3004 2990
3005 if (!btrfsic_is_initialized) { 2991 if (!btrfsic_is_initialized)
3006 submit_bio(rw, bio);
3007 return; 2992 return;
3008 }
3009 2993
3010 mutex_lock(&btrfsic_mutex); 2994 mutex_lock(&btrfsic_mutex);
3011 /* since btrfsic_submit_bio() is also called before 2995 /* since btrfsic_submit_bio() is also called before
@@ -3097,10 +3081,20 @@ void btrfsic_submit_bio(int rw, struct bio *bio)
3097 } 3081 }
3098leave: 3082leave:
3099 mutex_unlock(&btrfsic_mutex); 3083 mutex_unlock(&btrfsic_mutex);
3084}
3100 3085
3086void btrfsic_submit_bio(int rw, struct bio *bio)
3087{
3088 __btrfsic_submit_bio(rw, bio);
3101 submit_bio(rw, bio); 3089 submit_bio(rw, bio);
3102} 3090}
3103 3091
3092int btrfsic_submit_bio_wait(int rw, struct bio *bio)
3093{
3094 __btrfsic_submit_bio(rw, bio);
3095 return submit_bio_wait(rw, bio);
3096}
3097
3104int btrfsic_mount(struct btrfs_root *root, 3098int btrfsic_mount(struct btrfs_root *root,
3105 struct btrfs_fs_devices *fs_devices, 3099 struct btrfs_fs_devices *fs_devices,
3106 int including_extent_data, u32 print_mask) 3100 int including_extent_data, u32 print_mask)
diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h
index 8b59175cc502..13b8566c97ab 100644
--- a/fs/btrfs/check-integrity.h
+++ b/fs/btrfs/check-integrity.h
@@ -22,9 +22,11 @@
22#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 22#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
23int btrfsic_submit_bh(int rw, struct buffer_head *bh); 23int btrfsic_submit_bh(int rw, struct buffer_head *bh);
24void btrfsic_submit_bio(int rw, struct bio *bio); 24void btrfsic_submit_bio(int rw, struct bio *bio);
25int btrfsic_submit_bio_wait(int rw, struct bio *bio);
25#else 26#else
26#define btrfsic_submit_bh submit_bh 27#define btrfsic_submit_bh submit_bh
27#define btrfsic_submit_bio submit_bio 28#define btrfsic_submit_bio submit_bio
29#define btrfsic_submit_bio_wait submit_bio_wait
28#endif 30#endif
29 31
30int btrfsic_mount(struct btrfs_root *root, 32int btrfsic_mount(struct btrfs_root *root,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 856bc2b2192c..014beaa9458c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1952,11 +1952,6 @@ static int free_io_failure(struct inode *inode, struct io_failure_record *rec,
1952 return err; 1952 return err;
1953} 1953}
1954 1954
1955static void repair_io_failure_callback(struct bio *bio, int err)
1956{
1957 complete(bio->bi_private);
1958}
1959
1960/* 1955/*
1961 * this bypasses the standard btrfs submit functions deliberately, as 1956 * this bypasses the standard btrfs submit functions deliberately, as
1962 * the standard behavior is to write all copies in a raid setup. here we only 1957 * the standard behavior is to write all copies in a raid setup. here we only
@@ -1973,7 +1968,6 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
1973{ 1968{
1974 struct bio *bio; 1969 struct bio *bio;
1975 struct btrfs_device *dev; 1970 struct btrfs_device *dev;
1976 DECLARE_COMPLETION_ONSTACK(compl);
1977 u64 map_length = 0; 1971 u64 map_length = 0;
1978 u64 sector; 1972 u64 sector;
1979 struct btrfs_bio *bbio = NULL; 1973 struct btrfs_bio *bbio = NULL;
@@ -1989,8 +1983,6 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
1989 bio = btrfs_io_bio_alloc(GFP_NOFS, 1); 1983 bio = btrfs_io_bio_alloc(GFP_NOFS, 1);
1990 if (!bio) 1984 if (!bio)
1991 return -EIO; 1985 return -EIO;
1992 bio->bi_private = &compl;
1993 bio->bi_end_io = repair_io_failure_callback;
1994 bio->bi_size = 0; 1986 bio->bi_size = 0;
1995 map_length = length; 1987 map_length = length;
1996 1988
@@ -2011,10 +2003,8 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
2011 } 2003 }
2012 bio->bi_bdev = dev->bdev; 2004 bio->bi_bdev = dev->bdev;
2013 bio_add_page(bio, page, length, start - page_offset(page)); 2005 bio_add_page(bio, page, length, start - page_offset(page));
2014 btrfsic_submit_bio(WRITE_SYNC, bio);
2015 wait_for_completion(&compl);
2016 2006
2017 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { 2007 if (btrfsic_submit_bio_wait(WRITE_SYNC, bio)) {
2018 /* try to remap that extent elsewhere? */ 2008 /* try to remap that extent elsewhere? */
2019 bio_put(bio); 2009 bio_put(bio);
2020 btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); 2010 btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 2544805544f0..3214ebe593bd 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -208,7 +208,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
208 int is_metadata, int have_csum, 208 int is_metadata, int have_csum,
209 const u8 *csum, u64 generation, 209 const u8 *csum, u64 generation,
210 u16 csum_size); 210 u16 csum_size);
211static void scrub_complete_bio_end_io(struct bio *bio, int err);
212static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad, 211static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad,
213 struct scrub_block *sblock_good, 212 struct scrub_block *sblock_good,
214 int force_write); 213 int force_write);
@@ -1292,7 +1291,6 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
1292 for (page_num = 0; page_num < sblock->page_count; page_num++) { 1291 for (page_num = 0; page_num < sblock->page_count; page_num++) {
1293 struct bio *bio; 1292 struct bio *bio;
1294 struct scrub_page *page = sblock->pagev[page_num]; 1293 struct scrub_page *page = sblock->pagev[page_num];
1295 DECLARE_COMPLETION_ONSTACK(complete);
1296 1294
1297 if (page->dev->bdev == NULL) { 1295 if (page->dev->bdev == NULL) {
1298 page->io_error = 1; 1296 page->io_error = 1;
@@ -1309,18 +1307,11 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
1309 } 1307 }
1310 bio->bi_bdev = page->dev->bdev; 1308 bio->bi_bdev = page->dev->bdev;
1311 bio->bi_sector = page->physical >> 9; 1309 bio->bi_sector = page->physical >> 9;
1312 bio->bi_end_io = scrub_complete_bio_end_io;
1313 bio->bi_private = &complete;
1314 1310
1315 bio_add_page(bio, page->page, PAGE_SIZE, 0); 1311 bio_add_page(bio, page->page, PAGE_SIZE, 0);
1316 btrfsic_submit_bio(READ, bio); 1312 if (btrfsic_submit_bio_wait(READ, bio))
1317
1318 /* this will also unplug the queue */
1319 wait_for_completion(&complete);
1320
1321 page->io_error = !test_bit(BIO_UPTODATE, &bio->bi_flags);
1322 if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
1323 sblock->no_io_error_seen = 0; 1313 sblock->no_io_error_seen = 0;
1314
1324 bio_put(bio); 1315 bio_put(bio);
1325 } 1316 }
1326 1317
@@ -1389,11 +1380,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
1389 sblock->checksum_error = 1; 1380 sblock->checksum_error = 1;
1390} 1381}
1391 1382
1392static void scrub_complete_bio_end_io(struct bio *bio, int err)
1393{
1394 complete((struct completion *)bio->bi_private);
1395}
1396
1397static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad, 1383static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad,
1398 struct scrub_block *sblock_good, 1384 struct scrub_block *sblock_good,
1399 int force_write) 1385 int force_write)
@@ -1428,7 +1414,6 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
1428 sblock_bad->checksum_error || page_bad->io_error) { 1414 sblock_bad->checksum_error || page_bad->io_error) {
1429 struct bio *bio; 1415 struct bio *bio;
1430 int ret; 1416 int ret;
1431 DECLARE_COMPLETION_ONSTACK(complete);
1432 1417
1433 if (!page_bad->dev->bdev) { 1418 if (!page_bad->dev->bdev) {
1434 printk_ratelimited(KERN_WARNING 1419 printk_ratelimited(KERN_WARNING
@@ -1441,19 +1426,14 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
1441 return -EIO; 1426 return -EIO;
1442 bio->bi_bdev = page_bad->dev->bdev; 1427 bio->bi_bdev = page_bad->dev->bdev;
1443 bio->bi_sector = page_bad->physical >> 9; 1428 bio->bi_sector = page_bad->physical >> 9;
1444 bio->bi_end_io = scrub_complete_bio_end_io;
1445 bio->bi_private = &complete;
1446 1429
1447 ret = bio_add_page(bio, page_good->page, PAGE_SIZE, 0); 1430 ret = bio_add_page(bio, page_good->page, PAGE_SIZE, 0);
1448 if (PAGE_SIZE != ret) { 1431 if (PAGE_SIZE != ret) {
1449 bio_put(bio); 1432 bio_put(bio);
1450 return -EIO; 1433 return -EIO;
1451 } 1434 }
1452 btrfsic_submit_bio(WRITE, bio);
1453 1435
1454 /* this will also unplug the queue */ 1436 if (btrfsic_submit_bio_wait(WRITE, bio)) {
1455 wait_for_completion(&complete);
1456 if (!bio_flagged(bio, BIO_UPTODATE)) {
1457 btrfs_dev_stat_inc_and_print(page_bad->dev, 1437 btrfs_dev_stat_inc_and_print(page_bad->dev,
1458 BTRFS_DEV_STAT_WRITE_ERRS); 1438 BTRFS_DEV_STAT_WRITE_ERRS);
1459 btrfs_dev_replace_stats_inc( 1439 btrfs_dev_replace_stats_inc(
@@ -3373,7 +3353,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
3373 struct bio *bio; 3353 struct bio *bio;
3374 struct btrfs_device *dev; 3354 struct btrfs_device *dev;
3375 int ret; 3355 int ret;
3376 DECLARE_COMPLETION_ONSTACK(compl);
3377 3356
3378 dev = sctx->wr_ctx.tgtdev; 3357 dev = sctx->wr_ctx.tgtdev;
3379 if (!dev) 3358 if (!dev)
@@ -3390,8 +3369,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
3390 spin_unlock(&sctx->stat_lock); 3369 spin_unlock(&sctx->stat_lock);
3391 return -ENOMEM; 3370 return -ENOMEM;
3392 } 3371 }
3393 bio->bi_private = &compl;
3394 bio->bi_end_io = scrub_complete_bio_end_io;
3395 bio->bi_size = 0; 3372 bio->bi_size = 0;
3396 bio->bi_sector = physical_for_dev_replace >> 9; 3373 bio->bi_sector = physical_for_dev_replace >> 9;
3397 bio->bi_bdev = dev->bdev; 3374 bio->bi_bdev = dev->bdev;
@@ -3402,10 +3379,8 @@ leave_with_eio:
3402 btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); 3379 btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
3403 return -EIO; 3380 return -EIO;
3404 } 3381 }
3405 btrfsic_submit_bio(WRITE_SYNC, bio);
3406 wait_for_completion(&compl);
3407 3382
3408 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 3383 if (btrfsic_submit_bio_wait(WRITE_SYNC, bio))
3409 goto leave_with_eio; 3384 goto leave_with_eio;
3410 3385
3411 bio_put(bio); 3386 bio_put(bio);