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.
Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
---
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(+)
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 21f5cb86d70c..ffd2b6c9bd23 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -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]);
--
2.47.3