From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 2/2] gfs2: Make special version of gfs2_get_block_noalloc for jdata
Date: Thu, 12 Nov 2020 08:57:43 -0600 [thread overview]
Message-ID: <20201112145743.376789-3-rpeterso@redhat.com> (raw)
In-Reply-To: <20201112145743.376789-1-rpeterso@redhat.com>
Patch b2a846dbef4ef54ef032f0f5ee188c609a0278a7 fixed cases in which
writes were attempted to blocks that had been freed by punch_hole in a jdata
file, but the blocks were still represented on the ail1 list.
It had an unfortunate side-effect of returning -ENODATA in cases that
were not jdata because it affected function gfs2_block_map which is used by
many other callers. This resulted in several xfstests test failures. For
example, generic/029 would fail with this error:
+hexdump: /mnt/scratch/testfile: Input/output error
00000000 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 |XXXXXXXXXXXXXXXX|
This patch creates a special version of gfs2_get_block_noalloc for
jdata which returns -ENODATA instead of -EIO for unmapped blocks.
This is a more targeted approach that doesn't break non-jdata cases.
Fixes: b2a846dbef4e ("gfs2: Ignore journal log writes for jdata holes")
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
fs/gfs2/aops.c | 30 ++++++++++++++++++++++++++++--
fs/gfs2/log.c | 2 ++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 9cd2ecad07db..835c50e6a871 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -80,6 +80,32 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
return -EIO;
return 0;
}
+/**
+ * get_jdata_block_noalloc - jdata version of gfs2_get_block_noalloc
+ * @inode: The inode
+ * @lblock: The block number to look up
+ * @bh_result: The buffer head to return the result in
+ * @create: Non-zero if we may add block to the file
+ *
+ * The reason we have a separate function for jdata is that jdata go through
+ * the journal, and we don't want jdata holes (left by punch_hole) to appear
+ * as IO errors. We can safely ignore them.
+ *
+ * Returns: errno
+ */
+static int get_jdata_block_noalloc(struct inode *inode, sector_t lblock,
+ struct buffer_head *bh_result,
+ int create)
+{
+ int error;
+
+ error = gfs2_block_map(inode, lblock, bh_result, 0);
+ if (error)
+ return error;
+ if (!buffer_mapped(bh_result))
+ return -ENODATA;
+ return 0;
+}
/**
* gfs2_writepage - Write page for writeback mappings
@@ -133,8 +159,8 @@ static int gfs2_write_jdata_page(struct page *page,
if (page->index == end_index && offset)
zero_user_segment(page, offset, PAGE_SIZE);
- return __block_write_full_page(inode, page, gfs2_get_block_noalloc, wbc,
- end_buffer_async_write);
+ return __block_write_full_page(inode, page, get_jdata_block_noalloc,
+ wbc, end_buffer_async_write);
}
/**
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 9133b3178677..2e9314091c81 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -132,6 +132,8 @@ __acquires(&sdp->sd_ail_lock)
spin_unlock(&sdp->sd_ail_lock);
ret = generic_writepages(mapping, wbc);
spin_lock(&sdp->sd_ail_lock);
+ if (ret == -ENODATA) /* if a jdata write into a new hole */
+ ret = 0; /* ignore it */
if (ret || wbc->nr_to_write <= 0)
break;
return -EBUSY;
--
2.26.2
next prev parent reply other threads:[~2020-11-12 14:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 14:57 [Cluster-devel] [GFS2 PATCH 0/2] Fix regression in "Ignore journal log writes for jdata holes" Bob Peterson
2020-11-12 14:57 ` [Cluster-devel] [GFS2 PATCH 1/2] Revert "gfs2: Ignore " Bob Peterson
2020-11-12 14:57 ` Bob Peterson [this message]
2020-11-12 15:44 ` [Cluster-devel] [GFS2 PATCH 0/2] Fix regression in "Ignore " Bob Peterson
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=20201112145743.376789-3-rpeterso@redhat.com \
--to=rpeterso@redhat.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;
as well as URLs for NNTP newsgroup(s).