// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2013 Jie Liu. * All Rights Reserved. */ #include "xfs.h" #include "xfs_fs.h" #include "xfs_shared.h" #include "xfs_format.h" #include "xfs_log_format.h" #include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_da_format.h" #include "xfs_trans_space.h" #include "xfs_da_btree.h" #include "xfs_bmap_btree.h" #include "xfs_trace.h" /* * Shortly after enabling the large extents count feature in 2023, longstanding * bugs were found in the code that computes the minimum log size. Luckily, * the bugs resulted in over-estimates of that size, so there's no impact to * existing users. However, we don't want to reduce the minimum log size * because that can create the situation where a newer mkfs writes a new * filesystem that an older kernel won't mount. * * Several years prior, we also discovered that the transaction reservations * for rmap and reflink operations were unnecessarily large. That was fixed, * but the minimum log size computation was left alone to avoid the * compatibility problems noted above. Fix that too. * * Therefore, we only may correct the computation starting with filesystem * features that didn't exist in 2023. In other words, only turn this on if * the filesystem has parent pointers. * * This function can be called before the XFS_HAS_* flags have been set up, * (e.g. mkfs) so we must check the ondisk superblock. */ static inline bool xfs_want_minlogsize_fixes( struct xfs_sb *sb) { … } /* * Calculate the maximum length in bytes that would be required for a local * attribute value as large attributes out of line are not logged. */ STATIC int xfs_log_calc_max_attrsetm_res( struct xfs_mount *mp) { … } /* * Compute an alternate set of log reservation sizes for use exclusively with * minimum log size calculations. */ static void xfs_log_calc_trans_resv_for_minlogblocks( struct xfs_mount *mp, struct xfs_trans_resv *resv) { … } /* * Iterate over the log space reservation table to figure out and return * the maximum one in terms of the pre-calculated values which were done * at mount time. */ void xfs_log_get_max_trans_res( struct xfs_mount *mp, struct xfs_trans_res *max_resp) { … } /* * Calculate the minimum valid log size for the given superblock configuration. * Used to calculate the minimum log size at mkfs time, and to determine if * the log is large enough or not at mount time. Returns the minimum size in * filesystem block size units. */ int xfs_log_calc_minimum_size( struct xfs_mount *mp) { … }