@@ -2489,27 +2489,27 @@ static void end_bio_extent_writepage(struct bio *bio, int err)
24892489
24902490 bio_for_each_page_all (bvec , bio , iter ) {
24912491 struct page * page = bvec .bv_page ;
2492+ unsigned int bv_len = min_t (unsigned int , bvec .bv_len , PAGE_CACHE_SIZE );
24922493
24932494 /* We always issue full-page reads, but if some block
24942495 * in a page fails to read, blk_update_request() will
24952496 * advance bv_offset and adjust bv_len to compensate.
24962497 * Print a warning for nonzero offsets, and an error
24972498 * if they don't add up to a full page. */
24982499 if (bvec .bv_offset ) {
2499- if (bvec .bv_offset + bvec . bv_len != PAGE_CACHE_SIZE )
2500+ if (bvec .bv_offset + bv_len != PAGE_CACHE_SIZE )
25002501 btrfs_err (BTRFS_I (page -> mapping -> host )-> root -> fs_info ,
25012502 "partial page write in btrfs with offset %u and length %u" ,
2502- bvec .bv_offset , bvec . bv_len );
2503+ bvec .bv_offset , bv_len );
25032504 else
25042505 btrfs_info (BTRFS_I (page -> mapping -> host )-> root -> fs_info ,
25052506 "incomplete page write in btrfs with offset %u and "
25062507 "length %u" ,
2507- bvec .bv_offset , bvec . bv_len );
2508+ bvec .bv_offset , bv_len );
25082509 }
25092510
25102511 start = page_offset (page );
2511- end = start + bvec .bv_offset
2512- + min_t (unsigned int , bvec .bv_len , PAGE_CACHE_SIZE ) - 1 ;
2512+ end = start + bvec .bv_offset + bv_len - 1 ;
25132513
25142514 if (end_extent_writepage (page , err , start , end ))
25152515 continue ;
@@ -2565,6 +2565,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
25652565 bio_for_each_page_all (bvec , bio , iter ) {
25662566 struct page * page = bvec .bv_page ;
25672567 struct inode * inode = page -> mapping -> host ;
2568+ unsigned int bv_len = min_t (unsigned int , bvec .bv_len , PAGE_CACHE_SIZE );
25682569
25692570 pr_debug ("end_bio_extent_readpage: bi_sector=%llu, err=%d, "
25702571 "mirror=%u\n" , (u64 )bio -> bi_iter .bi_sector , err ,
@@ -2577,21 +2578,20 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
25772578 * Print a warning for nonzero offsets, and an error
25782579 * if they don't add up to a full page. */
25792580 if (bvec .bv_offset ) {
2580- if (bvec .bv_offset + bvec . bv_len != PAGE_CACHE_SIZE )
2581+ if (bvec .bv_offset + bv_len != PAGE_CACHE_SIZE )
25812582 btrfs_err (BTRFS_I (page -> mapping -> host )-> root -> fs_info ,
25822583 "partial page read in btrfs with offset %u and length %u" ,
2583- bvec .bv_offset , bvec . bv_len );
2584+ bvec .bv_offset , bv_len );
25842585 else
25852586 btrfs_info (BTRFS_I (page -> mapping -> host )-> root -> fs_info ,
25862587 "incomplete page read in btrfs with offset %u and "
25872588 "length %u" ,
2588- bvec .bv_offset , bvec . bv_len );
2589+ bvec .bv_offset , bv_len );
25892590 }
25902591
25912592 start = page_offset (page );
2592- end = start + bvec .bv_offset
2593- + min_t (unsigned int , bvec .bv_len , PAGE_CACHE_SIZE ) - 1 ;
2594- len = bvec .bv_len ;
2593+ end = start + bvec .bv_offset + bv_len - 1 ;
2594+ len = bv_len ;
25952595
25962596 mirror = io_bio -> mirror_num ;
25972597 if (likely (uptodate && tree -> ops &&
0 commit comments