From patchwork Fri Nov 11 12:05:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9422909 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 AACEB60233 for ; Fri, 11 Nov 2016 12:09:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D534299EE for ; Fri, 11 Nov 2016 12:09:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9200F29A85; Fri, 11 Nov 2016 12:09:16 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 17B5F299EE for ; Fri, 11 Nov 2016 12:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756409AbcKKMJO (ORCPT ); Fri, 11 Nov 2016 07:09:14 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33202 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756320AbcKKMGn (ORCPT ); Fri, 11 Nov 2016 07:06:43 -0500 Received: by mail-pf0-f195.google.com with SMTP id 144so2417995pfv.0; Fri, 11 Nov 2016 04:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9Cs7o4XLl29+R3Fk/xEZbE/gg/aC4f37zQ12XewQTDw=; b=KfDTYGRqi/3bu8gtlWY/qYxu8GAERJdYUsI31ifsIYYcCry9eVpsV8L9HjgkXQJV3z uQB5jhqxj2srZFS6HogdbKtdCV+mY56dK7Ze2lkTigHizsLZCmP2AEst81PHUFDRibnY MdqemTOdU1LWtVrLpCcwAVon2RhVUx4u07FgjicvBxCShrCk5OuzCaeRG7od+aMA/79a n9/3BAk5THiGvUmY72yxzG/STGEuYep06wpd7rGH6t7JgTXPjcVXuYMpfSORYyy/DZvD 8H8SQTjdcOTcGvt1+RnZTEpWdr316xmoUXcW8eC6ivGBIrVNYBHw9dL6Ey4pH1tuwNaw xTpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9Cs7o4XLl29+R3Fk/xEZbE/gg/aC4f37zQ12XewQTDw=; b=eqfNYvcNBaOl7dbfoKOulw2H64l5qNmfii1YKMxIY9TSa2Xsgm/W0ckyYfUczTvQwA AG2xn1RaT5qPwz+BdYN0xsRu26kW1owjksp/jVs4Eea1VknrS+XTH8F4RsnGqI0Y08X5 oCcb7hsZQ15jQwNrqjfY6LVGlhJ2PpIRnrYubS4/9oquaMCBmm/mtBG+eP5hBl73F4DD qm7PbFaZsNnTGnJ6i5Uiyqs7I+dt7G4w3K0u+8j+9UagmWcCwCrrzMlm4jfKIiWpAscs c4FJOPLJz3RCvZarLvyxtQqZWQTY0yVR+bwUxYMmCnQ35/LhBPznPsgrzuFXQzxoDiAO ECVA== X-Gm-Message-State: ABUngvdQdUIYXMjUD/tkDKwPIybfHdw5EBAGC+nW0QafYYifQ3sPme7cSygbxzitnac11g== X-Received: by 10.99.134.72 with SMTP id x69mr4326953pgd.140.1478866002236; Fri, 11 Nov 2016 04:06:42 -0800 (PST) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id xy8sm12659876pac.11.2016.11.11.04.06.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Nov 2016 04:06:41 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , Ming Lei , "Nicholas A. Bellinger" , linux-scsi@vger.kernel.org (open list:TARGET SUBSYSTEM), target-devel@vger.kernel.org (open list:TARGET SUBSYSTEM) Subject: [PATCH 04/12] target: avoid to access .bi_vcnt directly Date: Fri, 11 Nov 2016 20:05:32 +0800 Message-Id: <1478865957-25252-5-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478865957-25252-1-git-send-email-tom.leiming@gmail.com> References: <1478865957-25252-1-git-send-email-tom.leiming@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the bio is full, bio_add_pc_page() will return zero, so use this way to handle full bio. Also replace access to .bi_vcnt for pr_debug() with bio_segments(). Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei Reviewed-by: Sagi Grimberg --- drivers/target/target_core_pscsi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 9125d9358dea..04d7aa7390d0 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -935,13 +935,9 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, rc = bio_add_pc_page(pdv->pdv_sd->request_queue, bio, page, bytes, off); - if (rc != bytes) - goto fail; - pr_debug("PSCSI: bio->bi_vcnt: %d nr_vecs: %d\n", - bio->bi_vcnt, nr_vecs); - - if (bio->bi_vcnt > nr_vecs) { + bio_segments(bio), nr_vecs); + if (rc != bytes) { pr_debug("PSCSI: Reached bio->bi_vcnt max:" " %d i: %d bio: %p, allocating another" " bio\n", bio->bi_vcnt, i, bio);