Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756434AbcKKMJS (ORCPT ); Fri, 11 Nov 2016 07:09:18 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1104 Lines: 33 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 --- 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); -- 2.7.4