@@ -428,10 +428,8 @@ bool bio_integrity_prep(struct bio *bio)
428
428
{
429
429
struct bio_integrity_payload * bip ;
430
430
struct blk_integrity * bi = blk_get_integrity (bio -> bi_bdev -> bd_disk );
431
+ unsigned int len ;
431
432
void * buf ;
432
- unsigned long start , end ;
433
- unsigned int len , nr_pages ;
434
- unsigned int bytes , offset , i ;
435
433
gfp_t gfp = GFP_NOIO ;
436
434
437
435
if (!bi )
@@ -471,12 +469,7 @@ bool bio_integrity_prep(struct bio *bio)
471
469
goto err_end_io ;
472
470
}
473
471
474
- end = (((unsigned long ) buf ) + len + PAGE_SIZE - 1 ) >> PAGE_SHIFT ;
475
- start = ((unsigned long ) buf ) >> PAGE_SHIFT ;
476
- nr_pages = end - start ;
477
-
478
- /* Allocate bio integrity payload and integrity vectors */
479
- bip = bio_integrity_alloc (bio , GFP_NOIO , nr_pages );
472
+ bip = bio_integrity_alloc (bio , GFP_NOIO , 1 );
480
473
if (IS_ERR (bip )) {
481
474
printk (KERN_ERR "could not allocate data integrity bioset\n" );
482
475
kfree (buf );
@@ -489,23 +482,10 @@ bool bio_integrity_prep(struct bio *bio)
489
482
if (bi -> csum_type == BLK_INTEGRITY_CSUM_IP )
490
483
bip -> bip_flags |= BIP_IP_CHECKSUM ;
491
484
492
- /* Map it */
493
- offset = offset_in_page (buf );
494
- for (i = 0 ; i < nr_pages && len > 0 ; i ++ ) {
495
- bytes = PAGE_SIZE - offset ;
496
-
497
- if (bytes > len )
498
- bytes = len ;
499
-
500
- if (bio_integrity_add_page (bio , virt_to_page (buf ),
501
- bytes , offset ) < bytes ) {
502
- printk (KERN_ERR "could not attach integrity payload\n" );
503
- goto err_end_io ;
504
- }
505
-
506
- buf += bytes ;
507
- len -= bytes ;
508
- offset = 0 ;
485
+ if (bio_integrity_add_page (bio , virt_to_page (buf ), len ,
486
+ offset_in_page (buf )) < len ) {
487
+ printk (KERN_ERR "could not attach integrity payload\n" );
488
+ goto err_end_io ;
509
489
}
510
490
511
491
/* Auto-generate integrity metadata if this is a write */
0 commit comments