aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2017-07-13 18:00:50 -0400
committerDavid Sterba <dsterba@suse.com>2017-07-14 14:42:37 -0400
commitc3cfb656307583ddfea45375c10183737593c195 (patch)
tree715fc49cc0671fe86c20a33ce636c623113fd14e
parente8f5b395d5332b5d720d62d33d6e06836392fd85 (diff)
Btrfs: fix unexpected return value of bio_readpage_error
With blk_status_t conversion (that are now present in master), bio_readpage_error() may return 1 as now ->submit_bio_hook() may not set %ret if it runs without problems. This fixes that unexpected return value by changing btrfs_check_repairable() to return a bool instead of updating %ret, and patch is applicable to both codebases with and without blk_status_t. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/extent_io.c12
-rw-r--r--fs/btrfs/extent_io.h4
2 files changed, 8 insertions, 8 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 3a9ef02cad49..eb484a0d1320 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2257,7 +2257,7 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
2257 return 0; 2257 return 0;
2258} 2258}
2259 2259
2260int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, 2260bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
2261 struct io_failure_record *failrec, int failed_mirror) 2261 struct io_failure_record *failrec, int failed_mirror)
2262{ 2262{
2263 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 2263 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -2273,7 +2273,7 @@ int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
2273 btrfs_debug(fs_info, 2273 btrfs_debug(fs_info,
2274 "Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d", 2274 "Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d",
2275 num_copies, failrec->this_mirror, failed_mirror); 2275 num_copies, failrec->this_mirror, failed_mirror);
2276 return 0; 2276 return false;
2277 } 2277 }
2278 2278
2279 /* 2279 /*
@@ -2314,10 +2314,10 @@ int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
2314 btrfs_debug(fs_info, 2314 btrfs_debug(fs_info,
2315 "Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d", 2315 "Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d",
2316 num_copies, failrec->this_mirror, failed_mirror); 2316 num_copies, failrec->this_mirror, failed_mirror);
2317 return 0; 2317 return false;
2318 } 2318 }
2319 2319
2320 return 1; 2320 return true;
2321} 2321}
2322 2322
2323 2323
@@ -2380,8 +2380,8 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
2380 if (ret) 2380 if (ret)
2381 return ret; 2381 return ret;
2382 2382
2383 ret = btrfs_check_repairable(inode, failed_bio, failrec, failed_mirror); 2383 if (!btrfs_check_repairable(inode, failed_bio, failrec,
2384 if (!ret) { 2384 failed_mirror)) {
2385 free_io_failure(failure_tree, tree, failrec); 2385 free_io_failure(failure_tree, tree, failrec);
2386 return -EIO; 2386 return -EIO;
2387 } 2387 }
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index aeafdb35d90b..cfdbb9efaaed 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -539,8 +539,8 @@ void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start,
539 u64 end); 539 u64 end);
540int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, 540int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
541 struct io_failure_record **failrec_ret); 541 struct io_failure_record **failrec_ret);
542int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, 542bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
543 struct io_failure_record *failrec, int fail_mirror); 543 struct io_failure_record *failrec, int fail_mirror);
544struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio, 544struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
545 struct io_failure_record *failrec, 545 struct io_failure_record *failrec,
546 struct page *page, int pg_offset, int icsum, 546 struct page *page, int pg_offset, int icsum,