Skip to content

Commit a6111d1

Browse files
zhaoleiddmasoncl
authored andcommitted
btrfs: raid56: Use raid_write_end_io for scrub
No need to create additional end_io function for scrub, it increased code size and introduced some un-unified lines, as: raid_write_parity_end_io(): int err = bio->bi_error; if (bio->bi_error) raid_write_end_io(): int err = bio->bi_error; if (err) This patch combines them. Signed-off-by: Zhao Lei <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 748f4ef commit a6111d1

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

fs/btrfs/raid56.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ static void raid_write_end_io(struct bio *bio)
901901
{
902902
struct btrfs_raid_bio *rbio = bio->bi_private;
903903
int err = bio->bi_error;
904+
int max_errors;
904905

905906
if (err)
906907
fail_bio_stripe(rbio, bio);
@@ -913,7 +914,9 @@ static void raid_write_end_io(struct bio *bio)
913914
err = 0;
914915

915916
/* OK, we have read all the stripes we need to. */
916-
if (atomic_read(&rbio->error) > rbio->bbio->max_errors)
917+
max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ?
918+
0 : rbio->bbio->max_errors;
919+
if (atomic_read(&rbio->error) > max_errors)
917920
err = -EIO;
918921

919922
rbio_orig_end_io(rbio, err);
@@ -2277,31 +2280,6 @@ static int alloc_rbio_essential_pages(struct btrfs_raid_bio *rbio)
22772280
return 0;
22782281
}
22792282

2280-
/*
2281-
* end io function used by finish_rmw. When we finally
2282-
* get here, we've written a full stripe
2283-
*/
2284-
static void raid_write_parity_end_io(struct bio *bio)
2285-
{
2286-
struct btrfs_raid_bio *rbio = bio->bi_private;
2287-
int err = bio->bi_error;
2288-
2289-
if (bio->bi_error)
2290-
fail_bio_stripe(rbio, bio);
2291-
2292-
bio_put(bio);
2293-
2294-
if (!atomic_dec_and_test(&rbio->stripes_pending))
2295-
return;
2296-
2297-
err = 0;
2298-
2299-
if (atomic_read(&rbio->error))
2300-
err = -EIO;
2301-
2302-
rbio_orig_end_io(rbio, err);
2303-
}
2304-
23052283
static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
23062284
int need_check)
23072285
{
@@ -2454,7 +2432,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
24542432
break;
24552433

24562434
bio->bi_private = rbio;
2457-
bio->bi_end_io = raid_write_parity_end_io;
2435+
bio->bi_end_io = raid_write_end_io;
24582436
submit_bio(WRITE, bio);
24592437
}
24602438
return;

0 commit comments

Comments
 (0)