Commit e01bf588 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: pass bio opf to rbio_add_io_page

Prepare for further refactoring by moving this initialization to a
single place instead of setting it in the callers.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 110ac0e5
...@@ -1048,7 +1048,8 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio, ...@@ -1048,7 +1048,8 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
struct page *page, struct page *page,
int stripe_nr, int stripe_nr,
unsigned long page_index, unsigned long page_index,
unsigned long bio_max_len) unsigned long bio_max_len,
unsigned int opf)
{ {
struct bio *last = bio_list->tail; struct bio *last = bio_list->tail;
int ret; int ret;
...@@ -1085,7 +1086,9 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio, ...@@ -1085,7 +1086,9 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
btrfs_bio(bio)->device = stripe->dev; btrfs_bio(bio)->device = stripe->dev;
bio->bi_iter.bi_size = 0; bio->bi_iter.bi_size = 0;
bio_set_dev(bio, stripe->dev->bdev); bio_set_dev(bio, stripe->dev->bdev);
bio->bi_opf = opf;
bio->bi_iter.bi_sector = disk_start >> 9; bio->bi_iter.bi_sector = disk_start >> 9;
bio->bi_private = rbio;
bio_add_page(bio, page, PAGE_SIZE, 0); bio_add_page(bio, page, PAGE_SIZE, 0);
bio_list_add(bio_list, bio); bio_list_add(bio_list, bio);
...@@ -1254,7 +1257,8 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1254,7 +1257,8 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
} }
ret = rbio_add_io_page(rbio, &bio_list, ret = rbio_add_io_page(rbio, &bio_list,
page, stripe, pagenr, rbio->stripe_len); page, stripe, pagenr, rbio->stripe_len,
REQ_OP_WRITE);
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
...@@ -1279,7 +1283,8 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1279,7 +1283,8 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
ret = rbio_add_io_page(rbio, &bio_list, page, ret = rbio_add_io_page(rbio, &bio_list, page,
rbio->bioc->tgtdev_map[stripe], rbio->bioc->tgtdev_map[stripe],
pagenr, rbio->stripe_len); pagenr, rbio->stripe_len,
REQ_OP_WRITE);
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
...@@ -1290,9 +1295,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1290,9 +1295,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
BUG_ON(atomic_read(&rbio->stripes_pending) == 0); BUG_ON(atomic_read(&rbio->stripes_pending) == 0);
while ((bio = bio_list_pop(&bio_list))) { while ((bio = bio_list_pop(&bio_list))) {
bio->bi_private = rbio;
bio->bi_end_io = raid_write_end_io; bio->bi_end_io = raid_write_end_io;
bio->bi_opf = REQ_OP_WRITE;
submit_bio(bio); submit_bio(bio);
} }
...@@ -1496,7 +1499,8 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) ...@@ -1496,7 +1499,8 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
continue; continue;
ret = rbio_add_io_page(rbio, &bio_list, page, ret = rbio_add_io_page(rbio, &bio_list, page,
stripe, pagenr, rbio->stripe_len); stripe, pagenr, rbio->stripe_len,
REQ_OP_READ);
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
...@@ -1519,9 +1523,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) ...@@ -1519,9 +1523,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
*/ */
atomic_set(&rbio->stripes_pending, bios_to_read); atomic_set(&rbio->stripes_pending, bios_to_read);
while ((bio = bio_list_pop(&bio_list))) { while ((bio = bio_list_pop(&bio_list))) {
bio->bi_private = rbio;
bio->bi_end_io = raid_rmw_end_io; bio->bi_end_io = raid_rmw_end_io;
bio->bi_opf = REQ_OP_READ;
btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56); btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56);
...@@ -2038,7 +2040,8 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) ...@@ -2038,7 +2040,8 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
ret = rbio_add_io_page(rbio, &bio_list, ret = rbio_add_io_page(rbio, &bio_list,
rbio_stripe_page(rbio, stripe, pagenr), rbio_stripe_page(rbio, stripe, pagenr),
stripe, pagenr, rbio->stripe_len); stripe, pagenr, rbio->stripe_len,
REQ_OP_READ);
if (ret < 0) if (ret < 0)
goto cleanup; goto cleanup;
} }
...@@ -2065,9 +2068,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) ...@@ -2065,9 +2068,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
*/ */
atomic_set(&rbio->stripes_pending, bios_to_read); atomic_set(&rbio->stripes_pending, bios_to_read);
while ((bio = bio_list_pop(&bio_list))) { while ((bio = bio_list_pop(&bio_list))) {
bio->bi_private = rbio;
bio->bi_end_io = raid_recover_end_io; bio->bi_end_io = raid_recover_end_io;
bio->bi_opf = REQ_OP_READ;
btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56); btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56);
...@@ -2398,8 +2399,8 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2398,8 +2399,8 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
struct page *page; struct page *page;
page = rbio_stripe_page(rbio, rbio->scrubp, pagenr); page = rbio_stripe_page(rbio, rbio->scrubp, pagenr);
ret = rbio_add_io_page(rbio, &bio_list, ret = rbio_add_io_page(rbio, &bio_list, page, rbio->scrubp,
page, rbio->scrubp, pagenr, rbio->stripe_len); pagenr, rbio->stripe_len, REQ_OP_WRITE);
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
...@@ -2413,7 +2414,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2413,7 +2414,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
page = rbio_stripe_page(rbio, rbio->scrubp, pagenr); page = rbio_stripe_page(rbio, rbio->scrubp, pagenr);
ret = rbio_add_io_page(rbio, &bio_list, page, ret = rbio_add_io_page(rbio, &bio_list, page,
bioc->tgtdev_map[rbio->scrubp], bioc->tgtdev_map[rbio->scrubp],
pagenr, rbio->stripe_len); pagenr, rbio->stripe_len, REQ_OP_WRITE);
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
...@@ -2429,9 +2430,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ...@@ -2429,9 +2430,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
atomic_set(&rbio->stripes_pending, nr_data); atomic_set(&rbio->stripes_pending, nr_data);
while ((bio = bio_list_pop(&bio_list))) { while ((bio = bio_list_pop(&bio_list))) {
bio->bi_private = rbio;
bio->bi_end_io = raid_write_end_io; bio->bi_end_io = raid_write_end_io;
bio->bi_opf = REQ_OP_WRITE;
submit_bio(bio); submit_bio(bio);
} }
...@@ -2583,8 +2582,8 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio) ...@@ -2583,8 +2582,8 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio)
if (PageUptodate(page)) if (PageUptodate(page))
continue; continue;
ret = rbio_add_io_page(rbio, &bio_list, page, ret = rbio_add_io_page(rbio, &bio_list, page, stripe,
stripe, pagenr, rbio->stripe_len); pagenr, rbio->stripe_len, REQ_OP_READ);
if (ret) if (ret)
goto cleanup; goto cleanup;
} }
...@@ -2607,9 +2606,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio) ...@@ -2607,9 +2606,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio)
*/ */
atomic_set(&rbio->stripes_pending, bios_to_read); atomic_set(&rbio->stripes_pending, bios_to_read);
while ((bio = bio_list_pop(&bio_list))) { while ((bio = bio_list_pop(&bio_list))) {
bio->bi_private = rbio;
bio->bi_end_io = raid56_parity_scrub_end_io; bio->bi_end_io = raid56_parity_scrub_end_io;
bio->bi_opf = REQ_OP_READ;
btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56); btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment