From: Christoph Hellwig <hch@lst.de>
To: linux-xfs@vger.kernel.org
Cc: david@fromorbit.com
Subject: [PATCH 1/3] xfs: don't allocate COW blocks for zeroing holes or unwritten extents
Date: Wed, 28 Feb 2018 09:45:50 -0800 [thread overview]
Message-ID: <20180228174552.31919-2-hch@lst.de> (raw)
In-Reply-To: <20180228174552.31919-1-hch@lst.de>
The iomap zeroing interface is smart enough to skip zeroing holes or
unwritten extents. Don't subvert this logic for reflink files.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_iomap.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 66e1edbfb2b2..4e771e0f1170 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -955,6 +955,13 @@ static inline bool imap_needs_alloc(struct inode *inode,
(IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN);
}
+static inline bool needs_cow_for_zeroing(struct xfs_bmbt_irec *imap, int nimaps)
+{
+ return nimaps &&
+ imap->br_startblock != HOLESTARTBLOCK &&
+ imap->br_state != XFS_EXT_UNWRITTEN;
+}
+
static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags)
{
/*
@@ -1024,7 +1031,9 @@ xfs_file_iomap_begin(
goto out_unlock;
}
- if ((flags & (IOMAP_WRITE | IOMAP_ZERO)) && xfs_is_reflink_inode(ip)) {
+ if (xfs_is_reflink_inode(ip) &&
+ ((flags & IOMAP_WRITE) ||
+ ((flags & IOMAP_ZERO) && needs_cow_for_zeroing(&imap, nimaps)))) {
if (flags & IOMAP_DIRECT) {
/*
* A reflinked inode will result in CoW alloc.
--
2.14.2
next prev parent reply other threads:[~2018-02-28 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 17:45 iomap fixes Christoph Hellwig
2018-02-28 17:45 ` Christoph Hellwig [this message]
2018-03-01 22:01 ` [PATCH 1/3] xfs: don't allocate COW blocks for zeroing holes or unwritten extents Dave Chinner
2018-03-01 22:28 ` Darrick J. Wong
2018-02-28 17:45 ` [PATCH 2/3] xfs: don't start out with the exclusive ilock for direct I/O Christoph Hellwig
2018-03-01 22:02 ` Dave Chinner
2018-02-28 17:45 ` [PATCH 3/3] xfs: don't block on the ilock for RWF_NOWAIT Christoph Hellwig
2018-03-01 22:04 ` 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=20180228174552.31919-2-hch@lst.de \
--to=hch@lst.de \
--cc=david@fromorbit.com \
--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).