Skip to content

Commit

Permalink
bio-integrity: cleanup adding integrity pages to bip's bvec.
Browse files Browse the repository at this point in the history
bio_integrity_add_page() returns the add length if successful, else 0,
just as bio_add_page.  Simply check return value checking in
bio_integrity_prep to not deal with a > 0 but < len case that can't
happen.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Tested-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20230803025058epcms2p5a4d0db5da2ad967668932d463661c633@epcms2p5
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jinyoung Choi authored and Jens Axboe committed Aug 9, 2023
1 parent 80814b8 commit d1f04c2
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions block/bio-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,27 +252,18 @@ bool bio_integrity_prep(struct bio *bio)

/* Map it */
offset = offset_in_page(buf);
for (i = 0 ; i < nr_pages ; i++) {
int ret;
for (i = 0; i < nr_pages && len > 0; i++) {
bytes = PAGE_SIZE - offset;

if (len <= 0)
break;

if (bytes > len)
bytes = len;

ret = bio_integrity_add_page(bio, virt_to_page(buf),
bytes, offset);

if (ret == 0) {
if (bio_integrity_add_page(bio, virt_to_page(buf),
bytes, offset) < bytes) {
printk(KERN_ERR "could not attach integrity payload\n");
goto err_end_io;
}

if (ret < bytes)
break;

buf += bytes;
len -= bytes;
offset = 0;
Expand All @@ -291,7 +282,6 @@ bool bio_integrity_prep(struct bio *bio)
bio->bi_status = BLK_STS_RESOURCE;
bio_endio(bio);
return false;

}
EXPORT_SYMBOL(bio_integrity_prep);

Expand Down

0 comments on commit d1f04c2

Please sign in to comment.