From patchwork Thu Apr 14 12:02:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8835291 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E3B2D9F36E for ; Thu, 14 Apr 2016 12:11:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 160A820122 for ; Thu, 14 Apr 2016 12:11:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3240020173 for ; Thu, 14 Apr 2016 12:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754897AbcDNMDb (ORCPT ); Thu, 14 Apr 2016 08:03:31 -0400 Received: from mail-ob0-f193.google.com ([209.85.214.193]:34069 "EHLO mail-ob0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754885AbcDNMD3 (ORCPT ); Thu, 14 Apr 2016 08:03:29 -0400 Received: by mail-ob0-f193.google.com with SMTP id tz8so4852400obc.1; Thu, 14 Apr 2016 05:03:28 -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=VMm3vUnMBvrBD3UpvqmVHaSx0ZAOIqRaITqGRKX/Nmg=; b=YWxkOr4/57lMCP74voONc5vF2IJeMaDBbjh05413ioanbc41o14UEJaxnaZ8+m6ilw 9SCXUMLzQfolVLv5O9/cXLWg0eYMbVL+BV4RnKqaSgkJpbKyWItl47eYKmYqTFBiYt8Q i2pgvM2XbsEyM3x47T8W59lVhtk0uIRe7BDPY5kcLu8DnPjQqggkUDjf2XGpzNPGAJ+j Ur/UyylzpnD1AprVp3pmDoM+qYrICFLS9izA5iI4A6G8PB/aKOR8S6XerCqgWEvn4FlA Os9QQOFLaDVv6UJE4GoA2fSlL+Wb0YonlHTtZstFw6b1idwHHldmHcZ2AvBuAMfbwGXM 2hHg== 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=VMm3vUnMBvrBD3UpvqmVHaSx0ZAOIqRaITqGRKX/Nmg=; b=KSI3JEXPMtCkzyfXXXxaQT9OR/4MqzrNDbURPBED1zjvwrKw6mEDIcjaUrs+plO3ih eRETducNwsw+oJ1wCfCvf8q0lEIbIIn+CbTfFKSNMQSlpQ+e2JojTs+9Bm41feU3dxBb m4m9emrMahazIe9E/PbPNN7zBngXb8UdNwTDasxrRuoFOX1e0DkeYntLNp4bha8eqq8M W/injkCfA/5KFw8X6egin/u753bFSu9M4FT+KeXZkTwRvnb6gAsdt0lE2tixt37NTvcu QEx/OWlHHa+e8f+61tspm7+Ab/7dFZE0WDQaUGkOXs+UbPo0O2cWFI4q/O4J9UvAaeiM e46Q== X-Gm-Message-State: AOPr4FUV97AiNs1ehwu3070QLp4m/zfEB1DZ8e0FoRMyZCQ4JtTkH+PCKHESU5WmxK8s7Q== X-Received: by 10.60.42.171 with SMTP id p11mr7715685oel.16.1460635408260; Thu, 14 Apr 2016 05:03:28 -0700 (PDT) Received: from localhost ([12.228.154.70]) by smtp.gmail.com with ESMTPSA id b3sm13152328otc.30.2016.04.14.05.03.27 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 14 Apr 2016 05:03:27 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@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 v1 09/27] target: avoid to access .bi_vcnt directly Date: Thu, 14 Apr 2016 20:02:27 +0800 Message-Id: <1460635375-28282-10-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460635375-28282-1-git-send-email-tom.leiming@gmail.com> References: <1460635375-28282-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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.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 --- 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 de18790..66320e8 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -945,13 +945,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);