From patchwork Mon Jun 26 12:10:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9809281 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 41F17603F3 for ; Mon, 26 Jun 2017 12:17:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49E1528585 for ; Mon, 26 Jun 2017 12:17:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E2DA28583; Mon, 26 Jun 2017 12:17:52 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 EC7BA28582 for ; Mon, 26 Jun 2017 12:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752432AbdFZMRp (ORCPT ); Mon, 26 Jun 2017 08:17:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51049 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751461AbdFZMRm (ORCPT ); Mon, 26 Jun 2017 08:17:42 -0400 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 A3CC480472; Mon, 26 Jun 2017 12:17:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3CC480472 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ming.lei@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A3CC480472 Received: from localhost (ovpn-12-86.pek2.redhat.com [10.72.12.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76B097E0F7; Mon, 26 Jun 2017 12:17:26 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Huang Ying , Andrew Morton , Alexander Viro Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Ming Lei Subject: [PATCH v2 28/51] block: introduce bvec_for_each_sp_bvec() Date: Mon, 26 Jun 2017 20:10:11 +0800 Message-Id: <20170626121034.3051-29-ming.lei@redhat.com> In-Reply-To: <20170626121034.3051-1-ming.lei@redhat.com> References: <20170626121034.3051-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.28]); Mon, 26 Jun 2017 12:17:36 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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..7addceea9828 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_bvec_done; \ + (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 */