Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp874564imj; Fri, 15 Feb 2019 08:12:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IZH5Nzgye5tAHsueCBNtVPp+5TixQXY8bXhVTxFe6VSNIw4yyi7gv9E/DCMMGGfYv6NC3BG X-Received: by 2002:a17:902:a415:: with SMTP id p21mr11018586plq.7.1550247178178; Fri, 15 Feb 2019 08:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550247178; cv=none; d=google.com; s=arc-20160816; b=cAAk5L6hdMRtW3GQs6Ezp6DG0Dpzczlq9pQTtreqHDzFgcZ2b8yo1b/hMH8fdDv/EM IUy0J4EFyydv0nqTbo1xjX5MKsWHvdMpZh/3TAYCO5BtUsnnlIEP6NsfYQQcgSS8+9F1 ZdGlMtyI5rolRvqYW0NQ1499YyReF5wcmv2a4cxPWWsmFi1IBchjxkW/gLUq3TxPFoxC exWo0oRsa0pVRAZz6JhsOYtXnJNAdUNq+jrZ3984rrwtRChPrzAeV06aFIFooV2tq/Zv YX0LdarRd4NEd37MC3yDanOtE56y8wUVRBKxFjT2VzdP4r65Xpk+JJnMks9eR/J8cdKc 55hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=xr6DahF5ogf42oUHn8yO+xHUQepi7gnUCentUFTY6cc=; b=Jp3rMfKcJR5r0+VEfJjHxLzATWc9vLBLK4OUjvsHdUAMcaCyZKB0MLP31zsRoIPU1i Hn8p5Mihlf7zjA9zyxyNQuvy4nq98gVZ4dPdBGFKPqQAAnKcPlcJESgCUEKlzWLs1CIy Eb8b8sgyBk1fDkabP9OhwazttC2H2imOPReYy//03iCQcCLmHp0Ub4pcPawkfbi3/ajA Ytm65VKS3lIMY8AJMsS25CnmgoRXvRHttDM48H2H3a/bP3Xsoo8rmAnp3DCGlAZDfsG2 rbuYUzPMH5TXAaIu1T5Qjtj4F5z1/xbrHOG3l4xFiZTvlX6VexdOsn/pdBKDVWNbnQqs HbBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h85si5846977pfd.27.2019.02.15.08.12.36; Fri, 15 Feb 2019 08:12:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436556AbfBOLQe (ORCPT + 99 others); Fri, 15 Feb 2019 06:16:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2904 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732023AbfBOLQX (ORCPT ); Fri, 15 Feb 2019 06:16:23 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5204DC7857; Fri, 15 Feb 2019 11:16:22 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38D6A26E74; Fri, 15 Feb 2019 11:16:20 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V15 12/18] bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() Date: Fri, 15 Feb 2019 19:13:18 +0800 Message-Id: <20190215111324.30129-13-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Feb 2019 11:16:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bch_bio_alloc_pages() is always called on one new bio, so it is safe to access the bvec table directly. Given it is the only kind of this case, open code the bvec table access since bio_for_each_segment_all() will be changed to support for iterating over multipage bvec. Acked-by: Coly Li Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- drivers/md/bcache/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 20eddeac1531..62fb917f7a4f 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -270,7 +270,11 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_segment_all(bv, bio, i) { + /* + * This is called on freshly new bio, so it is safe to access the + * bvec table directly. + */ + for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++, i++) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) -- 2.9.5