Return-Path: Received: from mail.linux-iscsi.org ([67.23.28.174]:56138 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754400AbdEGWtq (ORCPT ); Sun, 7 May 2017 18:49:46 -0400 Message-ID: <1494197384.30469.34.camel@haakon3.risingtidesystems.com> Subject: Re: [PATCH 06/19] target: Fix data buffer size for VERIFY and WRITE AND VERIFY commands From: "Nicholas A. Bellinger" To: Bart Van Assche Cc: target-devel@vger.kernel.org, Hannes Reinecke , Christoph Hellwig , Andy Grover , David Disseldorp , stable@vger.kernel.org Date: Sun, 07 May 2017 15:49:44 -0700 In-Reply-To: <20170504225102.8931-7-bart.vanassche@sandisk.com> References: <20170504225102.8931-1-bart.vanassche@sandisk.com> <20170504225102.8931-7-bart.vanassche@sandisk.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On Thu, 2017-05-04 at 15:50 -0700, Bart Van Assche wrote: > For VERIFY and WRITE AND VERIFY commands the size of the SCSI > Data-Out buffer can differ from the size of the data area on > the storage medium that is affected by the command. Make sure > that the Data-Out buffer size is computed correctly. Apparently > this part got dropped from my previous VERIFY / WRITE AND VERIFY > patch before I posted it due to rebasing. > > Fixes: commit 0e2eb7d12eaa ("target: Fix VERIFY and WRITE VERIFY command parsing") > Signed-off-by: Bart Van Assche > Cc: Hannes Reinecke > Cc: Christoph Hellwig > Cc: Andy Grover > Cc: David Disseldorp > Cc: > --- > drivers/target/target_core_sbc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c > index a0ad618f1b1a..51489d96cb31 100644 > --- a/drivers/target/target_core_sbc.c > +++ b/drivers/target/target_core_sbc.c > @@ -888,9 +888,10 @@ static sense_reason_t sbc_parse_verify(struct se_cmd *cmd, int *sectors, > sense_reason_t > sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) > { > + enum { INVALID_SIZE = 1 }; > struct se_device *dev = cmd->se_dev; > unsigned char *cdb = cmd->t_task_cdb; > - unsigned int size; > + unsigned int size = INVALID_SIZE; > u32 sectors = 0; > sense_reason_t ret; > > @@ -1212,7 +1213,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) > return TCM_ADDRESS_OUT_OF_RANGE; > } > > - if (!(cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE)) > + if (size == INVALID_SIZE) > size = sbc_get_size(cmd, sectors); > } > This patch has no effect. All it does for VERIFY + WRITE_AND_VERIFY is prevent sbc_get_size() from being called twice with the same parameters, because your previous patch in for-next was incorrectly only doing it for only bytchk = 1. Anyways, sbc_parse_verify() should not being doing this directly, and not for only bytchk = 1. Anyways, I've fixed both cases and will post the proper fix inline against patch #19.