Skip to contentSkip to conversation

scsi: target: Allow FUA if no write cache enabled

PATCH In review Stuart Hayes 2 participants 3 messages Jun 9 – Jun 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: target: Allow FUA if no write cache enabled

Modify target code to ignore FUA bit in commands to targets with no write cache enabled.

Without this patch, accesses with FUA set will be rejected, even though they always go directly to the media when there's no write cache.

This is needed because EDK2 FAT filesystem code sets the FUA bit when writing, regardless of whether the device advertises support of DPOFUA. If a UEFI pre-boot write fails, the filesystem can become inaccessible until a reboot. This can cause linux installs to iSCSI to be unbootable, because some systems have firmware that will try to write a file in a vendor-specific directory under /boot/EFI (such as /boot/EFI/Dell) before attempting to boot to a UEFI boot entry pointing to a file in the FAT filesystem.

---
v1->v2:
- change to only ignore FUA bit set when no write cache is enabled, instead of advertising DPOFUA support

---
 drivers/target/target_core_sbc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/target/target_core_sbc.c +6 -0
index 21f5cb86d70c..ffd2b6c9bd23 100644
@@ -754,6 +754,12 @@ sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)
 	}
 	if (cdb[1] & 0x8) {
 		if (!target_check_fua(dev)) {
+			/*
+			 * Silently ignore FUA if there's no write cache.
+			 */
+			if (!target_check_wce(dev))
+				return 0;
+
 			pr_err("Got CDB: 0x%02x with FUA bit set, but device"
 			       " does not advertise support for FUA write\n",
 			       cdb[0]);
Signature · 1 line
2.47.3
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Critical] Silently dropping the FUA bit when WCE=0 prevents the backend from honoring the FUA request…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Silently dropping the FUA bit when WCE=0 prevents the backend from honoring the FUA request, causing silent data loss in the fileio AIO backend. --

commit 5cb17faff566c1313276f5a67af675e43649d8d6
Author: Stuart Hayes <[email protected]>

scsi: target: Allow FUA if no write cache enabled

This commit modifies the target core code to ignore the FUA bit in SCSI commands for targets without an enabled write cache. This allows systems with firmware that aggressively sets the FUA bit to successfully boot without failing due to unsupported FUA write errors.

Quoted 5 lines
drivers/target/target_core_sbc.c +0 -0
index 21f5cb86d70c0..ffd2b6c9bd231 100644

drivers/target/target_core_sbc.c sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb) · line 762

Quoted 9 lines
drivers/target/target_core_sbc.c +6 -0
@@ -754,6 +754,12 @@ sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)
 	}
 	if (cdb[1] & 0x8) {
 		if (!target_check_fua(dev)) {
+			/*
+			 * Silently ignore FUA if there's no write cache.
+			 */
+			if (!target_check_wce(dev))
+				return 0;
+

[Severity: Critical]
Does returning early here prevent the command from receiving the SCF_FUA flag?

By returning 0, this bypasses the cmd->se_cmd_flags |= SCF_FUA; assignment that happens further down in sbc_check_dpofua().

While WCE=0 implies no write cache, the fileio AIO backend relies entirely on the SCF_FUA flag to ensure synchronous writes:

drivers/target/target_core_file.c:fd_execute_rw_aio() {
...

	aio_cmd->iocb.ki_flags = IOCB_DIRECT;

	if (is_write && (cmd->se_cmd_flags & SCF_FUA))
		aio_cmd->iocb.ki_flags |= IOCB_DSYNC;

...
}

Without the SCF_FUA flag, fd_execute_rw_aio() will issue asynchronous writes without flushing the cache, as it ignores the O_DSYNC flag set on the underlying file descriptor.

Could this regression lead to silent data loss on power failure, since what used to be rejected as an unsupported FUA write will now complete asynchronously without a disk cache flush?

Quoted 3 lines
drivers/target/target_core_sbc.c +0 -0
 			pr_err("Got CDB: 0x%02x with FUA bit set, but device"
 			       " does not advertise support for FUA write\n",
 			       cdb[0]);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
Quoted 47 lines · On 6/9/2026 3:39 PM, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Silently dropping the FUA bit when WCE=0 prevents the backend from honoring the FUA request, causing silent data loss in the fileio AIO backend. --

commit 5cb17faff566c1313276f5a67af675e43649d8d6
Author: Stuart Hayes <[email protected]>

scsi: target: Allow FUA if no write cache enabled

This commit modifies the target core code to ignore the FUA bit in SCSI commands for targets without an enabled write cache. This allows systems with firmware that aggressively sets the FUA bit to successfully boot without failing due to unsupported FUA write errors.

Quoted 5 lines
drivers/target/target_core_sbc.c +0 -0
index 21f5cb86d70c0..ffd2b6c9bd231 100644

drivers/target/target_core_sbc.c sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb) · line 762

Quoted 9 lines
drivers/target/target_core_sbc.c +6 -0
@@ -754,6 +754,12 @@ sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)
  	}
  	if (cdb[1] & 0x8) {
  		if (!target_check_fua(dev)) {
+			/*
+			 * Silently ignore FUA if there's no write cache.
+			 */
+			if (!target_check_wce(dev))
+				return 0;
+

[Severity: Critical]
Does returning early here prevent the command from receiving the SCF_FUA flag?

By returning 0, this bypasses the cmd->se_cmd_flags |= SCF_FUA; assignment that happens further down in sbc_check_dpofua().

While WCE=0 implies no write cache, the fileio AIO backend relies entirely on the SCF_FUA flag to ensure synchronous writes:

drivers/target/target_core_file.c:fd_execute_rw_aio() {
...

	aio_cmd->iocb.ki_flags = IOCB_DIRECT;

	if (is_write && (cmd->se_cmd_flags & SCF_FUA))
		aio_cmd->iocb.ki_flags |= IOCB_DSYNC;

...
}

Quoted 8 lines

Without the SCF_FUA flag, fd_execute_rw_aio() will issue asynchronous writes without flushing the cache, as it ignores the O_DSYNC flag set on the underlying file descriptor.

Could this regression lead to silent data loss on power failure, since what used to be rejected as an unsupported FUA write will now complete asynchronously without a disk cache flush?

Valid point, yes. I will fix.

Also, I accidentally submitted this as V2 when it should have been V3, sorry.

Quoted 4 lines
Quoted 3 lines
drivers/target/target_core_sbc.c +0 -0
  			pr_err("Got CDB: 0x%02x with FUA bit set, but device"
  			       " does not advertise support for FUA write\n",
  			       cdb[0]);