From: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
To: "Guilherme G. Piccoli" <gpiccoli@linux.vnet.ibm.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
PDL-MPT-FUSIONLINUX <MPT-FusionLinux.pdl@broadcom.com>,
Sathya Prakash <sathya.prakash@broadcom.com>,
Chaitra Basappa <chaitra.basappa@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
Brian King <brking@linux.vnet.ibm.com>,
mauricfo@linux.vnet.ibm.com, linuxram@us.ibm.com
Subject: Re: [PATCH v2] mpt3sas: Force request partial completion alignment
Date: Wed, 25 Jan 2017 10:16:28 +0530 [thread overview]
Message-ID: <CAK=zhgoCNWT+vGtU=BikqOJwFi-kc6Oxj=Q2_jP_OEeYr=XanQ@mail.gmail.com> (raw)
In-Reply-To: <1485272838-23180-1-git-send-email-gpiccoli@linux.vnet.ibm.com>
On Tue, Jan 24, 2017 at 9:17 PM, Guilherme G. Piccoli
<gpiccoli@linux.vnet.ibm.com> wrote:
> From: Ram Pai <linuxram@us.ibm.com>
>
> The firmware or device, possibly under a heavy I/O load, can return
> on a partial unaligned boundary. Scsi-ml expects these requests to be
> completed on an alignment boundary. Scsi-ml blindly requeues the I/O
> without checking the alignment boundary of the I/O request for the
> remaining bytes. This leads to errors, since devices cannot perform
> non-aligned read/write operations.
>
> This patch fixes the issue in the driver. It aligns unaligned
> completions of FS requests, by truncating them to the nearest
> alignment boundary.
>
> Reported-by: Mauricio Faria De Oliveira <mauricfo@linux.vnet.ibm.com>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> ---
> v1->v2:
> * Improved printk, by showing some variables too [suggested by Sreekanth].
This patch looks good. Please consider this patch as
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
>
> drivers/scsi/mpt3sas/mpt3sas_scsih.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index 75f3fce..e52c942 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -4657,6 +4657,8 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
> struct MPT3SAS_DEVICE *sas_device_priv_data;
> u32 response_code = 0;
> unsigned long flags;
> + unsigned int sector_sz;
> + struct request *req;
>
> mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
> scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
> @@ -4715,6 +4717,21 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
> }
>
> xfer_cnt = le32_to_cpu(mpi_reply->TransferCount);
> +
> + /* In case of bogus fw or device, we could end up having
> + * unaligned partial completion. We can force alignment here,
> + * then scsi-ml does not need to handle this misbehavior.
> + */
> + sector_sz = scmd->device->sector_size;
> + req = scmd->request;
> + if (unlikely(sector_sz && req && (req->cmd_type == REQ_TYPE_FS) &&
> + (xfer_cnt % sector_sz))) {
> + sdev_printk(KERN_INFO, scmd->device,
> + "unaligned partial completion avoided (xfer_cnt=%u, sector_sz=%u)\n",
> + xfer_cnt, sector_sz);
> + xfer_cnt = (xfer_cnt / sector_sz) * sector_sz;
> + }
> +
> scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
> if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
> log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
> --
> 2.1.0
>
next prev parent reply other threads:[~2017-01-25 4:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 15:47 [PATCH v2] mpt3sas: Force request partial completion alignment Guilherme G. Piccoli
2017-01-25 4:46 ` Sreekanth Reddy [this message]
2017-01-25 23:46 ` Martin K. Petersen
2017-01-26 13:31 ` Guilherme G. Piccoli
2017-01-26 17:02 ` Ram Pai
2017-01-26 18:37 ` Guilherme G. Piccoli
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='CAK=zhgoCNWT+vGtU=BikqOJwFi-kc6Oxj=Q2_jP_OEeYr=XanQ@mail.gmail.com' \
--to=sreekanth.reddy@broadcom.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=brking@linux.vnet.ibm.com \
--cc=chaitra.basappa@broadcom.com \
--cc=gpiccoli@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=mauricfo@linux.vnet.ibm.com \
--cc=sathya.prakash@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.