All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 11/12] gfs2: Ignore journal log writes for jdata holes
Date: Fri, 21 Aug 2020 12:33:36 -0500	[thread overview]
Message-ID: <20200821173337.20377-12-rpeterso@redhat.com> (raw)
In-Reply-To: <20200821173337.20377-1-rpeterso@redhat.com>

Before this patch, when flushing out its ail1 list, gfs2_write_jdata_page
called __block_write_full_page passing in function gfs2_get_block_noalloc.
But there was a problem when a process wrote to a jdata file, then
truncated it or punched a hole, leaving references to the blocks within
the new hole in its ail list, which are to be written to the journal log.

In writing them to the journal, after calling gfs2_block_map, function
gfs2_get_block_noalloc, determined that the (hole-punched) block was not
mapped, so it returned -EIO to generic_writepages, which passed it back
to gfs2_ail1_start_one. This, in turn, performed a withdraw, assuming
there was a real IO error writing to the journal.

This might be a valid error when writing metadata to the journal, but for
journaled data writes, it does not warrant with withdraw.

This patch makes a separate function gfs2_get_jblock_noalloc which checks
for this situation and makes an exception for journaled data writes that
correspond to jdata holes. Other errors are returned as before.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 fs/gfs2/aops.c | 27 +++++++++++++++++++++++++--
 fs/gfs2/bmap.c |  8 ++++++--
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 9b2e927e6535..b2ab0077e150 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -81,6 +81,29 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
 	return 0;
 }
 
+/**
+ * gfs2_get_jblock_noalloc - Fills in a buffer head with details about a block
+ * @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
+ *
+ * Returns: errno
+ */
+
+static int gfs2_get_jblock_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 -EIO;
+	return 0;
+}
+
 /**
  * gfs2_writepage - Write page for writeback mappings
  * @page: The page
@@ -142,8 +165,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, gfs2_get_jblock_noalloc,
+				      wbc, end_buffer_async_write);
 }
 
 /**
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 67aff327bf38..2e3b121fb78b 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1300,8 +1300,12 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 	trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
 
 	ret = gfs2_iomap_get(inode, pos, length, flags, &iomap, &mp);
-	if (create && !ret && iomap.type == IOMAP_HOLE)
-		ret = gfs2_iomap_alloc(inode, &iomap, &mp);
+	if (!ret && iomap.type == IOMAP_HOLE) {
+		if (create)
+			ret = gfs2_iomap_alloc(inode, &iomap, &mp);
+		else
+			ret = -ENODATA;
+	}
 	release_metapath(&mp);
 	if (ret)
 		goto out;
-- 
2.26.2



  parent reply	other threads:[~2020-08-21 17:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 17:33 [Cluster-devel] [GFS2 PATCH 00/12] gfs2: jdata patch collection revisited Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 01/12] gfs2: rename gfs2_write_full_page to gfs2_write_jdata_page, remove parm Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 02/12] gfs2: add missing log_blocks trace points in gfs2_write_revokes Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 03/12] gfs2: enhance log_blocks trace point to show log blocks free Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 04/12] gfs2: Wipe jdata and ail1 in gfs2_journal_wipe, formerly gfs2_meta_wipe Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 05/12] gfs2: Calculate number of revokes during evict Bob Peterson
2020-08-27  6:00   ` Andreas Gruenbacher
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 06/12] gfs2: Create transaction for inodes with i_nlink != 0 Bob Peterson
2020-08-27  6:00   ` Andreas Gruenbacher
2020-08-27  7:41     ` Steven Whitehouse
2020-08-27 13:00     ` Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 07/12] gfs2: make gfs2_ail1_empty_one return the count of active items Bob Peterson
2020-08-27  6:00   ` Andreas Gruenbacher
2020-08-27 16:45     ` Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 08/12] gfs2: don't lock sd_ail_lock in gfs2_releasepage Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 09/12] gfs2: Only set PageChecked if we have a transaction Bob Peterson
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 10/12] gfs2: simplify gfs2_block_map Bob Peterson
2020-08-21 17:33 ` Bob Peterson [this message]
2020-08-21 17:33 ` [Cluster-devel] [GFS2 PATCH 12/12] gfs2: add some much needed cleanup for log flushes that fail 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=20200821173337.20377-12-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.