From patchwork Tue Dec 27 15:56:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489523 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 50E9462AB6 for ; Tue, 27 Dec 2016 16:08:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43F1E200E7 for ; Tue, 27 Dec 2016 16:08:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38D6A201BC; Tue, 27 Dec 2016 16:08:48 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 DD8E4223B2 for ; Tue, 27 Dec 2016 16:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933124AbcL0QIW (ORCPT ); Tue, 27 Dec 2016 11:08:22 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35399 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933171AbcL0QIP (ORCPT ); Tue, 27 Dec 2016 11:08:15 -0500 Received: by mail-pg0-f68.google.com with SMTP id i5so12806769pgh.2; Tue, 27 Dec 2016 08:08:14 -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=GsGqNNkyZc9bZnXlJuBAJclT03hC8hKbQioBOWsrFwE=; b=B1SjPI3s0V4zJWb4GuquH+yh37Ii5113z/CFUapJNVx7SP9DbeA8zyLUkfzJNV59u5 +ZyC1UNV95iagP6TrS4ehoZ4x/f24xF+ItGrhk/xXEiq999yytvu+wuKs8LEXiYrA5G7 aq+axQW7vHMvGEJl+iwFnkG/N2cR5K3L1K5E90XVo03OzWX1Rl1b5DwDRg6nFCnRhzy+ 8R2Yft9Q0jMRKvi6pZpW5hwIroBdF3xC2G/xNcLXXIG7gfsKWSu2OVlWvl8Z/7QN4Tsk GLSU1RkXPuaFfh+QESnFQWifCN+9udBEaiv2sCmxKOWoD7HmXNmUKExxN+mq4ox9i6eD LySw== 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=GsGqNNkyZc9bZnXlJuBAJclT03hC8hKbQioBOWsrFwE=; b=GGj0cFuXkJpMIr7rTqHJxB0WY48SauJs3byvUwbOxxKTCCZ9hs2qCGq/OffxlG1pPU kTZHUha4R66vK8pRBfi9FtZBH4LRNdauKJbXd9NoSbW7fHHCpERTg1fmUss0mrJmmFYm GIvubuJlt/Zr+ZxuudFBpL4uW2GCKoZaL/pIokGjDztNCh553VRPaB12+KWhTrZAwfcz CxL23HfhvICQrlCqpBQDMxS93UrfvxH5JCfD99q8pc5m4Df0dSn01y+zQPu4ej60AVvp l/8D78mJxL7OZR883KDgeUhLZ6mCTpxEhtg/Tz9YbbrE/8B8hI1Mu8+k3VlbhCDK5mVs kaAw== X-Gm-Message-State: AIkVDXIHAODGhEo3elPbt7D1KJfFPcgqKsUub1CJ+mLdtPnBoF2gRmf44bemTFPSggxYdw== X-Received: by 10.84.232.141 with SMTP id i13mr25231624plk.73.1482854407199; Tue, 27 Dec 2016 08:00:07 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id s5sm91424667pgj.19.2016.12.27.08.00.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:00:06 -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 15/54] block: implement sp version of bvec iterator helpers Date: Tue, 27 Dec 2016 23:56:04 +0800 Message-Id: <1482854250-13481-16-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 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 307a387eb29c..d77c3cabce8c 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -22,6 +22,7 @@ #include #include +#include /* * What is multipage bvecs(segment)? @@ -95,14 +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 singlepage(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))