From: Brian Foster <bfoster@redhat.com>
To: linux-bcachefs@vger.kernel.org, linux-xfs@vger.kernel.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Subject: [PATCH RFC 2/3] iomap: add nosubmit flag to skip data I/O on iomap mapping
Date: Wed, 10 Apr 2024 10:09:55 -0400 [thread overview]
Message-ID: <20240410140956.1186563-3-bfoster@redhat.com> (raw)
In-Reply-To: <20240410140956.1186563-1-bfoster@redhat.com>
Define a nosubmit flag to skip data I/O submission on a specified
mapping. The iomap layer still performs every step up through
constructing the bio as if it will be submitted, but instead invokes
completion on the bio directly from submit context. The purpose of
this is to facilitate filesystem metadata performance testing
without the overhead of actual data I/O.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/iomap/buffered-io.c | 21 +++++++++++++--------
include/linux/iomap.h | 1 +
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index b6d176027887..5d1c443a6fb4 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -46,11 +46,16 @@ static struct bio_set iomap_ioend_bioset;
/*
* Simple submit_bio() wrapper. Set ->bi_status to trigger error completion.
*/
-static inline int iomap_submit_bio(struct bio *bio, bool wait)
+static inline int iomap_submit_bio(const struct iomap *iomap, struct bio *bio,
+ bool wait)
{
- int ret = 0;
+ int ret = 0;
+ bool nosubmit = iomap->flags & IOMAP_F_NOSUBMIT;
+
+ if (nosubmit)
+ zero_fill_bio_iter(bio, bio->bi_iter);
- if (bio->bi_status)
+ if (bio->bi_status || nosubmit)
bio_endio(bio);
else if (wait)
ret = submit_bio_wait(bio);
@@ -428,7 +433,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
unsigned int nr_vecs = DIV_ROUND_UP(length, PAGE_SIZE);
if (ctx->bio)
- iomap_submit_bio(ctx->bio, false);
+ iomap_submit_bio(iomap, ctx->bio, false);
if (ctx->rac) /* same as readahead_gfp_mask */
gfp |= __GFP_NORETRY | __GFP_NOWARN;
@@ -481,7 +486,7 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops)
folio_set_error(folio);
if (ctx.bio) {
- iomap_submit_bio(ctx.bio, false);
+ iomap_submit_bio(&iter.iomap, ctx.bio, false);
WARN_ON_ONCE(!ctx.cur_folio_in_bio);
} else {
WARN_ON_ONCE(ctx.cur_folio_in_bio);
@@ -554,7 +559,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops)
iter.processed = iomap_readahead_iter(&iter, &ctx);
if (ctx.bio)
- iomap_submit_bio(ctx.bio, false);
+ iomap_submit_bio(&iter.iomap, ctx.bio, false);
if (ctx.cur_folio) {
if (!ctx.cur_folio_in_bio)
folio_unlock(ctx.cur_folio);
@@ -682,7 +687,7 @@ static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
bio_init(&bio, iomap->bdev, &bvec, 1, REQ_OP_READ);
bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
bio_add_folio_nofail(&bio, folio, plen, poff);
- return iomap_submit_bio(&bio, true);
+ return iomap_submit_bio(iomap, &bio, true);
}
static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
@@ -1686,7 +1691,7 @@ static int iomap_submit_ioend(struct iomap_writepage_ctx *wpc, int error)
if (error)
wpc->ioend->io_bio.bi_status = errno_to_blk_status(error);
- iomap_submit_bio(&wpc->ioend->io_bio, false);
+ iomap_submit_bio(&wpc->iomap, &wpc->ioend->io_bio, false);
wpc->ioend = NULL;
return error;
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 6fc1c858013d..8d34ec240e12 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -64,6 +64,7 @@ struct vm_fault;
#define IOMAP_F_BUFFER_HEAD 0
#endif /* CONFIG_BUFFER_HEAD */
#define IOMAP_F_XATTR (1U << 5)
+#define IOMAP_F_NOSUBMIT (1U << 6)
/*
* Flags set by the core iomap code during operations:
--
2.44.0
next prev parent reply other threads:[~2024-04-10 14:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 14:09 [PATCH RFC 0/3] xfs: nodataio mount option to skip data I/O Brian Foster
2024-04-10 14:09 ` [PATCH RFC 1/3] iomap: factor out a bio submission helper Brian Foster
2024-04-10 14:09 ` Brian Foster [this message]
2024-04-10 14:09 ` [PATCH RFC 3/3] xfs: add nodataio mount option to skip all data I/O Brian Foster
2024-04-10 16:17 ` [PATCH RFC 0/3] xfs: nodataio mount option to skip " Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240410140956.1186563-3-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox