Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: Make the integrity mapped property a bio flag

Previously we tracked whether the integrity metadata had been remapped
using a request flag. This was fine for low-level retries. However, if
an I/O was redriven by upper layers we would end up remapping again,
causing the retry to fail.

Deprecate the REQ_INTEGRITY flag and introduce BIO_MAPPED_INTEGRITY
which enables filesystems to notify lower layers that the bio in
question has already been remapped.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

authored by

Martin K. Petersen and committed by
Jens Axboe
495d2b38 e817bf3f

+7 -7
+6 -5
drivers/scsi/sd_dif.c
··· 375 375 unsigned int i, j; 376 376 u32 phys, virt; 377 377 378 - /* Already remapped? */ 379 - if (rq->cmd_flags & REQ_INTEGRITY) 380 - return 0; 381 - 382 378 sdkp = rq->bio->bi_bdev->bd_disk->private_data; 383 379 384 380 if (sdkp->protection_type == SD_DIF_TYPE3_PROTECTION) 385 381 return 0; 386 382 387 - rq->cmd_flags |= REQ_INTEGRITY; 388 383 phys = hw_sector & 0xffffffff; 389 384 390 385 __rq_for_each_bio(bio, rq) { 391 386 struct bio_vec *iv; 387 + 388 + /* Already remapped? */ 389 + if (bio_flagged(bio, BIO_MAPPED_INTEGRITY)) 390 + break; 392 391 393 392 virt = bio->bi_integrity->bip_sector & 0xffffffff; 394 393 ··· 407 408 408 409 kunmap_atomic(sdt, KM_USER0); 409 410 } 411 + 412 + bio->bi_flags |= BIO_MAPPED_INTEGRITY; 410 413 } 411 414 412 415 return 0;
+1 -2
include/linux/blk_types.h
··· 97 97 #define BIO_NULL_MAPPED 9 /* contains invalid user pages */ 98 98 #define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */ 99 99 #define BIO_QUIET 11 /* Make BIO Quiet */ 100 + #define BIO_MAPPED_INTEGRITY 12/* integrity metadata has been remapped */ 100 101 #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) 101 102 102 103 /* ··· 149 148 __REQ_ORDERED_COLOR, /* is before or after barrier */ 150 149 __REQ_ALLOCED, /* request came from our alloc pool */ 151 150 __REQ_COPY_USER, /* contains copies of user pages */ 152 - __REQ_INTEGRITY, /* integrity metadata has been remapped */ 153 151 __REQ_FLUSH, /* request for cache flush */ 154 152 __REQ_IO_STAT, /* account I/O stat */ 155 153 __REQ_MIXED_MERGE, /* merge of different types, fail separately */ ··· 190 190 #define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) 191 191 #define REQ_ALLOCED (1 << __REQ_ALLOCED) 192 192 #define REQ_COPY_USER (1 << __REQ_COPY_USER) 193 - #define REQ_INTEGRITY (1 << __REQ_INTEGRITY) 194 193 #define REQ_FLUSH (1 << __REQ_FLUSH) 195 194 #define REQ_IO_STAT (1 << __REQ_IO_STAT) 196 195 #define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE)