From patchwork Mon Mar 20 09:09:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 9633379 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 F2B19602D6 for ; Mon, 20 Mar 2017 09:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCF012847F for ; Mon, 20 Mar 2017 09:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1B702846B; Mon, 20 Mar 2017 09:16:18 +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 06C022810E for ; Mon, 20 Mar 2017 09:16:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753500AbdCTJQP (ORCPT ); Mon, 20 Mar 2017 05:16:15 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:46450 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753310AbdCTJPX (ORCPT ); Mon, 20 Mar 2017 05:15:23 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app11-12011 (RichMail) with SMTP id 2eeb58cf9c89039-479b8; Mon, 20 Mar 2017 17:10:33 +0800 (CST) X-RM-TRANSID: 2eeb58cf9c89039-479b8 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 2ee758cf9c84f89-7439b; Mon, 20 Mar 2017 17:10:33 +0800 (CST) X-RM-TRANSID: 2ee758cf9c84f89-7439b 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, bryantly@linux.vnet.ibm.com, Xiubo Li Subject: [PATCHv3 4/5] target/user: Fix wrongly calculating of the base_command_size Date: Mon, 20 Mar 2017 17:09:23 +0800 Message-Id: <1490000964-15732-5-git-send-email-lixiubo@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490000964-15732-1-git-send-email-lixiubo@cmss.chinamobile.com> References: <1490000964-15732-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 780c30f..e3daf15 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -598,8 +598,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);