Re: [PATCH] ata: implement MODE SELECT command

Sergei Shtylyov
2012-07-04T17:10:16Z

Hello.

On 07/04/2012 03:13 PM, Paolo Bonzini wrote:

> The cache_type file in sysfs lets users configure the disk cache in
> write-through or write-back modes. However, ata disks do not support
> writing to the file because they do not implement the MODE SELECT
> command.

> This patch adds a translation from MODE SELECT (for the caching page
> only) to the ATA SET FEATURES command.

> Cc: Jeff Garzik <jgarzik@pobox.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> drivers/ata/libata-scsi.c | 147 +++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 142 insertions(+), 5 deletions(-)

> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 41cde45..e7702d3 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
[...]
> + switch (pg) {
> + case CACHE_MPAGE:
> + if (ata_mselect_caching(tf, p, pg_len))
> + goto invalid_fld;

Error is in the data, not CDB, so returning "invalied field in CDB" doesn't
make sense...

> + break;
> +
> + default: /* invalid page code */
> + goto invalid_fld;
> + }
> + return 0;
> +
> + invalid_fld:
> + ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x0);
> + /* "Invalid field in cbd" */

s/cbd/CDB/

MBR, Sergei