From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/8] xfs: io type needs to be part of the writepage context
Date: Wed, 12 Aug 2015 08:49:42 +1000 [thread overview]
Message-ID: <1439333388-16452-3-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1439333388-16452-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
If we don't pass the IO type we are mapping with the writepage
context, then the imap is recalculated on every delalloc page that
is passed to xfs_do_writepage(). This defeats the purpose of having
a cached imap between calls and increases the overhead of delalloc
writeback significantly.
Fix this by moving the io type into the writepage context structure
so that it moves with the cached imap through the stack.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_aops.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 6dc1154..4d5479d 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -42,6 +42,7 @@
struct xfs_writepage_ctx {
struct xfs_bmbt_irec imap;
bool imap_valid;
+ unsigned int io_type;
};
void
@@ -952,7 +953,6 @@ xfs_do_writepage(
struct buffer_head *bh, *head;
xfs_ioend_t *ioend = NULL, *iohead = NULL;
loff_t offset;
- unsigned int type;
__uint64_t end_offset;
pgoff_t end_index, last_index;
ssize_t len;
@@ -1056,7 +1056,6 @@ xfs_do_writepage(
bh = head = page_buffers(page);
offset = page_offset(page);
- type = XFS_IO_OVERWRITE;
if (wbc->sync_mode == WB_SYNC_NONE)
nonblocking = 1;
@@ -1081,18 +1080,18 @@ xfs_do_writepage(
}
if (buffer_unwritten(bh)) {
- if (type != XFS_IO_UNWRITTEN) {
- type = XFS_IO_UNWRITTEN;
+ if (wpc->io_type != XFS_IO_UNWRITTEN) {
+ wpc->io_type = XFS_IO_UNWRITTEN;
wpc->imap_valid = false;
}
} else if (buffer_delay(bh)) {
- if (type != XFS_IO_DELALLOC) {
- type = XFS_IO_DELALLOC;
+ if (wpc->io_type != XFS_IO_DELALLOC) {
+ wpc->io_type = XFS_IO_DELALLOC;
wpc->imap_valid = false;
}
} else if (buffer_uptodate(bh)) {
- if (type != XFS_IO_OVERWRITE) {
- type = XFS_IO_OVERWRITE;
+ if (wpc->io_type != XFS_IO_OVERWRITE) {
+ wpc->io_type = XFS_IO_OVERWRITE;
wpc->imap_valid = false;
}
} else {
@@ -1121,8 +1120,8 @@ xfs_do_writepage(
* time.
*/
new_ioend = 1;
- err = xfs_map_blocks(inode, offset, &wpc->imap, type,
- nonblocking);
+ err = xfs_map_blocks(inode, offset, &wpc->imap,
+ wpc->io_type, nonblocking);
if (err)
goto error;
wpc->imap_valid = xfs_imap_valid(inode, &wpc->imap,
@@ -1130,10 +1129,10 @@ xfs_do_writepage(
}
if (wpc->imap_valid) {
lock_buffer(bh);
- if (type != XFS_IO_OVERWRITE)
+ if (wpc->io_type != XFS_IO_OVERWRITE)
xfs_map_at_offset(inode, bh, &wpc->imap, offset);
- xfs_add_to_ioend(inode, bh, offset, type, &ioend,
- new_ioend);
+ xfs_add_to_ioend(inode, bh, offset, wpc->io_type,
+ &ioend, new_ioend);
count++;
}
@@ -1214,7 +1213,9 @@ xfs_vm_writepage(
struct page *page,
struct writeback_control *wbc)
{
- struct xfs_writepage_ctx wpc = {};
+ struct xfs_writepage_ctx wpc = {
+ .io_type = XFS_IO_OVERWRITE,
+ };
return xfs_do_writepage(page, wbc, &wpc);
}
@@ -1224,7 +1225,9 @@ xfs_vm_writepages(
struct address_space *mapping,
struct writeback_control *wbc)
{
- struct xfs_writepage_ctx wpc = {};
+ struct xfs_writepage_ctx wpc = {
+ .io_type = XFS_IO_OVERWRITE,
+ };
struct blk_plug plug;
int ret;
--
2.5.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-08-11 22:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 22:49 [RFC, PATCH 0/8] xfs: get rid of xfs_cluster_write() Dave Chinner
2015-08-11 22:49 ` [PATCH 1/8] xfs: Introduce writeback context for writepages Dave Chinner
2015-08-12 7:26 ` Christoph Hellwig
2015-08-13 1:32 ` Dave Chinner
2015-08-13 6:52 ` Christoph Hellwig
2015-08-14 1:53 ` Dave Chinner
2015-08-15 13:23 ` Christoph Hellwig
2015-08-15 22:57 ` Dave Chinner
2015-08-11 22:49 ` Dave Chinner [this message]
2015-08-11 22:49 ` [PATCH 3/8] xfs: remove nonblocking mode from xfs_vm_writepage Dave Chinner
2015-08-12 7:27 ` Christoph Hellwig
2015-08-11 22:49 ` [PATCH 4/8] xfs: add ioend and iohead to xfs_writepage_ctx Dave Chinner
2015-08-11 22:49 ` [PATCH 5/8] xfs: writepage context needs to handle discontiguous page ranges Dave Chinner
2015-08-11 22:49 ` [PATCH 6/8] xfs: xfs_cluster_write is redundant Dave Chinner
2015-08-11 22:49 ` [PATCH 7/8] xfs: factor mapping out of xfs_do_writepage Dave Chinner
2015-08-11 22:49 ` [PATCH 8/8] xfs: bufferheads are not needed in ->writepage Dave Chinner
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=1439333388-16452-3-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/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