Skip to content

Commit c3cfb65

Browse files
Liu Bokdave
authored andcommitted
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 <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent e8f5b39 commit c3cfb65

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

fs/btrfs/extent_io.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
22572257
return 0;
22582258
}
22592259

2260-
int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
2260+
bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
22612261
struct io_failure_record *failrec, int failed_mirror)
22622262
{
22632263
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,
22732273
btrfs_debug(fs_info,
22742274
"Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d",
22752275
num_copies, failrec->this_mirror, failed_mirror);
2276-
return 0;
2276+
return false;
22772277
}
22782278

22792279
/*
@@ -2314,10 +2314,10 @@ int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
23142314
btrfs_debug(fs_info,
23152315
"Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d",
23162316
num_copies, failrec->this_mirror, failed_mirror);
2317-
return 0;
2317+
return false;
23182318
}
23192319

2320-
return 1;
2320+
return true;
23212321
}
23222322

23232323

@@ -2380,8 +2380,8 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
23802380
if (ret)
23812381
return ret;
23822382

2383-
ret = btrfs_check_repairable(inode, failed_bio, failrec, failed_mirror);
2384-
if (!ret) {
2383+
if (!btrfs_check_repairable(inode, failed_bio, failrec,
2384+
failed_mirror)) {
23852385
free_io_failure(failure_tree, tree, failrec);
23862386
return -EIO;
23872387
}

fs/btrfs/extent_io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start,
539539
u64 end);
540540
int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
541541
struct io_failure_record **failrec_ret);
542-
int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
543-
struct io_failure_record *failrec, int fail_mirror);
542+
bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
543+
struct io_failure_record *failrec, int fail_mirror);
544544
struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
545545
struct io_failure_record *failrec,
546546
struct page *page, int pg_offset, int icsum,

0 commit comments

Comments
 (0)