From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Fri, 24 Jul 2020 13:33:00 -0500 Subject: [Cluster-devel] [GFS2 PATCH 07/11] gfs2: Add a new jdata-specific version of gfs2_get_block_noalloc In-Reply-To: <20200724183304.366913-1-rpeterso@redhat.com> References: <20200724183304.366913-1-rpeterso@redhat.com> Message-ID: <20200724183304.366913-8-rpeterso@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch creates a new function, gfs2_get_jblk_noalloc, similar to gfs2_get_block_noalloc, which doesn't complain about unmapped blocks. This is due to situations in which jdata pages are queued to the ail1 list but haven't been written back, but afterward, they're deleted by a punch_hole or truncate operation. This resulted in a calling sequence that looks like this: gfs2_ail1_start gfs2_ail1_flush - for every tr on the sd_ail1_list: gfs2_ail1_start_one - for every bd on the tr's tr_ail1_list: generic_writepages write_cache_pages passing __writepage() __writepage() calls: mapping->a_ops->writepage AKA gfs2_jdata_writepage: __gfs2_jdata_writepage calls gfs2_write_jdata_page gfs2_get_jblk_noalloc (was gfs2_get_block_noalloc) gfs2_block_map - finds unmapped jdata page If we return -EIO like gfs2_get_block_noalloc, we error out and withdraw from gfs2_ail1_start_one. With this jdata-specific version, we simply assume the error is due to the page being truncated and ignore the error, which allows the ail1 write operation to finish successfully, writing out the jdata pages it can. Signed-off-by: Bob Peterson --- fs/gfs2/aops.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index e548b54d4139..c94521de838a 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -115,6 +115,27 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc) return 0; } +/** + * gfs2_get_jblk_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 + * + * This is a jdata-specific version of gfs2_get_block_noalloc. The difference + * is: This is called when the ail1 list is being written for jdata pages, + * which means we don't want to throw a -EIO error when they are not mapped, + * which can happen when jdata pages are deleted by punch_hold operations. + * + * Returns: errno + */ + +static int gfs2_get_jblk_noalloc(struct inode *inode, sector_t lblock, + struct buffer_head *bh_result, int create) +{ + return gfs2_block_map(inode, lblock, bh_result, 0); +} + /** * gfs2_write_jdata_page - gfs2 jdata-specific version of block_write_full_page * @page: The page to write @@ -142,7 +163,7 @@ 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, + return __block_write_full_page(inode, page, gfs2_get_jblk_noalloc, wbc, end_buffer_async_write); } -- 2.26.2