10 Star 0 Fork 19

src-anolis-os / xfsprogs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch 2.66 KB
AI 代码解读
一键复制 编辑 原始数据 按行查看 历史
liuzhilin 提交于 2023-12-11 15:31 . update to xfsprogs-5.0.0-12
From 07608c4969ea5ee964ada6c22f692c7474ce555f Mon Sep 17 00:00:00 2001
From: liuzhilin <liuzhilin@uniontech.com>
Date: Mon, 11 Dec 2023 15:28:24 +0800
Subject: [PATCH] mkfs-don-t-let-internal-logs-bump-the-root-dir-inode
---
mkfs/xfs_mkfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index a64a918..6e645cc 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3176,6 +3176,49 @@ validate_log_size(uint64_t logblocks, int blocklog, int min_logblocks)
}
}
+static void
+adjust_ag0_internal_logblocks(
+ struct mkfs_params *cfg,
+ struct xfs_mount *mp,
+ int min_logblocks,
+ int *max_logblocks)
+{
+ int backoff = 0;
+ int ichunk_blocks;
+
+ /*
+ * mkfs will trip over the write verifiers if the log is allocated in
+ * AG 0 and consumes enough space that we cannot allocate a non-sparse
+ * inode chunk for the root directory. The inode allocator requires
+ * that the AG have enough free space for the chunk itself plus enough
+ * to fix up the freelist with aligned blocks if we need to fill the
+ * allocation from the AGFL.
+ */
+ ichunk_blocks = XFS_INODES_PER_CHUNK * cfg->inodesize >> cfg->blocklog;
+ backoff = ichunk_blocks * 4;
+
+ /*
+ * We try to align inode allocations to the data device stripe unit,
+ * so ensure there's enough space to perform an aligned allocation.
+ * The inode geometry structure isn't set up yet, so compute this by
+ * hand.
+ */
+ backoff = max(backoff, cfg->dsunit * 2);
+
+ *max_logblocks -= backoff;
+
+ /* If the specified log size is too big, complain. */
+ if (cli_opt_set(&lopts, L_SIZE) && cfg->logblocks > *max_logblocks) {
+ fprintf(stderr,
+_("internal log size %lld too large, must be less than %d\n"),
+ (long long)cfg->logblocks,
+ *max_logblocks);
+ usage();
+ }
+
+ cfg->logblocks = min(cfg->logblocks, *max_logblocks);
+}
+
static void
calculate_log_size(
struct mkfs_params *cfg,
@@ -3299,6 +3342,9 @@ _("log ag number %lld too large, must be less than %lld\n"),
cfg->logagno = cli->logagno;
} else
cfg->logagno = (xfs_agnumber_t)(sbp->sb_agcount / 2);
+ if (cfg->logagno == 0)
+ adjust_ag0_internal_logblocks(cfg, mp, min_logblocks,
+ &max_logblocks);
cfg->logstart = XFS_AGB_TO_FSB(mp, cfg->logagno,
libxfs_prealloc_blocks(mp));
--
2.39.3
1
https://gitee.com/src-anolis-os/xfsprogs.git
git@gitee.com:src-anolis-os/xfsprogs.git
src-anolis-os
xfsprogs
xfsprogs
a8

搜索帮助