From: Damien Le Moal <dlemoal@kernel.org>
To: Nick Spooner <nicholas.spooner@seagate.com>,
Niklas Cassel <cassel@kernel.org>
Cc: linux-ide@vger.kernel.org, Hannes Reinecke <hare@kernel.org>,
"Martin K . Petersen" <mkp@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] ata: libata-scsi: fix REQUESTED MAX LBA field for REMOVE ELEMENT AND TRUNCATE
Date: Sun, 15 Nov 2026 10:58:21 +0900 [thread overview]
Message-ID: <f72e653e-2cef-4920-89c3-f32ebc68de95@kernel.org> (raw)
In-Reply-To: <20261113151929.9586-1-nicholas.spooner@seagate.com>
On 11/14/26 00:19, Nick Spooner wrote:
> ata_scsi_remove_element_and_truncate_xlat() copies the REQUESTED CAPACITY
> field, req_capacity, to REQUESTED MAX LBA for every block count except 1.
>
> However, SAT-6 specifies that if REQUESTED CAPACITY is greater than one,
> the REQUESTED MAX LBA shall be set to REQUESTED CAPACITY minus one, since
> the max LBA = count - 1 (see SAT-6 rev2, 9.16.1, Table 74). For example, if
> a capacity C > 1 is requested, the capacity ends up one block larger if the
> drive can provide C + 1. If the drive can provide C but not C + 1, a
> request that should be valid is instead rejected with INVALID FIELD IN CDB
> (see ACS-5 rev10, 7.33.3.3).
>
> Modify ata_scsi_remove_element_and_truncate_xlat() to decrement
> req_capacity, except when equal to 1 or 0 (rejected if 1, let the device
> choose if 0).
>
> Tested by issuing sg_rem_rest_elem on a Seagate drive ST32000NM001F,
> firmware db02 and checking the taskfile.
>
> Fixes: db496721cb0d ("ata: libata-scsi: add support for the REMOVE ELEMENT AND TRUNCATE command")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nick Spooner <nicholas.spooner@seagate.com>
Good catch for the "- 1", but checking SAT, it says that:
If the REQUESTED CAPACITY field is set to one, then the REMOVE
ELEMENT AND TRUNCATE command shall be terminated with a
CHECK CONDITION status with the sense key set to ILLEGAL
REQUEST and the additional sense code set to INVALID FIELD IN
CDB.
So we should not silently ignore the 1 case and fail it.
Can you send a v2 with that failure added?
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-11-15 1:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 15:19 [PATCH] ata: libata-scsi: fix REQUESTED MAX LBA field for REMOVE ELEMENT AND TRUNCATE Nick Spooner
2026-11-15 1:58 ` Damien Le Moal [this message]
2026-11-16 16:47 ` Nick Spooner
2026-11-16 20:30 ` Damien Le Moal
2026-11-16 17:40 ` Niklas Cassel
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=f72e653e-2cef-4920-89c3-f32ebc68de95@kernel.org \
--to=dlemoal@kernel.org \
--cc=cassel@kernel.org \
--cc=hare@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=nicholas.spooner@seagate.com \
--cc=stable@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