From patchwork Fri May 25 03:46:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10426087 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 4369A602D6 for ; Fri, 25 May 2018 03:50:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32635294F9 for ; Fri, 25 May 2018 03:50:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25930295A4; Fri, 25 May 2018 03:50:07 +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 ACAEA294F9 for ; Fri, 25 May 2018 03:50:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEE596B02AC; Thu, 24 May 2018 23:50:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A75056B02AE; Thu, 24 May 2018 23:50:05 -0400 (EDT) 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 917356B02AF; Thu, 24 May 2018 23:50:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by kanga.kvack.org (Postfix) with ESMTP id 652CB6B02AC for ; Thu, 24 May 2018 23:50:05 -0400 (EDT) Received: by mail-qt0-f198.google.com with SMTP id g12-v6so2788837qtj.22 for ; Thu, 24 May 2018 20:50:05 -0700 (PDT) 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=lO8usbshcANMX9YtYPoIOLTZmPPvraKC7YlTKszn3Lc=; b=DOT+UAw9JaUd1I1M1yFt8W6ukkkcYW9TWSUGgOdMGBVg1oZ5nX5H1M223qdDNGd1Sf P/HibGd9QAuqsb6xXT9n+OEUJZjbJgBz0MSeipvdj5SNVuTbyvFi+CW9sqGxUjk4Vh1y 5aZECCGNCI49+aviJjVY8+zV//BFGKvztA+L5RiiQx9EwnoqFNHnIWCY7ZHn9vvp3usY soZ9umdrdw3Alq9uBJdWPn4Hych+TeCNf/fvQpgqq55AK95RIp9tmNw4qWQRzIffz5HI P/MPzwcVTDhNhg8UtR1+Xyu1Saqu54sU+8sF/tS4v4C/j5ESxZOq5sVCl9XjRlkthqJH cKQg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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: ALKqPwfI+/aTnXItdcSOeG598lhATbRJO0FrTj0Y534hzsyKyniTgsXt AvfVmTPfEfTwqgVCDmDHykVtGrpiNS64BII1FMDWOqyYMgfyECib1olhqn1WAm1PFR+/IiJeyPt sF4+2dWfz1x134C/Oyt+G2EdnlCrzw8RBwhQatkAccRv/sXG+O6CyphOSmnTF1+jaSg== X-Received: by 2002:ac8:161b:: with SMTP id p27-v6mr590145qtj.135.1527220205208; Thu, 24 May 2018 20:50:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzSOPuc0LbFi0LWCbU1ovX9t2WnJQpJ1fcwkrmUl5kZN4axDWap/elmxkb2XK9ZdbZdh5w X-Received: by 2002:ac8:161b:: with SMTP id p27-v6mr590123qtj.135.1527220204646; Thu, 24 May 2018 20:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527220204; cv=none; d=google.com; s=arc-20160816; b=RqLnwuDlAuRFWR+HftAzKPy3kn5WfCwaPRA0SbjiwtuNRrbyUmHc1Nqd7yf8YPLvMn aX8Dzvzkdkal7M4I2D5lChOl+7b2LDi/hD5YtrfHxYkpQ83YHts6M94IfqT1K3MM4UK0 s3n94CblLURyx0XydL8/0mO694+zlkbdHaxYf7mPl2hs7SAAqFLWr5lN3sT1w17wQZa3 XMEo5bIoht9DXoYY4bQPx3mGdko6y2e5vzHc0rhnpgN+G8ALzaPqOBG4s3GTj3rSH5NY DIM7jufyMVhf0SV/RpbvneLEXVgtVzbsCF3AGSW3pFhlWt7iuzVs+JRlECtt5dBQtoF0 f7Mw== 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 :arc-authentication-results; bh=lO8usbshcANMX9YtYPoIOLTZmPPvraKC7YlTKszn3Lc=; b=wre/apeTUUTOQAY1ifNKsGcG2z+wMV0fa1n0HP12HQPNXcTSWsk9vaPaiMzqFHWF8e Fm/v8xLyuN4+70y+/e9XSg/Hyyi7A1vHR8WIe5B2dsOZgO9vG54w956JtlMKiGfl/rkM 5Irz6UpynM8JqF/aG//t8sD8K8nIajPxljfOV1IqPgt+Reo8IRzReh5IrplWEjavNpEC DHmcSNbjtpcvGts4o0AFPNME/GH0rOsIc4wdm9Vsv32/lpZk3hjgULxlgdYpw6ELv75a GMFvoxU0A3Zo/4foT87WBirURAFFhMKKOn3fr23PXgZsrdzI+QbKcJ7mdl7bRB6qmCxf zU+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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 (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id e64-v6si2207805qtd.286.2018.05.24.20.50.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 20:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44A2F401EF03; Fri, 25 May 2018 03:50:04 +0000 (UTC) Received: from localhost (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C405202345C; Fri, 25 May 2018 03:49:56 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: David Sterba , Huang Ying , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Ming Lei Subject: [RESEND PATCH V5 17/33] block: bio: introduce bio_for_each_page_all2 and bio_for_each_segment_all Date: Fri, 25 May 2018 11:46:05 +0800 Message-Id: <20180525034621.31147-18-ming.lei@redhat.com> In-Reply-To: <20180525034621.31147-1-ming.lei@redhat.com> References: <20180525034621.31147-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 25 May 2018 03:50:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 25 May 2018 03:50:04 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' 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 This patch introduces bio_for_each_page_all2(), which is for replacing bio_for_each_page_all() in case that the returned bvec has to be single page bvec. Given the interface type has to be changed for passing one local iterator variable of 'bvec_iter_all', and doing all changes in one single patch isn't realistic, so use the name of bio_for_each_page_all2() temporarily for conversion, and once all bio_for_each_page_all() is converted, the original name of bio_for_each_page_all() will be recovered finally. This patch introduce bio_for_each_segment_all too, which is used for updating bvec table directly, and users should be carful about this helper since it returns real multipage segment now. Signed-off-by: Ming Lei --- include/linux/bio.h | 18 ++++++++++++++++++ include/linux/bvec.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 61a04c131641..75baad77d9a8 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -225,6 +225,24 @@ static inline bool bio_rewind_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_segment_all(bvl, bio, i) \ + bio_for_each_page_all((bvl), (bio), (i)) + +/* + * This helper returns singlepage bvec to caller, and the sp bvec is + * generated in-flight from multipage bvec stored in bvec table. So we + * can _not_ change the bvec stored in bio->bi_io_vec[] via this helper. + * + * If bvec need to be updated in the table, please use + * bio_for_each_segment_all() and make sure it is correctly used since + * bvec may points to one multipage bvec. + */ +#define bio_for_each_page_all2(bvl, bio, i, bi) \ + for ((bi).iter = BVEC_ITER_ALL_INIT, i = 0, bvl = &(bi).bv; \ + (bi).iter.bi_idx < (bio)->bi_vcnt && \ + (((bi).bv = bio_iter_iovec((bio), (bi).iter)), 1); \ + bio_advance_iter((bio), &(bi).iter, (bi).bv.bv_len), i++) + #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) static inline unsigned __bio_elements(struct bio *bio, bool seg) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 217afcd83a15..2deee87b823e 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -84,6 +84,12 @@ struct bvec_iter { current bvec */ }; +/* this iter is only for implementing bio_for_each_page_all2() */ +struct bvec_iter_all { + struct bvec_iter iter; + struct bio_vec bv; /* in-flight singlepage bvec */ +}; + /* * various member access, note that bio_data should of course not be used * on highmem page vectors