]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: target: Add atomic support to target_core_iblock
authorMike Christie <michael.christie@oracle.com>
Mon, 20 Oct 2025 10:38:20 +0000 (10:38 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 3 Nov 2025 02:40:02 +0000 (21:40 -0500)
Make target_core_iblock use the LIO helper function to translate its
block_device atomic settings to LIO settings. If we then get a write
that LIO has indicated is atomic via the SCF_ATOMIC flag, we use the
REQ_ATOMIC flag to tell the block layer to perform an atomic write.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://patch.msgid.link/20251020103820.2917593-8-john.g.garry@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_iblock.c

index 281612b9830f8640c705902ea526f14ac1f6e5a4..8ec7b534ad7601f16c6f319b8b1f95cf29a6e10b 100644 (file)
@@ -152,6 +152,8 @@ static int iblock_configure_device(struct se_device *dev)
        if (bdev_nonrot(bd))
                dev->dev_attrib.is_nonrot = 1;
 
+       target_configure_write_atomic_from_bdev(&dev->dev_attrib, bd);
+
        bi = bdev_get_integrity(bd);
        if (!bi)
                return 0;
@@ -773,6 +775,9 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
                        else if (!bdev_write_cache(ib_dev->ibd_bd))
                                opf |= REQ_FUA;
                }
+
+               if (cmd->se_cmd_flags & SCF_ATOMIC)
+                       opf |= REQ_ATOMIC;
        } else {
                opf = REQ_OP_READ;
                miter_dir = SG_MITER_FROM_SG;