From patchwork Sat Oct 29 08:08:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403467 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 72982601C0 for ; Sat, 29 Oct 2016 08:33:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60B9C2A6BD for ; Sat, 29 Oct 2016 08:33:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 552B72A6CD; Sat, 29 Oct 2016 08:33:29 +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 F307B2A6BD for ; Sat, 29 Oct 2016 08:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756756AbcJ2IMZ (ORCPT ); Sat, 29 Oct 2016 04:12:25 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35398 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756406AbcJ2IMV (ORCPT ); Sat, 29 Oct 2016 04:12:21 -0400 Received: by mail-pf0-f193.google.com with SMTP id s8so3376525pfj.2; Sat, 29 Oct 2016 01:12:20 -0700 (PDT) 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=rZWNu3V5wNys6gVLZpIIMfeb6zRAmII2ErJFLHsBLjU=; b=fnZmfILd030HvYIw3yvN7gNT5atPuLOsqhShvnuEFWwZ8c6HGFlVQGQSPrDrDp47j/ hXM70S+VG34w8rUssx1EdKdOcW5AuO+748d0okSMBP0BgVDYz6GDuHqVDeGVzMVlTXkq aHLSD+as+ZRslxqfkKlE3qL/3IKHSc7ir+vpqWdJmtsadEwpiqHzxeOZMMRHt9q2yt/F N8xojXvbzfoEIt2qqZ4nUXsa28+mRauf1fW2b+Vk/P349M0rsdiLyAkjveWe6wArcUs0 BoGPjlZuQoqdiYW3Ke2dIlaoc27eBjTnZHzMVkUKaKOVzpggYrJWzJkRyt4TphDZ27M4 urWQ== 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=rZWNu3V5wNys6gVLZpIIMfeb6zRAmII2ErJFLHsBLjU=; b=l3rx1pbILO8vWfd96ok7p3jLgqg298XYkvfTssaoZ91JVR0O9cl4yep0OmVUVGourc paki+7SEpTEkWqaUrKlTcJu2C8B4UXFXFx7cMoYkbLeiaG0tLUv90liWhGwSgEoiizYR YrkaCIkteMmMKd9QToCbEdRYTJQDdDoTodImaWmDIXO2cwoPRURAYzodHXWOBJwpYTQh RL6iF0m+yJ0d4g1gLNNR4KXeY4R5bk2vz8dh3v5LFmzDOoYRmECBC5wFB8FkoJgaIPSc tKsb5Z2R4Y2ZWmJumdSa0xReZg89FD7ZiclhefSXXgT5WFiXvb/vLo/QY79lyFxYn2EL +D0Q== X-Gm-Message-State: ABUngvdnW0MQ/H/QcbMw5q4kk50/K9lpEtOp+5/rKVRyNo20umXbzwr7xMYkGxQrmK5SUw== X-Received: by 10.98.27.21 with SMTP id b21mr32155681pfb.12.1477728740266; Sat, 29 Oct 2016 01:12:20 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id 141sm23511933pfw.63.2016.10.29.01.12.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:12:19 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , "Kirill A . Shutemov" , 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 05/60] target: avoid to access .bi_vcnt directly Date: Sat, 29 Oct 2016 16:08:04 +0800 Message-Id: <1477728600-12938-6-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> References: <1477728600-12938-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(). Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- 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);