From patchwork Mon Jan 21 08:17:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E723013B4 for ; Mon, 21 Jan 2019 08:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D84F329EB6 for ; Mon, 21 Jan 2019 08:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB9DF29EB8; Mon, 21 Jan 2019 08:19:57 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 654DC29EB6 for ; Mon, 21 Jan 2019 08:19:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D0D58E002F; Mon, 21 Jan 2019 03:19:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9583F8E0025; Mon, 21 Jan 2019 03:19:56 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81F5A8E002F; Mon, 21 Jan 2019 03:19:56 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 577288E0025 for ; Mon, 21 Jan 2019 03:19:56 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id w19so20356648qto.13 for ; Mon, 21 Jan 2019 00:19:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=8AAv6xLmlnhHy6lrFmcykh11uSuIfhKUAirhS6/Y8Bg=; b=SiviUseoPqa7DVbu4Y7pp56wtNCv5d3IFvs8Uy+bcYed5c8XqtZokV0sWav/SziDek YFqzt1WgAYtCO0FiCzube1JzGLJ08YaII8RpBu9jW3meMmvP02Ixdwir/lzMxtF3HiWf foTvTcG6pQE+9ejE49q1tXLT7pYt4pzIUXDTmvKId3w00jv/hC1tD4g1OTAoQUKJap8j JeXX5kgV+bmq6z3UBW+eB073fp1rD1MTJ0Y2CqhM+S6gYC5WvVycYNaRFvtsl6CElLGW /4+AYdAuGsYOkP23AQnmtC0PHkeNVkgo6MhGHdXJbRZrGZZrMYJvARonvYocVagplIHP u9+Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukeu7w+U9tVJMCjukJ4OkB3jHMIf9eO1XY8e4bRCdBHLZ6oVGJFw 4ikR/zv8FAd+gHgm8viMmx+kiFDij8N75orT6vSmndNBa2fPKeHQH0IFX09jBA4lZjZGEWAP13k F6j7dt+KllZ95G7GTiwKf+IipNzL4oJUsIwgSm8i4V+BU5SPe0Ea+byv70ljv8+SohA== X-Received: by 2002:a0c:884d:: with SMTP id 13mr25034616qvm.170.1548058796129; Mon, 21 Jan 2019 00:19:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6DmH06gA97h5XUoUiISVCRIIQfc+EeRuoT0CsLl2pzeYGNfdFm5QQDU55tajZmhxqOysmw X-Received: by 2002:a0c:884d:: with SMTP id 13mr25034601qvm.170.1548058795622; Mon, 21 Jan 2019 00:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058795; cv=none; d=google.com; s=arc-20160816; b=CNyHpSkAZ1vrofIQqPaQcpSIDc0q41FIQcxJ/RaSUMTI+mmsiBHkmxCXnxyba6jTOc cZMVFXa7DvxdLU0ce/vWq1vEUP14+lcBax6pAtoP/0N3QixNUDtPMJ8Um1keRR2FdzBf xs0VYa6Pe2sXgeoB2qiISig0PgWv4FXKWQsQgLjnQSWPH9/3V6OSDQRaYtgVqhgZXKtP 4FV/xcPlc/4j+xYP69fS0S+mcJ68cnik9R+3JI01Ny1WVKzxpuwq/b9i9caQqavfDYSk r8GaEzJ/rMyoB/OmtY3YcImHpKS7uyLbdjUcAPB1vYsrbny1vTY5TtPVFU50clDd78aA HrDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=8AAv6xLmlnhHy6lrFmcykh11uSuIfhKUAirhS6/Y8Bg=; b=CtfQklvt+/IuB3xbag9wQrw8+NhcAIrjWtXWzg99B4ryXgTZGGmEw/sigQZGw71RjV 3+aWtYpOKqmM+F6hRheDG1yvZ1R4MMrXZN/nLmaftDGq80U5jI/Sq89P+XLYaI5BXsYX zbSxZmHWuRDjhDpqTk81ta81AJDz1ZvCcVasHyH2EJMa0DkDYIgb+wQjwOpJvudY9NB8 a5/OdRknBQeArdxkAN30gVSc/ezzkaym7GYhTCy0Y3c+kYdrf1wF0zFkZzToNcwnzTZQ mA0/2CSyEC6+LvOh2YintVtbBQNqdl8I6MrhOqvaPvHXJ95fjLBN0YY6AlVQz+SwQy+y 0TXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f21si7252828qve.138.2019.01.21.00.19.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:19:55 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30609811D3; Mon, 21 Jan 2019 08:19:54 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C30935D737; Mon, 21 Jan 2019 08:19:36 +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 V14 05/18] block: introduce bio_for_each_mp_bvec() and rq_for_each_mp_bvec() Date: Mon, 21 Jan 2019 16:17:52 +0800 Message-Id: <20190121081805.32727-6-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 21 Jan 2019 08:19:54 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP bio_for_each_mp_bvec() is used for iterating over multi-page bvec for bio split & merge code. rq_for_each_mp_bvec() can be used for drivers which may handle the multi-page bvec directly, so far loop is one perfect use case. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- include/linux/bio.h | 10 ++++++++++ include/linux/blkdev.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 72b4f7be2106..730288145568 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -156,6 +156,16 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, #define bio_for_each_segment(bvl, bio, iter) \ __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter) +#define __bio_for_each_mp_bvec(bvl, bio, iter, start) \ + for (iter = (start); \ + (iter).bi_size && \ + ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, (iter))), 1); \ + bio_advance_iter((bio), &(iter), (bvl).bv_len)) + +/* iterate over multi-page bvec */ +#define bio_for_each_mp_bvec(bvl, bio, iter) \ + __bio_for_each_mp_bvec(bvl, bio, iter, (bio)->bi_iter) + #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) static inline unsigned bio_segments(struct bio *bio) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 338604dff7d0..6ebae3ee8f44 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -797,6 +797,10 @@ struct req_iterator { __rq_for_each_bio(_iter.bio, _rq) \ bio_for_each_segment(bvl, _iter.bio, _iter.iter) +#define rq_for_each_mp_bvec(bvl, _rq, _iter) \ + __rq_for_each_bio(_iter.bio, _rq) \ + bio_for_each_mp_bvec(bvl, _iter.bio, _iter.iter) + #define rq_iter_last(bvec, _iter) \ (_iter.bio->bi_next == NULL && \ bio_iter_last(bvec, _iter.iter))