From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, xfs-stable@lists.linux.dev,
Christoph Hellwig <hch@lst.de>, Brian Foster <bfoster@redhat.com>,
"Darrick J. Wong" <djwong@kernel.org>,
Carlos Maiolino <cem@kernel.org>,
Catherine Hoang <catherine.hoang@oracle.com>
Subject: [PATCH 6.6 019/140] xfs: update the file system geometry after recoverying superblock buffers
Date: Mon, 24 Feb 2025 15:33:38 +0100 [thread overview]
Message-ID: <20250224142603.759712204@linuxfoundation.org> (raw)
In-Reply-To: <20250224142602.998423469@linuxfoundation.org>
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <hch@lst.de>
commit 6a18765b54e2e52aebcdb84c3b4f4d1f7cb2c0ca upstream.
Primary superblock buffers that change the file system geometry after a
growfs operation can affect the operation of later CIL checkpoints that
make use of the newly added space and allocation groups.
Apply the changes to the in-memory structures as part of recovery pass 2,
to ensure recovery works fine for such cases.
In the future we should apply the logic to other updates such as features
bits as well.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/xfs/xfs_buf_item_recover.c | 52 ++++++++++++++++++++++++++++++++++++++++++
fs/xfs/xfs_log_recover.c | 8 ------
2 files changed, 52 insertions(+), 8 deletions(-)
--- a/fs/xfs/xfs_buf_item_recover.c
+++ b/fs/xfs/xfs_buf_item_recover.c
@@ -22,6 +22,9 @@
#include "xfs_inode.h"
#include "xfs_dir2.h"
#include "xfs_quota.h"
+#include "xfs_alloc.h"
+#include "xfs_ag.h"
+#include "xfs_sb.h"
/*
* This is the number of entries in the l_buf_cancel_table used during
@@ -685,6 +688,49 @@ xlog_recover_do_inode_buffer(
}
/*
+ * Update the in-memory superblock and perag structures from the primary SB
+ * buffer.
+ *
+ * This is required because transactions running after growfs may require the
+ * updated values to be set in a previous fully commit transaction.
+ */
+static int
+xlog_recover_do_primary_sb_buffer(
+ struct xfs_mount *mp,
+ struct xlog_recover_item *item,
+ struct xfs_buf *bp,
+ struct xfs_buf_log_format *buf_f,
+ xfs_lsn_t current_lsn)
+{
+ struct xfs_dsb *dsb = bp->b_addr;
+ xfs_agnumber_t orig_agcount = mp->m_sb.sb_agcount;
+ int error;
+
+ xlog_recover_do_reg_buffer(mp, item, bp, buf_f, current_lsn);
+
+ /*
+ * Update the in-core super block from the freshly recovered on-disk one.
+ */
+ xfs_sb_from_disk(&mp->m_sb, dsb);
+
+ /*
+ * Initialize the new perags, and also update various block and inode
+ * allocator setting based off the number of AGs or total blocks.
+ * Because of the latter this also needs to happen if the agcount did
+ * not change.
+ */
+ error = xfs_initialize_perag(mp, orig_agcount,
+ mp->m_sb.sb_agcount, mp->m_sb.sb_dblocks,
+ &mp->m_maxagi);
+ if (error) {
+ xfs_warn(mp, "Failed recovery per-ag init: %d", error);
+ return error;
+ }
+ mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
+ return 0;
+}
+
+/*
* V5 filesystems know the age of the buffer on disk being recovered. We can
* have newer objects on disk than we are replaying, and so for these cases we
* don't want to replay the current change as that will make the buffer contents
@@ -967,6 +1013,12 @@ xlog_recover_buf_commit_pass2(
dirty = xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f);
if (!dirty)
goto out_release;
+ } else if ((xfs_blft_from_flags(buf_f) & XFS_BLFT_SB_BUF) &&
+ xfs_buf_daddr(bp) == 0) {
+ error = xlog_recover_do_primary_sb_buffer(mp, item, bp, buf_f,
+ current_lsn);
+ if (error)
+ goto out_release;
} else {
xlog_recover_do_reg_buffer(mp, item, bp, buf_f, current_lsn);
}
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3317,7 +3317,6 @@ xlog_do_recover(
struct xfs_mount *mp = log->l_mp;
struct xfs_buf *bp = mp->m_sb_bp;
struct xfs_sb *sbp = &mp->m_sb;
- xfs_agnumber_t orig_agcount = sbp->sb_agcount;
int error;
trace_xfs_log_recover(log, head_blk, tail_blk);
@@ -3366,13 +3365,6 @@ xlog_do_recover(
/* re-initialise in-core superblock and geometry structures */
mp->m_features |= xfs_sb_version_to_features(sbp);
xfs_reinit_percpu_counters(mp);
- error = xfs_initialize_perag(mp, orig_agcount, sbp->sb_agcount,
- sbp->sb_dblocks, &mp->m_maxagi);
- if (error) {
- xfs_warn(mp, "Failed post-recovery per-ag init: %d", error);
- return error;
- }
- mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
/* Normal transactions can now occur */
clear_bit(XLOG_ACTIVE_RECOVERY, &log->l_opstate);
next prev parent reply other threads:[~2025-02-24 14:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250224142602.998423469@linuxfoundation.org>
2025-02-24 14:33 ` [PATCH 6.6 002/140] xfs: assert a valid limit in xfs_rtfind_forw Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 003/140] xfs: validate inumber in xfs_iget Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 004/140] xfs: fix a sloppy memory handling bug in xfs_iroot_realloc Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 005/140] xfs: fix a typo Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 006/140] xfs: skip background cowblock trims on inodes open for write Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 007/140] xfs: dont free cowblocks from under dirty pagecache on unshare Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 008/140] xfs: merge xfs_attr_leaf_try_add into xfs_attr_leaf_addname Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 009/140] xfs: return bool from xfs_attr3_leaf_add Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 010/140] xfs: distinguish extra split from real ENOSPC from xfs_attr3_leaf_split Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 011/140] xfs: distinguish extra split from real ENOSPC from xfs_attr_node_try_addname Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 012/140] xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 013/140] xfs: dont ifdef around the exact minlen allocations Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 014/140] xfs: call xfs_bmap_exact_minlen_extent_alloc from xfs_bmap_btalloc Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 015/140] xfs: support lowmode allocations in xfs_bmap_exact_minlen_extent_alloc Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 016/140] xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate() Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 017/140] xfs: Remove empty declartion in header file Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 018/140] xfs: pass the exact range to initialize to xfs_initialize_perag Greg Kroah-Hartman
2025-02-24 14:33 ` Greg Kroah-Hartman [this message]
2025-02-24 14:33 ` [PATCH 6.6 020/140] xfs: error out when a superblock buffer update reduces the agcount Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 021/140] xfs: dont use __GFP_RETRY_MAYFAIL in xfs_initialize_perag Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 022/140] xfs: update the pag for the last AG at recovery time Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 023/140] xfs: Reduce unnecessary searches when searching for the best extents Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 024/140] xfs: streamline xfs_filestream_pick_ag Greg Kroah-Hartman
2025-02-24 14:33 ` [PATCH 6.6 025/140] xfs: Check for delayed allocations before setting extsize Greg Kroah-Hartman
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=20250224142603.759712204@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=bfoster@redhat.com \
--cc=catherine.hoang@oracle.com \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=xfs-stable@lists.linux.dev \
/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