Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966184AbcJ2IZt (ORCPT ); Sat, 29 Oct 2016 04:25:49 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36679 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941855AbcJ2IO0 (ORCPT ); Sat, 29 Oct 2016 04:14:26 -0400 From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , "Kirill A . Shutemov" , Ming Lei , Johannes Berg Subject: [PATCH 32/60] block: implement sp version of bvec iterator helpers Date: Sat, 29 Oct 2016 16:08:31 +0800 Message-Id: <1477728600-12938-33-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> References: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1828 Lines: 57 This patch implements singlepage version of the following 3 helpers: - bvec_iter_offset_sp() - bvec_iter_len_sp() - bvec_iter_page_sp() So that one multipage bvec can be splited to singlepage bvec, and make users of current bvec iterator happy. Signed-off-by: Ming Lei --- include/linux/bvec.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index da984fa171bc..12c53a0eee52 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -22,6 +22,7 @@ #include #include +#include /* * What is multipage bvecs(segment)? @@ -95,15 +96,25 @@ struct bvec_iter { #define bvec_iter_offset_mp(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) +#define bvec_iter_page_idx_mp(bvec, iter) \ + (bvec_iter_offset_mp((bvec), (iter)) / PAGE_SIZE) + /* * of sp segment. * * This helpers will be implemented for building sp bvec in flight. * */ -#define bvec_iter_offset_sp(bvec, iter) bvec_iter_offset_mp((bvec), (iter)) -#define bvec_iter_len_sp(bvec, iter) bvec_iter_len_mp((bvec), (iter)) -#define bvec_iter_page_sp(bvec, iter) bvec_iter_page_mp((bvec), (iter)) +#define bvec_iter_offset_sp(bvec, iter) \ + (bvec_iter_offset_mp((bvec), (iter)) % PAGE_SIZE) + +#define bvec_iter_len_sp(bvec, iter) \ + min_t(unsigned, bvec_iter_len_mp((bvec), (iter)), \ + (PAGE_SIZE - (bvec_iter_offset_sp((bvec), (iter))))) + +#define bvec_iter_page_sp(bvec, iter) \ + nth_page(bvec_iter_page_mp((bvec), (iter)), \ + bvec_iter_page_idx_mp((bvec), (iter))) /* current interfaces support sp style at default */ #define bvec_iter_page(bvec, iter) bvec_iter_page_sp((bvec), (iter)) -- 2.7.4