Received: by 10.192.165.148 with SMTP id m20csp4961131imm; Tue, 8 May 2018 18:37:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrpVH+BkRaUIgmccEgfA5ULtcJ0xXEhWzaA/Gtxff+0zpudM2RxtaHqAj8Sbyfpo9H7Cj6L X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr17585671plp.367.1525829831759; Tue, 08 May 2018 18:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525829831; cv=none; d=google.com; s=arc-20160816; b=Lq/vsWjdXKyk6HqsYqYJ5SoVtfk5KWEyxnq9HMr7gduMXNRxFHLz/xR4UB7yZI0agN cK1gSPzovGo04S8rhkwlx1jgT14fOvGAwCKJaee9HJRiw+hnFSC+wvUob3Raw2lLmTw4 NDKXu5232BCcvjSdwrclELEW6vWZwFOz4FdrmjRSmVmKyzHM+DXpHOSD7nn72nUN7tc/ LA6eto8wLqn+R9DLjv07Oh9/Vg2uOO3TMVdNySjBJ7kDAyF/kpdaFiShQGb/tVPJcSA3 4sD6oM/0aYjaAzaNlJTcULI2GjqFyRSXfhvEvpAN5txQnFXzsFT9Irkfl5YIi3vvSeoh U/hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ph0IRMnGMuiit3FXdyM+fA2rETPRLhjAUwHkoxZbT0o=; b=JhtLJ0pDwp4U1/Ns7jcBnGjGuOTtkxS6R4ICHhzUYyN21v6oTlmJk08N6g5Ciug9el VRhRdHs5aEmQ+vst0i4YGTsOHbrD01d7HaRKyQk8+aZO1ZOwfObT2De+Ic1zCSuTTEVV ySutl+IG1/nE7dyxRkrX18l9bS+RkSKIeR3kYff3tDdIFouB86cZ8+Fkidby5x5Ds/6w IdxMIjhduW1K8H6NzTMMY2e43fvhKjKvkr1vqGqxY3QzOKy3DrEOHmRVrZjMvFsv/qpI mJG8T0cROOVdxZT/UrVPBTMCXELHu3GSDwGytShDZCmclev8X3dhy3zYaHZud3FJsGAy UnXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cohECXoX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12-v6si25005614pld.367.2018.05.08.18.36.57; Tue, 08 May 2018 18:37:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cohECXoX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933664AbeEIBgK (ORCPT + 99 others); Tue, 8 May 2018 21:36:10 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:43342 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933499AbeEIBeY (ORCPT ); Tue, 8 May 2018 21:34:24 -0400 Received: by mail-qt0-f195.google.com with SMTP id f13-v6so33911434qtp.10; Tue, 08 May 2018 18:34:23 -0700 (PDT) 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=cohECXoXmnN48RxSmvAFCdZCbTvEslyq+6LITicMvj5kmwshTv5UETNzLWS02TMGCi tKy9GePFZkT64x/oRB47xjlXg7j2cc/pmcHwaa9xwXr8q9nCn4tI1cLM1kGs+Jd8m4pQ 3+x/rdyK7w/L2qm9TABLhA4I2rdjMoF+C8y1rZ+qrpzGTIAwNG+qio+y2tjAssnJuCTd i5hJhR7mm3p+wlrQcLVPGnSwWBWP4LSlCTaLO32XOSAfiwK9ahAepd5y9nxuEa+njk2j mXc6IuRbRHKYE6Vy/isFmaXELUArbrzHjhdoPn9E0qGB+Vx6O4VmnuT07DZYHDmze9nt 6bcw== 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=ph0IRMnGMuiit3FXdyM+fA2rETPRLhjAUwHkoxZbT0o=; b=YEyFoY93s5fy8TiYnAFjobfWBABZaP9GnLAMfswZndMGsQ/z7RFs4BzEQ/iWMeID7R wAzpROZEO4ZzVcTVMPdolh5xEmFexfB5bN+IZqPK66Db81CSSQKSHtaOWckV91m+hRYL EzLTug0NvS4mewzw5sABgCiIvf3WER/1vxZo4w0VYf9eH7vMGLC41+beAUuJ+z+aApfd RnlPyDa+oaLvXkDDoDwFnYakHseHI8ErCQ7HKvFJLeQntF05gJpcg6HWVpo0KlHEhouF hp+FlFrcvUIAF3M89pRxCirIVJq8L/7ZpxRB9AJDrAnkyJwD/rgIid0Z2AgCyYFfGVHY 69Bg== X-Gm-Message-State: ALQs6tBQQeKfPU/yh1GAIZUVKXK+gllnjnYKIT+LwjJCjFGLgUIaz/1p rzo841U/F52yLcR+STBeO6XqZTBE2g== X-Received: by 2002:ac8:4611:: with SMTP id p17-v6mr37659037qtn.320.1525829662832; Tue, 08 May 2018 18:34:22 -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 x28-v6sm23719003qtx.95.2018.05.08.18.34.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 18:34:21 -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: Tue, 8 May 2018 21:33:53 -0400 Message-Id: <20180509013358.16399-6-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509013358.16399-1-kent.overstreet@gmail.com> References: <20180509013358.16399-1-kent.overstreet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.17.0