From patchwork Thu Feb 16 11:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9576959 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 6B3E7600C5 for ; Thu, 16 Feb 2017 11:51:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C4F22855B for ; Thu, 16 Feb 2017 11:51:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6156D285BB; Thu, 16 Feb 2017 11:51:38 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 17A282855B for ; Thu, 16 Feb 2017 11:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754771AbdBPLvW (ORCPT ); Thu, 16 Feb 2017 06:51:22 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34331 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754487AbdBPLqc (ORCPT ); Thu, 16 Feb 2017 06:46:32 -0500 Received: by mail-pg0-f65.google.com with SMTP id v184so1827455pgv.1; Thu, 16 Feb 2017 03:46:26 -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=L9Aqvft7/aCoIb44pwCdnskDptcguwfx3kGADTJTV0U=; b=gaJA53ARxv93CnX/JHJGV1djWxgBFjdvK2JhqdXeXjDA5e6J4tNmB8r/fIBSIRHDWq lRwypxfuz+uxa9gdMeK+Oome+seawzCghbQ5m6XDOv94zsbIDwsaoZUfE6myX34db1Sx si0cZ+BX3hiP8hq25LDdMWxzqurbYRhvK94cOryJMRyzUJG3ZN+JFXieE2nf4gNcZBvz yeyunIbXvhP1pnDOYHrt1pQkAM3UtsIb0UEm67RoFCZ3H57GP50idwt9GwHeX9vKZsLm 2rgQnKJd2hpyzBjvf6XIDIBdUZH4n1UHcPXHm/qSFhrsdjUv55MBvBDGsO9F7GR0acy1 aneQ== 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=L9Aqvft7/aCoIb44pwCdnskDptcguwfx3kGADTJTV0U=; b=SQmD9V4qSpTezrlnFgEUGEm7mu7v4cLGdHzbxjAMawBvyZYOg8SgtsoofAFGQTKg0q RCEW94JZwNY/pmdPCxWPS2qMlvLlTGLYHTwkckhhmBF2q5iDoTmSsM4nieV1n5LCW8rm WmyxP5tgxPKPyIrlX/tii5EyFCA2894JOBDN88CAnvekPqOwIwPIPxqsMOfyTK6B9xv+ 1a+zEZWDKFyxEfntL7ZPALZpX3Zkm42rm/uZ9nNEAyNSo8EM2tpltB/d65pa+oj4NMnI pCuD/fnE0Ngu7uNe+3cJ90FD9YpQT5U0ETpYQ+5SSdAdgfTJqf3PCHSgsIdZKk1G/Sn+ lETQ== X-Gm-Message-State: AMke39kv/2i/LzL8yklVLpUIP4Dn84mChPf8nFuyghcwfsnFxlsnR8gpF0mFOmAzkVNAPA== X-Received: by 10.98.86.203 with SMTP id h72mr2157905pfj.108.1487245581109; Thu, 16 Feb 2017 03:46:21 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id t14sm13274644pfk.85.2017.02.16.03.46.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:46:20 -0800 (PST) From: Ming Lei To: Shaohua Li , Jens Axboe , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig , NeilBrown Cc: Ming Lei Subject: [PATCH 04/17] md: introduce helpers for dealing with fetch/store preallocated pages in bio Date: Thu, 16 Feb 2017 19:45:34 +0800 Message-Id: <1487245547-24384-5-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487245547-24384-1-git-send-email-tom.leiming@gmail.com> References: <1487245547-24384-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 Both raid1 and raid10 uses bio's bvec table to store pre-allocated pages, then fetch and add it to bio. This patch introduces two helpers for dealing with the special case, like what bio_iov_iter_get_pages() does. Signed-off-by: Ming Lei --- drivers/md/md.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/md/md.h b/drivers/md/md.h index a86ad62079de..21897cb514af 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -708,4 +708,25 @@ static inline void mddev_clear_unsupported_flags(struct mddev *mddev, { mddev->flags &= ~unsupported_flags; } + +/* + * Both raid1 and raid10 use bio's bvec table to store the preallocated + * pages, so we introduces the following helpers for this kind of usage. + * + * Actually the usage is a bit similar with bio_iov_iter_get_pages(). + * + * Please make sure .bi_io_vec[idx] points to one unused vector by the + * bio. + */ +static inline struct page *mdev_get_page_from_bio(struct bio *bio, unsigned idx) +{ + return bio->bi_io_vec[idx].bv_page; +} + +static inline void mdev_put_page_to_bio(struct bio *bio, unsigned idx, + struct page *page) +{ + bio->bi_io_vec[idx].bv_page = page; +} + #endif /* _MD_MD_H */