From: John Garry <john.g.garry@oracle.com>
To: martin.petersen@oracle.com
Cc: target-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-scsi@vger.kernel.org, michael.christie@oracle.com,
John Garry <john.g.garry@oracle.com>
Subject: [PATCH v2 3/7] scsi: target: Add helper to setup atomic values from block_device
Date: Fri, 10 Oct 2025 14:15:04 +0000 [thread overview]
Message-ID: <20251010141508.3695908-4-john.g.garry@oracle.com> (raw)
In-Reply-To: <20251010141508.3695908-1-john.g.garry@oracle.com>
From: Mike Christie <michael.christie@oracle.com>
This adds 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>
---
drivers/target/target_core_device.c | 17 +++++++++++++++++
include/target/target_core_backend.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 83fe3d9a9681c..39a2d9c3eb9e1 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -840,6 +840,23 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
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.
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index d394306f8f490..e32de80854b6a 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -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)
{
--
2.43.5
next prev parent reply other threads:[~2025-10-10 14:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 14:15 [PATCH v2 0/7] scsi: target: Add WRITE_ATOMIC_16 support John Garry
2025-10-10 14:15 ` [PATCH v2 1/7] scsi: target: Rename target_configure_unmap_from_queue John Garry
2025-10-10 14:15 ` [PATCH v2 2/7] scsi: target: Add atomic se_device fields John Garry
2025-10-10 14:15 ` John Garry [this message]
2025-10-10 14:15 ` [PATCH v2 4/7] scsi: target: Add WRITE_ATOMIC_16 handler John Garry
2025-10-12 1:38 ` kernel test robot
2025-10-10 14:15 ` [PATCH v2 5/7] scsi: target: Report atomic values in INQUIRY John Garry
2025-10-10 14:15 ` [PATCH v2 6/7] scsi: target: Add WRITE_ATOMIC_16 support to RSOC John Garry
2025-10-10 14:15 ` [PATCH v2 7/7] scsi: target: Add atomic support to target_core_iblock John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251010141508.3695908-4-john.g.garry@oracle.com \
--to=john.g.garry@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox