From: Christoph Hellwig <hch@lst.de>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: "Darrick J . Wong" <darrick.wong@oracle.com>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
cluster-devel@redhat.com
Subject: [PATCH 02/15] FOLD: iomap: make ->submit_ioend optional
Date: Mon, 1 Jul 2019 23:54:26 +0200 [thread overview]
Message-ID: <20190701215439.19162-3-hch@lst.de> (raw)
In-Reply-To: <20190701215439.19162-1-hch@lst.de>
Provide a default end_io handler that comple file systems can override
if they need deferred action. With that we don't need an submit_ioend
method for simple file systems.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/iomap.c | 26 +++++++++++++++++++++-----
fs/xfs/xfs_aops.c | 23 ++++++++++-------------
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/fs/iomap.c b/fs/iomap.c
index ebfff663b2a9..7574f63939cc 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -2350,6 +2350,13 @@ iomap_sort_ioends(struct list_head *ioend_list)
}
EXPORT_SYMBOL_GPL(iomap_sort_ioends);
+static void iomap_writepage_end_bio(struct bio *bio)
+{
+ struct iomap_ioend *ioend = bio->bi_private;
+
+ iomap_finish_ioend(ioend, blk_status_to_errno(bio->bi_status));
+}
+
/*
* Submit the bio for an ioend. We are passed an ioend with a bio attached to
* it, and we submit that bio. The ioend may be used for multiple bio
@@ -2368,14 +2375,23 @@ static int
iomap_submit_ioend(struct iomap_writepage_ctx *wpc, struct iomap_ioend *ioend,
int error)
{
+ ioend->io_bio->bi_private = ioend;
+ ioend->io_bio->bi_end_io = iomap_writepage_end_bio;
+
/*
- * If we are failing the IO now, just mark the ioend with an error and
- * finish it. This will run IO completion immediately as there is only
- * one reference to the ioend at this point in time.
+ * File systems can perform actions at submit time and/or override
+ * the end_io handler here for complex operations like copy on write
+ * extent manipulation or unwritten extent conversions.
*/
- ioend->io_bio->bi_private = ioend;
- error = wpc->ops->submit_ioend(ioend, error);
+ if (wpc->ops->submit_ioend)
+ error = wpc->ops->submit_ioend(ioend, error);
if (error) {
+ /*
+ * If we are failing the IO now, just mark the ioend with an
+ * error and finish it. This will run IO completion immediately
+ * as there is only one reference to the ioend at this point in
+ * time.
+ */
ioend->io_bio->bi_status = errno_to_blk_status(error);
bio_endio(ioend->io_bio);
return error;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 0821312a1d11..ac1404bc583c 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -265,20 +265,14 @@ xfs_end_bio(
{
struct iomap_ioend *ioend = bio->bi_private;
struct xfs_inode *ip = XFS_I(ioend->io_inode);
- struct xfs_mount *mp = ip->i_mount;
unsigned long flags;
- if ((ioend->io_flags & IOMAP_F_SHARED) ||
- ioend->io_type == IOMAP_UNWRITTEN ||
- ioend->io_private) {
- spin_lock_irqsave(&ip->i_ioend_lock, flags);
- if (list_empty(&ip->i_ioend_list))
- WARN_ON_ONCE(!queue_work(mp->m_unwritten_workqueue,
- &ip->i_ioend_work));
- list_add_tail(&ioend->io_list, &ip->i_ioend_list);
- spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
- } else
- iomap_finish_ioend(ioend, blk_status_to_errno(bio->bi_status));
+ spin_lock_irqsave(&ip->i_ioend_lock, flags);
+ if (list_empty(&ip->i_ioend_list))
+ WARN_ON_ONCE(!queue_work(ip->i_mount->m_unwritten_workqueue,
+ &ip->i_ioend_work));
+ list_add_tail(&ioend->io_list, &ip->i_ioend_list);
+ spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
}
/*
@@ -531,7 +525,10 @@ xfs_submit_ioend(
memalloc_nofs_restore(nofs_flag);
- ioend->io_bio->bi_end_io = xfs_end_bio;
+ if ((ioend->io_flags & IOMAP_F_SHARED) ||
+ ioend->io_type == IOMAP_UNWRITTEN ||
+ ioend->io_private)
+ ioend->io_bio->bi_end_io = xfs_end_bio;
return status;
}
--
2.20.1
next prev parent reply other threads:[~2019-07-01 21:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 21:54 RFC: use the iomap writepage path in gfs2 Christoph Hellwig
2019-07-01 21:54 ` [PATCH 01/15] FOLD: iomap: make the discard_page method optional Christoph Hellwig
2019-07-01 21:54 ` Christoph Hellwig [this message]
2019-07-01 21:54 ` [PATCH 03/15] iomap: zero newly allocated mapped blocks Christoph Hellwig
2019-07-01 21:54 ` [PATCH 04/15] iomap: warn on inline maps iomap_writepage_map Christoph Hellwig
2019-07-01 21:54 ` [PATCH 05/15] iomap: move struct iomap_page to iomap.c Christoph Hellwig
2019-07-01 21:54 ` [PATCH 06/15] HACK: disable lockdep annotation in iomap_dio_rw Christoph Hellwig
2019-07-01 21:54 ` [PATCH 07/15] gfs2: use page_offset in gfs2_page_mkwrite Christoph Hellwig
2019-07-01 21:54 ` [PATCH 08/15] gfs2: remove the unused gfs2_stuffed_write_end function Christoph Hellwig
2019-07-01 21:54 ` [PATCH 09/15] gfs2: merge gfs2_writeback_aops and gfs2_ordered_aops Christoph Hellwig
2019-07-01 21:54 ` [PATCH 10/15] gfs2: merge gfs2_writepage_common into gfs2_writepage Christoph Hellwig
2019-07-01 21:54 ` [PATCH 11/15] gfs2: mark stuffed_readpage static Christoph Hellwig
2019-07-01 21:54 ` [PATCH 12/15] gfs2: use iomap_bmap instead of generic_block_bmap Christoph Hellwig
2019-07-01 21:54 ` [PATCH 13/15] gfs2: implement gfs2_block_zero_range using iomap_zero_range Christoph Hellwig
2019-07-01 21:54 ` [PATCH 14/15] gfs2: don't use buffer_heads in gfs2_allocate_page_backing Christoph Hellwig
2019-07-01 21:54 ` [PATCH 15/15] gfs2: use iomap for buffered I/O in ordered and writeback mode Christoph Hellwig
2019-08-05 12:27 ` Andreas Gruenbacher
2019-08-06 5:30 ` Christoph Hellwig
2019-09-30 20:49 ` Andreas Gruenbacher
2019-07-03 22:35 ` RFC: use the iomap writepage path in gfs2 Andreas Gruenbacher
2019-07-08 16:03 ` Christoph Hellwig
2019-07-08 17:29 ` Andreas Gruenbacher
2019-07-08 0:01 ` Dave Chinner
2019-07-08 16:19 ` Christoph Hellwig
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=20190701215439.19162-3-hch@lst.de \
--to=hch@lst.de \
--cc=agruenba@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).