From patchwork Wed Mar 8 08:45:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 9610575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6343B60414 for ; Wed, 8 Mar 2017 08:46:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7982427CEA for ; Wed, 8 Mar 2017 08:46:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E72F27D13; Wed, 8 Mar 2017 08:46:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23D5C28433 for ; Wed, 8 Mar 2017 08:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751276AbdCHIq5 (ORCPT ); Wed, 8 Mar 2017 03:46:57 -0500 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:19250 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751796AbdCHIqj (ORCPT ); Wed, 8 Mar 2017 03:46:39 -0500 Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee658bfc4c0982-4a03f; Wed, 08 Mar 2017 16:45:52 +0800 (CST) X-RM-TRANSID: 2ee658bfc4c0982-4a03f X-RM-SPAM-FLAG: 00000000 Received: from promote.cache-dns.local.cache-dns.local (unknown[223.105.0.130]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee758bfc4bdf2d-08a48; Wed, 08 Mar 2017 16:45:52 +0800 (CST) X-RM-TRANSID: 2ee758bfc4bdf2d-08a48 From: lixiubo@cmss.chinamobile.com To: agrover@redhat.com, nab@linux-iscsi.org, mchristi@redhat.com Cc: shli@kernel.org, sheng@yasker.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, namei.unix@gmail.com, Xiubo Li Subject: [PATCHv2 4/5] target/user: Fix wrongly calculating of the base_command_size Date: Wed, 8 Mar 2017 16:45:42 +0800 Message-Id: <1488962743-17028-5-git-send-email-lixiubo@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488962743-17028-1-git-send-email-lixiubo@cmss.chinamobile.com> References: <1488962743-17028-1-git-send-email-lixiubo@cmss.chinamobile.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiubo Li The t_data_nents and t_bidi_data_nents are all the numbers of the segments, and we couldn't be sure the size of the data area block will equal to size of the segment. Use the actually block number needed intead of the sum of segments. Signed-off-by: Xiubo Li --- drivers/target/target_core_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 99cd239..117be07 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -650,8 +650,7 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, struct tcmu_cmd *cmd, * expensive to tell how many regions are freed in the bitmap */ base_command_size = max(offsetof(struct tcmu_cmd_entry, - req.iov[se_cmd->t_bidi_data_nents + - se_cmd->t_data_nents]), + req.iov[tcmu_cmd->dbi_len]), sizeof(struct tcmu_cmd_entry)); command_size = base_command_size + round_up(scsi_command_size(se_cmd->t_task_cdb), TCMU_OP_ALIGN_SIZE);