public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@sandisk.com>
To: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"James.Bottomley@HansenPartnership.com"
	<James.Bottomley@HansenPartnership.com>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "chaitra.basappa@broadcom.com" <chaitra.basappa@broadcom.com>,
	"sathya.prakash@broadcom.com" <sathya.prakash@broadcom.com>,
	"suganath-prabu.subramani@broadcom.com"
	<suganath-prabu.subramani@broadcom.com>,
	"hare@suse.de" <hare@suse.de>,
	"MPT-FusionLinux.pdl@broadcom.com"
	<MPT-FusionLinux.pdl@broadcom.com>, "hch@lst.de" <hch@lst.de>
Subject: Re: [PATCH v4] sd: Check for unaligned partial completion
Date: Wed, 15 Feb 2017 15:10:54 +0000	[thread overview]
Message-ID: <1487171439.2990.2.camel@sandisk.com> (raw)
In-Reply-To: <20170215021230.11181-1-damien.lemoal@wdc.com>

On Wed, 2017-02-15 at 11:12 +0900, Damien Le Moal wrote:
> +			resid = round_up(resid, sector_size);
> +			if (resid < good_bytes)
> +				good_bytes -= resid;
> +			else
> +				good_bytes = 0;
> +			scsi_set_resid(SCpnt, resid);

Hello Damien,

If the Data-Out buffer is smaller than a single logical block, can the above
code cause resid to exceed the Data-Out buffer size? I think we should avoid
to convert a residual overflow into a residual underflow. Additionally, will
round_up() work correctly if resid is negative (residual underflow)? How
about using the following (untested) code instead of the above?

if (resid > 0) {
        resid = min(good_bytes, round_up(resid, sector_size));
        good_bytes -= resid;
        scsi_set_resid(SCpnt, resid);
}

Thanks,

Bart.

  parent reply	other threads:[~2017-02-15 15:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15  2:12 [PATCH v4] sd: Check for unaligned partial completion Damien Le Moal
2017-02-15  6:34 ` Christoph Hellwig
2017-02-15  6:48   ` Damien Le Moal
2017-02-15  7:06     ` Ram Pai
2017-02-16 19:34       ` Guilherme G. Piccoli
2017-02-15 15:10 ` Bart Van Assche [this message]
2017-02-16  0:50   ` Damien Le Moal
2017-02-15 16:42 ` Bart Van Assche
2017-02-16  0:54   ` Damien Le Moal
2017-02-16  1:10     ` Bart Van Assche
2017-02-16  2:52       ` Damien Le Moal
2017-02-16  3:00         ` Damien Le Moal
2017-02-16  3:28         ` Bart Van Assche
2017-02-16  5:17           ` Damien Le Moal
2017-02-16  3:36         ` Martin K. Petersen
2017-02-16  4:16           ` Damien Le Moal

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=1487171439.2990.2.camel@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=chaitra.basappa@broadcom.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox