mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	block: Add a disk flag to block integrity profile
So far we have relied on the app tag size to determine whether a disk has been formatted with T10 protection information or not. However, not all target devices provide application tag storage. Add a flag to the block integrity profile that indicates whether the disk has been formatted with protection information. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Sagi Grimberg <sagig@dev.mellanox.co.il> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
		
							parent
							
								
									8288f496eb
								
							
						
					
					
						commit
						3aec2f41a8
					
				
					 4 changed files with 28 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -53,6 +53,14 @@ Description:
 | 
			
		|||
		512 bytes of data.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
What:		/sys/block/<disk>/integrity/device_is_integrity_capable
 | 
			
		||||
Date:		July 2014
 | 
			
		||||
Contact:	Martin K. Petersen <martin.petersen@oracle.com>
 | 
			
		||||
Description:
 | 
			
		||||
		Indicates whether a storage device is capable of storing
 | 
			
		||||
		integrity metadata. Set if the device is T10 PI-capable.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
What:		/sys/block/<disk>/integrity/write_generate
 | 
			
		||||
Date:		June 2008
 | 
			
		||||
Contact:	Martin K. Petersen <martin.petersen@oracle.com>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -307,6 +307,12 @@ static ssize_t integrity_generate_show(struct blk_integrity *bi, char *page)
 | 
			
		|||
	return sprintf(page, "%d\n", (bi->flags & BLK_INTEGRITY_GENERATE) != 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ssize_t integrity_device_show(struct blk_integrity *bi, char *page)
 | 
			
		||||
{
 | 
			
		||||
	return sprintf(page, "%u\n",
 | 
			
		||||
		       (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE) != 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct integrity_sysfs_entry integrity_format_entry = {
 | 
			
		||||
	.attr = { .name = "format", .mode = S_IRUGO },
 | 
			
		||||
	.show = integrity_format_show,
 | 
			
		||||
| 
						 | 
				
			
			@ -329,11 +335,17 @@ static struct integrity_sysfs_entry integrity_generate_entry = {
 | 
			
		|||
	.store = integrity_generate_store,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct integrity_sysfs_entry integrity_device_entry = {
 | 
			
		||||
	.attr = { .name = "device_is_integrity_capable", .mode = S_IRUGO },
 | 
			
		||||
	.show = integrity_device_show,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct attribute *integrity_attrs[] = {
 | 
			
		||||
	&integrity_format_entry.attr,
 | 
			
		||||
	&integrity_tag_size_entry.attr,
 | 
			
		||||
	&integrity_verify_entry.attr,
 | 
			
		||||
	&integrity_generate_entry.attr,
 | 
			
		||||
	&integrity_device_entry.attr,
 | 
			
		||||
	NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -270,7 +270,13 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
 | 
			
		|||
		  "Enabling DIX %s protection\n", disk->integrity->name);
 | 
			
		||||
 | 
			
		||||
	/* Signal to block layer that we support sector tagging */
 | 
			
		||||
	if (dif && type && sdkp->ATO) {
 | 
			
		||||
	if (dif && type) {
 | 
			
		||||
 | 
			
		||||
		disk->integrity->flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
 | 
			
		||||
 | 
			
		||||
		if (!sdkp)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		if (type == SD_DIF_TYPE3_PROTECTION)
 | 
			
		||||
			disk->integrity->tag_size = sizeof(u16) + sizeof(u32);
 | 
			
		||||
		else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1461,6 +1461,7 @@ static inline uint64_t rq_io_start_time_ns(struct request *req)
 | 
			
		|||
enum blk_integrity_flags {
 | 
			
		||||
	BLK_INTEGRITY_VERIFY		= 1 << 0,
 | 
			
		||||
	BLK_INTEGRITY_GENERATE		= 1 << 1,
 | 
			
		||||
	BLK_INTEGRITY_DEVICE_CAPABLE	= 1 << 2,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct blk_integrity_iter {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue