From patchwork Fri May 18 07:49:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 10408379 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 55E99601F9 for ; Fri, 18 May 2018 07:50:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E462886A for ; Fri, 18 May 2018 07:50:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C44128892; Fri, 18 May 2018 07:50: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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABE2B2886A for ; Fri, 18 May 2018 07:50:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBEDF6B058B; Fri, 18 May 2018 03:50:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C6E746B058D; Fri, 18 May 2018 03:50:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B83C86B058E; Fri, 18 May 2018 03:50:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f199.google.com (mail-qt0-f199.google.com [209.85.216.199]) by kanga.kvack.org (Postfix) with ESMTP id 8A4626B058B for ; Fri, 18 May 2018 03:50:05 -0400 (EDT) Received: by mail-qt0-f199.google.com with SMTP id t3-v6so6078980qto.14 for ; Fri, 18 May 2018 00:50:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ph0IRMnGMuiit3FXdyM+fA2rETPRLhjAUwHkoxZbT0o=; b=gomlhTYIB7suNc03zM1oviC28POz1k61gPK3HwqPyujzhQQ4QGH9dNWJTYU+t9wFms xE8mwoK6i5I0DtokOcrPFwsIGzlzowwLemojKc5pxJE22Zt1ZW0Fh6YWPVUspj6cQgCn JVJ0LjaJcA6reUsZYXI+NRveNjAfxb4Z+jnjSQJn2EgH/GxElKxqqz1uzFsdevlhin6i jROtDESZYvN/ETVOPwRHHd9l/kFKVft7iTLgYhm6S8b1sHUc1XitFuYH9airld/HAyus reuMtYCzXt081vrXfl+Sr1qRjad3QJh50msA98ohPhs1qd7ZQO7+pEsE6E7N5PdzGQe7 6sOQ== X-Gm-Message-State: ALKqPwenngp4tiojk7IuwlhGAAhteLSv+69eaoXKjwUJvB631X4wYni2 XbyT+YsMKR0gSLijtyamOdicjefXT/LFj/2O7rwqqp5Z4mV/O0lJl0sLH8wHuAE+++0qbe4PKC4 sUE896ZhZ7EPg5JmxMMIjOQCLt8HOjVM9vcU0hLgqz7Kw1FzDnDVhWOGiARycUfDBirBMrHwKCd l3yGCp8JH9JssKYIJCDUrm35CBDed954Sgps9mPskhGOseQAKsB2fmhiFiA3Qbcu3eQh2ClPaDC U37d17XNXh80TtWT3tBeW4X4sDd2jA4iufXdw45C/mbzJKbPi2YJ3z/ufmoWwEMS501U88MQw+b xkfE/Kz7kjMWgCRnk6u4H1Sem892iMsw5ZuEOKgN1yBmX3YYZzLh8Tb5pm5ivWLxAeVj+ZOwxy4 c X-Received: by 2002:aed:3e19:: with SMTP id l25-v6mr8154599qtf.143.1526629805371; Fri, 18 May 2018 00:50:05 -0700 (PDT) X-Received: by 2002:aed:3e19:: with SMTP id l25-v6mr8154589qtf.143.1526629804801; Fri, 18 May 2018 00:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526629804; cv=none; d=google.com; s=arc-20160816; b=u9qahSQeel9Oxg/IaFNFZPEFqznuTaxfi2qs1FdqJhB7xKjZKPsXq4DoWNrB3v4X+k 1/ykbMyndUfcBZqNYcJ3VBytj84wxGFTIlTEmVA7teLTERKsBMIKGsgljp7GdtBLT34G 9/snqKMEWrxWYEKaU//ytpaQImqk3h25JUTaihHfUHQfCuUwskuDRyb+omSXjnKrBBqp 1Z8e4s+fUKbi+d0oz+jtbwxP8JjW0/kO7M4HmXAOdspwTgivuhKgOlkYB+AYxI4tWziW uOIQJd6rIIBPUdbdw2dShp9HkOm49cgjn4ybGMnQvZnDoZqxNNk59G9qVF3Yn16Dp4CZ uhEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ph0IRMnGMuiit3FXdyM+fA2rETPRLhjAUwHkoxZbT0o=; b=s9YnlfpM4tTxU2aU88fAUA7jGXtHG1Exongj0ZMgId0r1B4NFGURFhvOAMG/7QF/PZ ixn2IpIkqNToiGGPexea1y2wWFXQPwVd5j/0uk3xuQPq3qp0E2lNWWy8j7ccApZbrNDw O95bv44+q9N+fTN1R6EkzpL5ojzcPk5ZNQqrLybYZrjbbkB1+WnNo0YEgKOY0fSP08+g TIhUdaVbdLsgV5gJ99/5+AQr+w0YNnKrl2uWwoDgQb12EemBPIj/Mnh2li3oniKItwIr yJK71/YOslEPUAjdadAObDWEXBvPyLguuIPFTNQtt292wqTFck42KTrlQZF9QlXMGRaM O76A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lz4JfSEC; spf=pass (google.com: domain of kent.overstreet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r47-v6sor5731708qtc.54.2018.05.18.00.50.04 for (Google Transport Security); Fri, 18 May 2018 00:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of kent.overstreet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lz4JfSEC; spf=pass (google.com: domain of kent.overstreet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=ph0IRMnGMuiit3FXdyM+fA2rETPRLhjAUwHkoxZbT0o=; b=lz4JfSECYVlK1YFGQb4h9AC9bSVMsl2ZiBkV4YG4HlD9r0yjCLbfPHtCHUf579EKvy mjrUFumPxitT9kE0sT4VX/B6hH8AmmQBZCgkY4IZtPvR06MUFf/TPMEKVNPH0FE730xO GIS9bV2bXR/h8rGzMsEwH4Yd/OHusPAzzI1FpQIgfrD34xQrL/RVDrcQpXbVfIT7RiUn Y0jNi8r6p+LrK9kTnu8Jz3d8qxUinXUp1uqcwjJ81Gcj0VdtGZeX8ry3koVwsC8ukLgK E5RBBxS0VG8DenyhmMYdhlP2IylbVR13Romn0yaTJ6bYOcN+0B8QILAuCUg0vO2ukDu5 7GCA== X-Google-Smtp-Source: AB8JxZrNZ6wwEs3bAl1tD7sY0G5kgrl992kkOvfRmfMYnLLAYCRitpWn0SIdPwUUYjAz4Rh1jXj5bw== X-Received: by 2002:ac8:3f58:: with SMTP id w24-v6mr8247554qtk.217.1526629804470; Fri, 18 May 2018 00:50:04 -0700 (PDT) Received: from localhost.localdomain (c-71-234-172-214.hsd1.vt.comcast.net. [71.234.172.214]) by smtp.gmail.com with ESMTPSA id s64-v6sm5443004qkl.85.2018.05.18.00.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 00:50:03 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, Jens Axboe , Ingo Molnar Cc: Kent Overstreet Subject: [PATCH 05/10] block: Add bio_copy_data_iter(), zero_fill_bio_iter() Date: Fri, 18 May 2018 03:49:07 -0400 Message-Id: <20180518074918.13816-10-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518074918.13816-1-kent.overstreet@gmail.com> References: <20180518074918.13816-1-kent.overstreet@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Add versions that take bvec_iter args instead of using bio->bi_iter - to be used by bcachefs. Signed-off-by: Kent Overstreet --- block/bio.c | 44 ++++++++++++++++++++++++-------------------- include/linux/bio.h | 18 +++++++++++++++--- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/block/bio.c b/block/bio.c index b7cdad6fc4..d7bd765e9e 100644 --- a/block/bio.c +++ b/block/bio.c @@ -530,20 +530,20 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs, } EXPORT_SYMBOL(bio_alloc_bioset); -void zero_fill_bio(struct bio *bio) +void zero_fill_bio_iter(struct bio *bio, struct bvec_iter start) { unsigned long flags; struct bio_vec bv; struct bvec_iter iter; - bio_for_each_segment(bv, bio, iter) { + __bio_for_each_segment(bv, bio, iter, start) { char *data = bvec_kmap_irq(&bv, &flags); memset(data, 0, bv.bv_len); flush_dcache_page(bv.bv_page); bvec_kunmap_irq(data, &flags); } } -EXPORT_SYMBOL(zero_fill_bio); +EXPORT_SYMBOL(zero_fill_bio_iter); /** * bio_put - release a reference to a bio @@ -971,28 +971,13 @@ void bio_advance(struct bio *bio, unsigned bytes) } EXPORT_SYMBOL(bio_advance); -/** - * bio_copy_data - copy contents of data buffers from one chain of bios to - * another - * @src: source bio list - * @dst: destination bio list - * - * If @src and @dst are single bios, bi_next must be NULL - otherwise, treats - * @src and @dst as linked lists of bios. - * - * Stops when it reaches the end of either @src or @dst - that is, copies - * min(src->bi_size, dst->bi_size) bytes (or the equivalent for lists of bios). - */ -void bio_copy_data(struct bio *dst, struct bio *src) +void bio_copy_data_iter(struct bio *dst, struct bvec_iter dst_iter, + struct bio *src, struct bvec_iter src_iter) { - struct bvec_iter src_iter, dst_iter; struct bio_vec src_bv, dst_bv; void *src_p, *dst_p; unsigned bytes; - src_iter = src->bi_iter; - dst_iter = dst->bi_iter; - while (1) { if (!src_iter.bi_size) { src = src->bi_next; @@ -1029,6 +1014,25 @@ void bio_copy_data(struct bio *dst, struct bio *src) bio_advance_iter(dst, &dst_iter, bytes); } } +EXPORT_SYMBOL(bio_copy_data_iter); + +/** + * bio_copy_data - copy contents of data buffers from one chain of bios to + * another + * @src: source bio list + * @dst: destination bio list + * + * If @src and @dst are single bios, bi_next must be NULL - otherwise, treats + * @src and @dst as linked lists of bios. + * + * Stops when it reaches the end of either @src or @dst - that is, copies + * min(src->bi_size, dst->bi_size) bytes (or the equivalent for lists of bios). + */ +void bio_copy_data(struct bio *dst, struct bio *src) +{ + bio_copy_data_iter(dst, dst->bi_iter, + src, src->bi_iter); +} EXPORT_SYMBOL(bio_copy_data); struct bio_map_data { diff --git a/include/linux/bio.h b/include/linux/bio.h index 91b02520e2..5a6ee955a8 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -67,8 +67,12 @@ #define bio_multiple_segments(bio) \ ((bio)->bi_iter.bi_size != bio_iovec(bio).bv_len) -#define bio_sectors(bio) ((bio)->bi_iter.bi_size >> 9) -#define bio_end_sector(bio) ((bio)->bi_iter.bi_sector + bio_sectors((bio))) + +#define bvec_iter_sectors(iter) ((iter).bi_size >> 9) +#define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors((iter))) + +#define bio_sectors(bio) bvec_iter_sectors((bio)->bi_iter) +#define bio_end_sector(bio) bvec_iter_end_sector((bio)->bi_iter) /* * Return the data direction, READ or WRITE. @@ -501,6 +505,8 @@ static inline void bio_flush_dcache_pages(struct bio *bi) } #endif +extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter dst_iter, + struct bio *src, struct bvec_iter src_iter); extern void bio_copy_data(struct bio *dst, struct bio *src); extern void bio_free_pages(struct bio *bio); @@ -509,7 +515,13 @@ extern struct bio *bio_copy_user_iov(struct request_queue *, struct iov_iter *, gfp_t); extern int bio_uncopy_user(struct bio *); -void zero_fill_bio(struct bio *bio); +void zero_fill_bio_iter(struct bio *bio, struct bvec_iter iter); + +static inline void zero_fill_bio(struct bio *bio) +{ + zero_fill_bio_iter(bio, bio->bi_iter); +} + extern struct bio_vec *bvec_alloc(gfp_t, int, unsigned long *, mempool_t *); extern void bvec_free(mempool_t *, struct bio_vec *, unsigned int); extern unsigned int bvec_nr_vecs(unsigned short idx);