For my large capacity drives connected to my SAS HBA i get improper
sector values when i use hdparm to get the native max. Also, the drives
have known bad sectors, but when read fails, the sector information
printed in the sense buffer is incorrect.
In fill_result_tf() of libata-core.c the flags for the resultant tf is
copied from the request tf before calling the qc_fill_rtf() for the
driver. In case of SAS we convert the FIS to tf after receiving the
response and memcpy this tf over to the result tf in
sas_ata_qc_fill_rtf(); which results in overwriting the flags
for rtf. As a result, when ata_tf_read_block() is called by
ata_gen_ata_sense() ata_tf_read_block() does not find ATA_TFLAG_LBA or
ATA_TFLAG_LBA48 in the rtf flags. Hence, the returned block value is not
calculated correctly.
The fix sets the flags in result tf from tf after calling qc_fill_rtf()
to take care of overwrites (as in libsas). Also, if the overwrite was
intentional, we will only setup the right bits here.
From 68c77e87da2d33c2fdb5b5f349252c28374f1dc5 Mon Sep 17 00:00:00 2001
From: Praveen Murali <pmurali@xxxxxxxxxxxx>
Date: Thu, 21 Jun 2012 16:25:52 -0700
Subject: [PATCH v1] Fix sector number translation in sense buffer for SATA drives.
For my large capacity drives connected to my SAS HBA i get improper
sector values when i use hdparm to get the native max. Also, the drives
have known bad sectors, but when read fails, the sector information printed
in the sense buffer is incorrect.
In fill_result_tf() of libata-core.c the flags for the resultant tf is copied
from the request tf before calling the qc_fill_rtf() for the driver. In case of
SAS we convert the FIS to tf after receiving the response and memcpy this tf over
to the result tf in sas_ata_qc_fill_rtf(); which results in overwriting the flags
for rtf. As a result, when ata_tf_read_block() is called by ata_gen_ata_sense()
ata_tf_read_block() does not find ATA_TFLAG_LBA or ATA_TFLAG_LBA48 in the rtf flags.
Hence, the returned block value is not calculated correctly.
The fix sets the flags in result tf from tf after calling qc_fill_rtf() to take care
of overwrites (as in libsas). Also, if the overwrite was intentional, we will only
setup the right bits here.
---
drivers/ata/libata-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c04ad68..b046d35 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4787,8 +4787,11 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
- qc->result_tf.flags = qc->tf.flags;
ap->ops->qc_fill_rtf(qc);
+ /* set the flags in after filling in rtf since the flag might get
+ * overwritten downstreami (as is the case with libsas/sas_ata.c;
+ * a memcopy is done from a tf buffer created from the FIS). */
+ qc->result_tf.flags |= qc->tf.flags;
}
static void ata_verify_xfer(struct ata_queued_cmd *qc)
--
1.7.10
[SCSI Target Devel]
[Linux SCSI Target Infrastructure]
[Kernel Newbies]
[Share Photos]
[IDE]
[Security]
[Git]
[Netfilter]
[Bugtraq]
[Photos]
[Yosemite]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Linux ATA RAID]
[Linux IIO]
[Samba]
[Video 4 Linux]
[Device Mapper]
[Linux Resources]