From patchwork Tue Dec 27 15:56:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489559 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 D7E9862AB6 for ; Tue, 27 Dec 2016 16:10:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA74F200E7 for ; Tue, 27 Dec 2016 16:10:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF1CE201BC; Tue, 27 Dec 2016 16:10:53 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72D0825D99 for ; Tue, 27 Dec 2016 16:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933161AbcL0QKt (ORCPT ); Tue, 27 Dec 2016 11:10:49 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36259 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933143AbcL0QKF (ORCPT ); Tue, 27 Dec 2016 11:10:05 -0500 Received: by mail-pg0-f65.google.com with SMTP id n5so12818495pgh.3; Tue, 27 Dec 2016 08:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1rvNZOCQPGINuLcJfO3AYVP4hd+1VXGvEYnrbFXg1iM=; b=uECR4HdOlLnOQVE8dPMl3IFjt+vyDZVCf3xSfoYVRRwrxNv0pKAwKZwxcMQJnjFaCN pXsyHsPBwsb1ItstL9SeaXC5gGRRR62wlBuul62uwlI4x60/u+r3IiCftYOD0/ptrvL6 jxFzYVQBGehx9LsLV/12HtOeu6GwQxWhoeruebEXPeeq06SriIbczQpOnqstrCwiiG/9 PqpWPYaad9GisWC/0zWJC2mnSjBxPWbUaK/PAIcooJC5VugIKDAfUjhoJDIkG9ITiF/i /Z72LiB4C6Oec8zUxxnlrtvVAmIVIj24ldl+4u/BQJkqTr2/OxYwRPS885naJg6IDu9c kJMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1rvNZOCQPGINuLcJfO3AYVP4hd+1VXGvEYnrbFXg1iM=; b=knozLpNH9UTEbUa+BpYhnQ2IfIm6vT75sSpedVAJ9n0LunwpwJBEsVfj9Mhx3p/sAn UVBUcAJd7NEmehjt9iI4SvMSUlAF873lVxKK1LaLxMG/jXl7Drf2SHbaKNILsC3aosZN 0mMojyq7YNEC2xq2s79k60a8kFL3nfb10StIJ7G+4oZdZn+znFkjtw98ItQB5KITahku Iz7+CJUxRIUlW2QpwR0XlByKUIe+mLNwsdFi/34ceH2W+VGsSOgnbN5MvR/HfWQJ3rov hPVEIMS7eypVUtmWgGuZypBTwpJobxlfJknO0h6fPyxiGy0Xf+dzJbh5eYDEjSU3gAWn ydNQ== X-Gm-Message-State: AIkVDXKx1m9ekZVD9TPit4w7mVIVv2+ZAsKN/xUQtI3NrksrD8L2qEIYoc/JJEdBFgW+aA== X-Received: by 10.99.105.70 with SMTP id e67mr58365028pgc.99.1482854503343; Tue, 27 Dec 2016 08:01:43 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id x4sm91372547pgc.14.2016.12.27.08.01.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:01:42 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Ming Lei , Johannes Berg Subject: [PATCH v1 29/54] block: introduce bvec_for_each_sp_bvec() Date: Tue, 27 Dec 2016 23:56:18 +0800 Message-Id: <1482854250-13481-30-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482854250-13481-1-git-send-email-tom.leiming@gmail.com> References: <1482854250-13481-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-Virus-Scanned: ClamAV using ClamSMTP This helper can be used to iterate each singlepage bvec from one multipage bvec. Signed-off-by: Ming Lei --- include/linux/bvec.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 5c51c58fe202..baf379d56106 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -192,4 +192,18 @@ static inline void bvec_iter_advance_mp(const struct bio_vec *bv, .bi_bvec_done = 0, \ } +/* + * This helper iterates over the multipage bvec of @mp_bvec and + * returns each singlepage bvec via @sp_bvl. + */ +#define __bvec_for_each_sp_bvec(sp_bvl, mp_bvec, iter, start) \ + for (iter = start, \ + (iter).bi_size = (mp_bvec)->bv_len; \ + (iter).bi_size && \ + ((sp_bvl = bvec_iter_bvec((mp_bvec), (iter))), 1); \ + bvec_iter_advance((mp_bvec), &(iter), (sp_bvl).bv_len)) + +#define bvec_for_each_sp_bvec(sp_bvl, mp_bvec, iter) \ + __bvec_for_each_sp_bvec(sp_bvl, mp_bvec, iter, BVEC_ITER_ALL_INIT) + #endif /* __LINUX_BVEC_ITER_H */