Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stuart Hayes" <stuart.w.hayes@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2] scsi: target: Allow FUA if no write cache enabled
Date: Tue, 09 Jun 2026 20:39:52 +0000	[thread overview]
Message-ID: <20260609203953.154771F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260609202156.90700-1-stuart.w.hayes@gmail.com>

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 <stuart.w.hayes@gmail.com>

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.

> diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
> index 21f5cb86d70c0..ffd2b6c9bd231 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;
> +

[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?

>  			pr_err("Got CDB: 0x%02x with FUA bit set, but device"
>  			       " does not advertise support for FUA write\n",
>  			       cdb[0]);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260609202156.90700-1-stuart.w.hayes@gmail.com?part=1

  reply	other threads:[~2026-06-09 20:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 20:21 [PATCH v2] scsi: target: Allow FUA if no write cache enabled Stuart Hayes
2026-06-09 20:39 ` sashiko-bot [this message]
2026-06-10 20:43   ` stuart hayes
  -- strict thread matches above, loose matches on Subject: below --
2026-04-28 20:39 Stuart Hayes
2026-04-30 15:43 ` Martin K. Petersen
2026-06-01 15:11   ` stuart hayes

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=20260609203953.154771F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=stuart.w.hayes@gmail.com \
    /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