@@ -95,6 +95,7 @@ struct btrfs_bio_ctrl {
95
95
enum btrfs_compression_type compress_type ;
96
96
u32 len_to_stripe_boundary ;
97
97
u32 len_to_oe_boundary ;
98
+ btrfs_bio_end_io_t end_io_func ;
98
99
};
99
100
100
101
struct extent_page_data {
@@ -1479,15 +1480,16 @@ static int alloc_new_bio(struct btrfs_inode *inode,
1479
1480
struct btrfs_bio_ctrl * bio_ctrl ,
1480
1481
struct writeback_control * wbc ,
1481
1482
blk_opf_t opf ,
1482
- btrfs_bio_end_io_t end_io_func ,
1483
1483
u64 disk_bytenr , u32 offset , u64 file_offset ,
1484
1484
enum btrfs_compression_type compress_type )
1485
1485
{
1486
1486
struct btrfs_fs_info * fs_info = inode -> root -> fs_info ;
1487
1487
struct bio * bio ;
1488
1488
int ret ;
1489
1489
1490
- bio = btrfs_bio_alloc (BIO_MAX_VECS , opf , end_io_func , NULL );
1490
+ ASSERT (bio_ctrl -> end_io_func );
1491
+
1492
+ bio = btrfs_bio_alloc (BIO_MAX_VECS , opf , bio_ctrl -> end_io_func , NULL );
1491
1493
/*
1492
1494
* For compressed page range, its disk_bytenr is always @disk_bytenr
1493
1495
* passed in, no matter if we have added any range into previous bio.
@@ -1548,7 +1550,6 @@ static int alloc_new_bio(struct btrfs_inode *inode,
1548
1550
* @size: portion of page that we want to write to
1549
1551
* @pg_offset: offset of the new bio or to check whether we are adding
1550
1552
* a contiguous page to the previous one
1551
- * @end_io_func: end_io callback for new bio
1552
1553
* @compress_type: compress type for current bio
1553
1554
*
1554
1555
* The will either add the page into the existing @bio_ctrl->bio, or allocate a
@@ -1561,7 +1562,6 @@ static int submit_extent_page(blk_opf_t opf,
1561
1562
struct btrfs_bio_ctrl * bio_ctrl ,
1562
1563
u64 disk_bytenr , struct page * page ,
1563
1564
size_t size , unsigned long pg_offset ,
1564
- btrfs_bio_end_io_t end_io_func ,
1565
1565
enum btrfs_compression_type compress_type ,
1566
1566
bool force_bio_submit )
1567
1567
{
@@ -1573,6 +1573,9 @@ static int submit_extent_page(blk_opf_t opf,
1573
1573
1574
1574
ASSERT (pg_offset < PAGE_SIZE && size <= PAGE_SIZE &&
1575
1575
pg_offset + size <= PAGE_SIZE );
1576
+
1577
+ ASSERT (bio_ctrl -> end_io_func );
1578
+
1576
1579
if (force_bio_submit )
1577
1580
submit_one_bio (bio_ctrl );
1578
1581
@@ -1583,7 +1586,7 @@ static int submit_extent_page(blk_opf_t opf,
1583
1586
/* Allocate new bio if needed */
1584
1587
if (!bio_ctrl -> bio ) {
1585
1588
ret = alloc_new_bio (inode , bio_ctrl , wbc , opf ,
1586
- end_io_func , disk_bytenr , offset ,
1589
+ disk_bytenr , offset ,
1587
1590
page_offset (page ) + cur ,
1588
1591
compress_type );
1589
1592
if (ret < 0 )
@@ -1763,6 +1766,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
1763
1766
memzero_page (page , zero_offset , iosize );
1764
1767
}
1765
1768
}
1769
+ bio_ctrl -> end_io_func = end_bio_extent_readpage ;
1766
1770
begin_page_read (fs_info , page );
1767
1771
while (cur <= end ) {
1768
1772
unsigned long this_bio_flag = 0 ;
@@ -1876,8 +1880,8 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
1876
1880
1877
1881
ret = submit_extent_page (REQ_OP_READ | read_flags , NULL ,
1878
1882
bio_ctrl , disk_bytenr , page , iosize ,
1879
- pg_offset , end_bio_extent_readpage ,
1880
- this_bio_flag , force_bio_submit );
1883
+ pg_offset , this_bio_flag ,
1884
+ force_bio_submit );
1881
1885
if (ret ) {
1882
1886
/*
1883
1887
* We have to unlock the remaining range, or the page
@@ -2096,6 +2100,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
2096
2100
*/
2097
2101
wbc -> nr_to_write -- ;
2098
2102
2103
+ epd -> bio_ctrl .end_io_func = end_bio_extent_writepage ;
2099
2104
while (cur <= end ) {
2100
2105
u64 disk_bytenr ;
2101
2106
u64 em_end ;
@@ -2192,7 +2197,6 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
2192
2197
& epd -> bio_ctrl , disk_bytenr ,
2193
2198
page , iosize ,
2194
2199
cur - page_offset (page ),
2195
- end_bio_extent_writepage ,
2196
2200
0 , false);
2197
2201
if (ret ) {
2198
2202
has_error = true;
@@ -2685,10 +2689,11 @@ static int write_one_subpage_eb(struct extent_buffer *eb,
2685
2689
if (no_dirty_ebs )
2686
2690
clear_page_dirty_for_io (page );
2687
2691
2692
+ epd -> bio_ctrl .end_io_func = end_bio_subpage_eb_writepage ;
2693
+
2688
2694
ret = submit_extent_page (REQ_OP_WRITE | write_flags , wbc ,
2689
2695
& epd -> bio_ctrl , eb -> start , page , eb -> len ,
2690
- eb -> start - page_offset (page ),
2691
- end_bio_subpage_eb_writepage , 0 , false);
2696
+ eb -> start - page_offset (page ), 0 , false);
2692
2697
if (ret ) {
2693
2698
btrfs_subpage_clear_writeback (fs_info , page , eb -> start , eb -> len );
2694
2699
set_btree_ioerr (page , eb );
@@ -2719,6 +2724,8 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
2719
2724
2720
2725
prepare_eb_write (eb );
2721
2726
2727
+ epd -> bio_ctrl .end_io_func = end_bio_extent_buffer_writepage ;
2728
+
2722
2729
num_pages = num_extent_pages (eb );
2723
2730
for (i = 0 ; i < num_pages ; i ++ ) {
2724
2731
struct page * p = eb -> pages [i ];
@@ -2727,9 +2734,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
2727
2734
set_page_writeback (p );
2728
2735
ret = submit_extent_page (REQ_OP_WRITE | write_flags , wbc ,
2729
2736
& epd -> bio_ctrl , disk_bytenr , p ,
2730
- PAGE_SIZE , 0 ,
2731
- end_bio_extent_buffer_writepage ,
2732
- 0 , false);
2737
+ PAGE_SIZE , 0 , 0 , false);
2733
2738
if (ret ) {
2734
2739
set_btree_ioerr (p , eb );
2735
2740
if (PageWriteback (p ))
@@ -4978,13 +4983,14 @@ static int read_extent_buffer_subpage(struct extent_buffer *eb, int wait,
4978
4983
eb -> read_mirror = 0 ;
4979
4984
atomic_set (& eb -> io_pages , 1 );
4980
4985
check_buffer_tree_ref (eb );
4986
+ bio_ctrl .end_io_func = end_bio_extent_readpage ;
4987
+
4981
4988
btrfs_subpage_clear_error (fs_info , page , eb -> start , eb -> len );
4982
4989
4983
4990
btrfs_subpage_start_reader (fs_info , page , eb -> start , eb -> len );
4984
4991
ret = submit_extent_page (REQ_OP_READ , NULL , & bio_ctrl ,
4985
4992
eb -> start , page , eb -> len ,
4986
- eb -> start - page_offset (page ),
4987
- end_bio_extent_readpage , 0 , true);
4993
+ eb -> start - page_offset (page ), 0 , true);
4988
4994
if (ret ) {
4989
4995
/*
4990
4996
* In the endio function, if we hit something wrong we will
@@ -5075,6 +5081,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num)
5075
5081
* set io_pages. See check_buffer_tree_ref for a more detailed comment.
5076
5082
*/
5077
5083
check_buffer_tree_ref (eb );
5084
+ bio_ctrl .end_io_func = end_bio_extent_readpage ;
5078
5085
for (i = 0 ; i < num_pages ; i ++ ) {
5079
5086
page = eb -> pages [i ];
5080
5087
@@ -5088,8 +5095,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num)
5088
5095
ClearPageError (page );
5089
5096
err = submit_extent_page (REQ_OP_READ , NULL ,
5090
5097
& bio_ctrl , page_offset (page ), page ,
5091
- PAGE_SIZE , 0 , end_bio_extent_readpage ,
5092
- 0 , false);
5098
+ PAGE_SIZE , 0 , 0 , false);
5093
5099
if (err ) {
5094
5100
/*
5095
5101
* We failed to submit the bio so it's the
0 commit comments