From patchwork Sat Oct 29 08:08:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403367 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 6243760587 for ; Sat, 29 Oct 2016 08:26:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EEA12A60D for ; Sat, 29 Oct 2016 08:26:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 431D22A623; Sat, 29 Oct 2016 08:26:08 +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 EA1F02A60D for ; Sat, 29 Oct 2016 08:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965481AbcJ2IZs (ORCPT ); Sat, 29 Oct 2016 04:25:48 -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 Received: by mail-pf0-f196.google.com with SMTP id n85so3388108pfi.3; Sat, 29 Oct 2016 01:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YPwIAeXX/XWBx13mCzv6nduoxb8GRgsSaEdl8HmuxUQ=; b=AbYMXQ8hefJSGYDlT9PHwErg0W5kcfaICSRNpMKn/WdBhmpSAI1mSgZPcly1Ed15j0 bys9Gwgsir4s8GNnX0/E/EhU3N/b9rlvTs9lww0eyKa6sBQM/pg7ShgAmzkD0BN5Dsh3 yV9MSoUgIMbKy9JXw/rxVLE5xBPN6kj1JrZjOexn80UdzxA15tdpaFKdLZFuU/TwZSm9 bIHHSm3v+ee66iKQfZ8KCjRVAsdeS0KKdjrRBLkH5Oq/nvnhB5ZG4PyX91dHh0riE3Mx LjxBh1SRHx/20qV1HFfwpokWWsDx5psOYA4WH9ffs7tJGN5vjpJexk7pEvjce4nixz9U f8tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YPwIAeXX/XWBx13mCzv6nduoxb8GRgsSaEdl8HmuxUQ=; b=M//lp+WiD+SsVnCafk+uf4TIDrVbi3fVxKji1juU6HoJDANNzssZWD8IaFHlwfqC4c pQrPXDTUnpS715nMKX+8THtEj2ZOj+XBPKFWxaD1/LjQkxAqTU0kUWpXxiGVuvfMSh2o NGgftEaUtx1Cgccmpc1pVpmRHw+rH3O0hW6ddTHPEDVCvIIz98TN+XrrtTpHsFBuJ2ND Q1+VrXZY1DoN6loL6A308yWnUuN6T8KlOErv/0EkYncenDdr+Ysvc/7HAwcZhMbl2uTI zX5kOeGuUTL8novSBxgRR65clw1uvmitiMKwZM9WN7q9MjUtgxUE00teiJgjsbFw3iiI cGbA== X-Gm-Message-State: ABUngve8cORk/rNCxRL8I4ndReJBgBFqHsxiTlKJ02YbqwJu1i20WIoA5w5qehul3c4SnQ== X-Received: by 10.99.110.201 with SMTP id j192mr26329168pgc.133.1477728865413; Sat, 29 Oct 2016 01:14:25 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id y2sm18249370pff.82.2016.10.29.01.14.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:14:24 -0700 (PDT) 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-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 | 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))