1
0

scsi: target: Add helper to set up atomic values from block_device

Add a helper function that sets up the atomic value based on a
block_device similar to what we do for unmap.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
jpg: Set atomic alignment, drop atomic_supported reference
Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://patch.msgid.link/20251020103820.2917593-4-john.g.garry@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Mike Christie
2025-10-20 10:38:16 +00:00
committed by Martin K. Petersen
parent d505447b8d
commit c486634fe2
2 changed files with 19 additions and 0 deletions

View File

@@ -840,6 +840,23 @@ free_device:
return NULL;
}
void target_configure_write_atomic_from_bdev(struct se_dev_attrib *attrib,
struct block_device *bdev)
{
struct request_queue *q = bdev_get_queue(bdev);
int block_size = bdev_logical_block_size(bdev);
if (!bdev_can_atomic_write(bdev))
return;
attrib->atomic_max_len = queue_atomic_write_max_bytes(q) / block_size;
attrib->atomic_granularity = attrib->atomic_alignment =
queue_atomic_write_unit_min_bytes(q) / block_size;
attrib->atomic_max_with_boundary = 0;
attrib->atomic_max_boundary = 0;
}
EXPORT_SYMBOL_GPL(target_configure_write_atomic_from_bdev);
/*
* Check if the underlying struct block_device supports discard and if yes
* configure the UNMAP parameters.

View File

@@ -123,6 +123,8 @@ bool target_sense_desc_format(struct se_device *dev);
sector_t target_to_linux_sector(struct se_device *dev, sector_t lb);
bool target_configure_unmap_from_bdev(struct se_dev_attrib *attrib,
struct block_device *bdev);
void target_configure_write_atomic_from_bdev(struct se_dev_attrib *attrib,
struct block_device *bdev);
static inline bool target_dev_configured(struct se_device *se_dev)
{