diff options
| author | Zhao Lei <zhaolei@cn.fujitsu.com> | 2016-01-12 04:52:13 -0500 |
|---|---|---|
| committer | Chris Mason <clm@fb.com> | 2016-01-20 10:22:18 -0500 |
| commit | a6111d11b8b5364d02ea2e881c81ce39d004eb32 (patch) | |
| tree | 0a0aa9c0ee14665dbe0f3d436aaeedb90f6d198a /fs/btrfs | |
| parent | 748f4ef4c6708e733da077a1980923b9d19db78a (diff) | |
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 <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
| -rw-r--r-- | fs/btrfs/raid56.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 2bc34e91b62e..55161369fab1 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c | |||
| @@ -901,6 +901,7 @@ static void raid_write_end_io(struct bio *bio) | |||
| 901 | { | 901 | { |
| 902 | struct btrfs_raid_bio *rbio = bio->bi_private; | 902 | struct btrfs_raid_bio *rbio = bio->bi_private; |
| 903 | int err = bio->bi_error; | 903 | int err = bio->bi_error; |
| 904 | int max_errors; | ||
| 904 | 905 | ||
| 905 | if (err) | 906 | if (err) |
| 906 | fail_bio_stripe(rbio, bio); | 907 | fail_bio_stripe(rbio, bio); |
| @@ -913,7 +914,9 @@ static void raid_write_end_io(struct bio *bio) | |||
| 913 | err = 0; | 914 | err = 0; |
| 914 | 915 | ||
| 915 | /* OK, we have read all the stripes we need to. */ | 916 | /* 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) | ||
| 917 | err = -EIO; | 920 | err = -EIO; |
| 918 | 921 | ||
| 919 | rbio_orig_end_io(rbio, err); | 922 | rbio_orig_end_io(rbio, err); |
| @@ -2277,31 +2280,6 @@ static int alloc_rbio_essential_pages(struct btrfs_raid_bio *rbio) | |||
| 2277 | return 0; | 2280 | return 0; |
| 2278 | } | 2281 | } |
| 2279 | 2282 | ||
| 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 | |||
| 2305 | static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, | 2283 | static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, |
| 2306 | int need_check) | 2284 | int need_check) |
| 2307 | { | 2285 | { |
| @@ -2454,7 +2432,7 @@ submit_write: | |||
| 2454 | break; | 2432 | break; |
| 2455 | 2433 | ||
| 2456 | bio->bi_private = rbio; | 2434 | bio->bi_private = rbio; |
| 2457 | bio->bi_end_io = raid_write_parity_end_io; | 2435 | bio->bi_end_io = raid_write_end_io; |
| 2458 | submit_bio(WRITE, bio); | 2436 | submit_bio(WRITE, bio); |
| 2459 | } | 2437 | } |
| 2460 | return; | 2438 | return; |
