From 833334abfd1042bf27334b65b68c0c295eb4ec3e Mon Sep 17 00:00:00 2001 From: Distro SIG Date: Wed, 26 Jul 2023 11:50:29 +0800 Subject: [PATCH 1/7] update to xfsprogs-5.0.0-11.el8_8.src.rpm Signed-off-by: Distro SIG --- 1001-xfsprogs-gcc10.patch | 68 ----------- 1002-xfsprogs-add-atomic-write-support.patch | 53 --------- ...trample-the-gid-set-in-the-protofile.patch | 88 -------------- ...replay-log-if-dirty-during-xfs_repai.patch | 79 ------------ ...-terminate-getsubopt-arrays-properly.patch | 112 ------------------ ...epair-ignore-empty-xattr-leaf-blocks.patch | 56 --------- ...-validation-of-l-size-against-maximu.patch | 92 -------------- ...nternal-logs-bump-the-root-dir-inode.patch | 105 ---------------- dist | 1 + ...fs-ignore-autofs-mount-table-entries.patch | 78 ++++++++++++ xfsprogs.spec | 80 +------------ 11 files changed, 85 insertions(+), 727 deletions(-) delete mode 100644 1001-xfsprogs-gcc10.patch delete mode 100644 1002-xfsprogs-add-atomic-write-support.patch delete mode 100644 1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch delete mode 100644 1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch delete mode 100644 1005-mkfs-terminate-getsubopt-arrays-properly.patch delete mode 100644 1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch delete mode 100644 1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch delete mode 100644 1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch create mode 100644 dist create mode 100644 xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch diff --git a/1001-xfsprogs-gcc10.patch b/1001-xfsprogs-gcc10.patch deleted file mode 100644 index cc59715..0000000 --- a/1001-xfsprogs-gcc10.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0af5be8216f8201246e8c847c81531855bd0f31d Mon Sep 17 00:00:00 2001 -From: Eric Sandeen -Date: Tue, 19 Apr 2022 18:26:06 +0800 -Subject: [PATCH] xfsprogs: do not redeclare globals provided by libraries - ---- - db/init.c | 1 - - logprint/logprint.c | 5 ++--- - mdrestore/xfs_mdrestore.c | 1 - - 3 files changed, 2 insertions(+), 5 deletions(-) - -diff --git a/db/init.c b/db/init.c -index 455220a..0ac3736 100644 ---- a/db/init.c -+++ b/db/init.c -@@ -27,7 +27,6 @@ static int force; - static struct xfs_mount xmount; - struct xfs_mount *mp; - static struct xlog xlog; --libxfs_init_t x; - xfs_agnumber_t cur_agno = NULLAGNUMBER; - - static void -diff --git a/logprint/logprint.c b/logprint/logprint.c -index 7754a2a..0d6f682 100644 ---- a/logprint/logprint.c -+++ b/logprint/logprint.c -@@ -24,7 +24,6 @@ int print_buffer; - int print_overwrite; - int print_no_data; - int print_no_print; --int print_exit = 1; /* -e is now default. specify -c to override */ - static int print_operation = OP_PRINT; - - static void -@@ -132,7 +131,7 @@ main(int argc, char **argv) - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - memset(&mount, 0, sizeof(mount)); -- -+ print_exit = 1; /* -e is now default. specify -c to override */ - progname = basename(argv[0]); - while ((c = getopt(argc, argv, "bC:cdefl:iqnors:tDVv")) != EOF) { - switch (c) { -@@ -152,7 +151,7 @@ main(int argc, char **argv) - case 'e': - /* -e is now default - */ -- print_exit++; -+ print_exit = 1; - break; - case 'C': - print_operation = OP_COPY; -diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c -index 3375e08..1cd399d 100644 ---- a/mdrestore/xfs_mdrestore.c -+++ b/mdrestore/xfs_mdrestore.c -@@ -7,7 +7,6 @@ - #include "libxfs.h" - #include "xfs_metadump.h" - --char *progname; - static int show_progress = 0; - static int show_info = 0; - static int progress_since_warning = 0; --- -2.27.0 - diff --git a/1002-xfsprogs-add-atomic-write-support.patch b/1002-xfsprogs-add-atomic-write-support.patch deleted file mode 100644 index f901bf2..0000000 --- a/1002-xfsprogs-add-atomic-write-support.patch +++ /dev/null @@ -1,53 +0,0 @@ -From c6f1dcf13e5f16585e2c8e0b750bc13111826e68 Mon Sep 17 00:00:00 2001 -From: Joseph Qi -Date: Mon, 30 May 2022 15:11:22 +0800 -Subject: [PATCH] xfsprogs: add atomic write support - -Signed-off-by: Gao Xiang -Signed-off-by: Joseph Qi ---- - libxfs/xfs_format.h | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h -index 722c9de..894adb9 100644 ---- a/libxfs/xfs_format.h -+++ b/libxfs/xfs_format.h -@@ -450,11 +450,13 @@ xfs_sb_has_compat_feature( - #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ - #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ - #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ -+#define XFS_SB_FEAT_RO_COMPAT_ATOMIC_FILE (1 << 29) /* db atomic file */ - #define XFS_SB_FEAT_RO_COMPAT_ALL \ - (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ - XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ - XFS_SB_FEAT_RO_COMPAT_REFLINK| \ -- XFS_SB_FEAT_RO_COMPAT_INOBTCNT) -+ XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ -+ XFS_SB_FEAT_RO_COMPAT_ATOMIC_FILE) - #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL - static inline bool - xfs_sb_has_ro_compat_feature( -@@ -1158,14 +1160,18 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) - #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ - #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ - -+/* avoid using the highest bit 63 */ -+#define XFS_DIFLAG2_DIO_ATOMIC_WRITE_BIT 60 -+ - #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) - #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) - #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) - #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) -+#define XFS_DIFLAG2_DIO_ATOMIC_WRITE (1ULL << XFS_DIFLAG2_DIO_ATOMIC_WRITE_BIT) - - #define XFS_DIFLAG2_ANY \ - (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ -- XFS_DIFLAG2_BIGTIME) -+ XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_DIO_ATOMIC_WRITE) - - static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) - { --- -2.19.1.6.gb485710b - diff --git a/1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch b/1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch deleted file mode 100644 index 5f5547e..0000000 --- a/1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 79511c6abf13b0ee11050867c817841aaeaa154a Mon Sep 17 00:00:00 2001 -From: "Darrick J. Wong" -Date: Mon, 20 Jun 2022 15:33:39 +0800 -Subject: [PATCH] mkfs: don't trample the gid set in the protofile - -Catherine's recent changes to xfs/019 exposed a bug in how libxfs -handles setgid bits. mkfs reads the desired gid in from the protofile, -but if the parent directory is setgid, it will override the user's -setting and (re)set the child's gid to the parent's gid. Overriding -user settings is (probably) not the desired mode of operation, so create -a flag to struct cred to force the gid in the protofile. - -It looks like this has been broken since ~2005. - -Cc: Catherine Hoang -Fixes: 9f064b7e ("Provide mkfs options to easily exercise all inheritable attributes, esp. the extsize allocator hint. Merge of master-melb:xfs-cmds:24370a by kenmcd.") -Signed-off-by: Darrick J. Wong -Reviewed-by: Catherine Hoang -Reviewed-by: Christoph Hellwig -Reviewed-by: Christoph Hellwig -Signed-off-by: Eric Sandeen -Signed-off-by: Hongnan Li ---- - include/xfs_inode.h | 11 +++++++---- - libxfs/util.c | 3 ++- - mkfs/proto.c | 3 ++- - 3 files changed, 11 insertions(+), 6 deletions(-) - -diff --git a/include/xfs_inode.h b/include/xfs_inode.h -index ccf72d4..d700193 100644 ---- a/include/xfs_inode.h -+++ b/include/xfs_inode.h -@@ -151,10 +151,13 @@ static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip) - return ip->i_d.di_flags2 & XFS_DIFLAG2_BIGTIME; - } - --typedef struct cred { -- uid_t cr_uid; -- gid_t cr_gid; --} cred_t; -+/* Always set the child's GID to this value, even if the parent is setgid. */ -+#define CRED_FORCE_GID (1U << 0) -+struct cred { -+ uid_t cr_uid; -+ gid_t cr_gid; -+ unsigned int cr_flags; -+}; - - extern int libxfs_inode_alloc (struct xfs_trans **, struct xfs_inode *, - mode_t, nlink_t, xfs_dev_t, struct cred *, -diff --git a/libxfs/util.c b/libxfs/util.c -index fd4906f..9741376 100644 ---- a/libxfs/util.c -+++ b/libxfs/util.c -@@ -301,7 +301,8 @@ libxfs_ialloc( - } - - if (pip && (VFS_I(pip)->i_mode & S_ISGID)) { -- ip->i_d.di_gid = pip->i_d.di_gid; -+ if (!(cr->cr_flags & CRED_FORCE_GID)) -+ ip->i_d.di_gid = pip->i_d.di_gid; - if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) - VFS_I(ip)->i_mode |= S_ISGID; - } -diff --git a/mkfs/proto.c b/mkfs/proto.c -index 3bba491..b15f765 100644 ---- a/mkfs/proto.c -+++ b/mkfs/proto.c -@@ -360,7 +360,7 @@ parseproto( - xfs_trans_t *tp; - int val; - int isroot = 0; -- cred_t creds; -+ struct cred creds; - char *value; - struct xfs_name xname; - -@@ -428,6 +428,7 @@ parseproto( - mode |= val; - creds.cr_uid = (int)getnum(getstr(pp), 0, 0, false); - creds.cr_gid = (int)getnum(getstr(pp), 0, 0, false); -+ creds.cr_flags = CRED_FORCE_GID; - xname.name = (unsigned char *)name; - xname.len = name ? strlen(name) : 0; - xname.type = 0; --- -2.27.0 - diff --git a/1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch b/1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch deleted file mode 100644 index 3545484..0000000 --- a/1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch +++ /dev/null @@ -1,79 +0,0 @@ -From b51b816e769842f9ef422896f89b0cbbcf230b01 Mon Sep 17 00:00:00 2001 -From: Joseph Qi -Date: Thu, 10 Nov 2022 17:14:42 +0800 -Subject: [PATCH] fsck.xfs: try to replay log if dirty during xfs_repair - -It is possible that when the machine crashes, the fs is in inconsistent -state with the journal log not yet replayed. This can drop the machine -into the rescue shell because currently fsck.xfs does not address the -journal replay, which brings maintenance trouble. - -So try to replay log if it is dirty using mount/umount way which is -suggested in xfs_repair manpage. Note that we only do this for root -device so that we don't want to touch data device. - -Administrators have to enable this feature by systemd command options -fsck.mode=force and fsck.repair=yes. For other options, we leave it -behave like before, e.g. drop to the rescue shell if repair detects -any corruptions and need administators repair manually. - -Signed-off-by: Joseph Qi ---- - fsck/xfs_fsck.sh | 31 +++++++++++++++++++++++++++++-- - 1 file changed, 29 insertions(+), 2 deletions(-) - -diff --git a/fsck/xfs_fsck.sh b/fsck/xfs_fsck.sh -index 6af0f224..768611c7 100755 ---- a/fsck/xfs_fsck.sh -+++ b/fsck/xfs_fsck.sh -@@ -31,10 +31,12 @@ repair2fsck_code() { - - AUTO=false - FORCE=false -+REPLAY=false - while getopts ":aApyf" c - do - case $c in -- a|A|p|y) AUTO=true;; -+ a|A|p) AUTO=true;; -+ y) REPLAY=true;; - f) FORCE=true;; - esac - done -@@ -64,7 +66,32 @@ fi - - if $FORCE; then - xfs_repair -e $DEV -- repair2fsck_code $? -+ error=$? -+ if [ $error -eq 2 ] && [ $REPLAY = true ]; then -+ for x in $(cat /proc/cmdline); do -+ case $x in -+ root=*) -+ ROOT="${x#root=}" -+ ;; -+ rootflags=*) -+ ROOTFLAGS="-o ${x#rootflags=}" -+ ;; -+ esac -+ done -+ -+ test -b "$ROOT" || ROOT=$(blkid -t "$ROOT" -o device) -+ if [ $DEV = $ROOT ]; then -+ echo "Replaying log for $DEV" -+ mkdir -p /tmp/replay_mnt || exit 1 -+ mount $DEV /tmp/replay_mnt $ROOTFLAGS || exit 1 -+ umount /tmp/replay_mnt -+ rm -d /tmp/replay_mnt -+ -+ xfs_repair -e $DEV -+ error=$? -+ fi -+ fi -+ repair2fsck_code $error - exit $? - fi - --- -2.24.4 - diff --git a/1005-mkfs-terminate-getsubopt-arrays-properly.patch b/1005-mkfs-terminate-getsubopt-arrays-properly.patch deleted file mode 100644 index 7d0daa7..0000000 --- a/1005-mkfs-terminate-getsubopt-arrays-properly.patch +++ /dev/null @@ -1,112 +0,0 @@ -From e3f705d0c461689fcfd36e405c61df39d9a83e0b Mon Sep 17 00:00:00 2001 -From: "Darrick J. Wong" -Date: Wed, 13 Jul 2022 20:58:28 -0500 -Subject: [PATCH 1005/1008] mkfs: terminate getsubopt arrays properly - -Having not drank any (or maybe too much) coffee this morning, I typed: - -$ mkfs.xfs -d agcount=3 -d nrext64=0 -Segmentation fault - -I traced this down to getsubopt walking off the end of the dopts.subopts -array. The manpage says you're supposed to terminate the suboptions -string array with a NULL entry, but the structure definition uses -MAX_SUBOPTS/D_MAX_OPTS directly, which means there is no terminator. - -Explicitly terminate each suboption array with a NULL entry after -making room for it. - -Signed-off-by: Darrick J. Wong -[sandeen: explicitly add NULL terminators & clarify comment] -Reviewed-by: Eric Sandeen -Signed-off-by: Eric Sandeen -Signed-off-by: Ferry Meng -Reviewed-by: Joseph Qi ---- - mkfs/xfs_mkfs.c | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c -index 36360ba7..37747698 100644 ---- a/mkfs/xfs_mkfs.c -+++ b/mkfs/xfs_mkfs.c -@@ -122,8 +122,11 @@ enum { - M_MAX_OPTS, - }; - --/* Just define the max options array size manually right now */ --#define MAX_SUBOPTS D_MAX_OPTS -+/* -+ * Just define the max options array size manually to the largest -+ * enum right now, leaving room for a NULL terminator at the end -+ */ -+#define MAX_SUBOPTS (D_MAX_OPTS + 1) - - #define SUBOPT_NEEDS_VAL (-1LL) - #define MAX_CONFLICTS 8 -@@ -224,6 +227,7 @@ static struct opt_params bopts = { - .name = 'b', - .subopts = { - [B_SIZE] = "size", -+ [B_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = B_SIZE, -@@ -255,6 +259,7 @@ static struct opt_params dopts = { - [D_PROJINHERIT] = "projinherit", - [D_EXTSZINHERIT] = "extszinherit", - [D_COWEXTSIZE] = "cowextsize", -+ [D_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = D_AGCOUNT, -@@ -384,6 +389,7 @@ static struct opt_params iopts = { - [I_ATTR] = "attr", - [I_PROJID32BIT] = "projid32bit", - [I_SPINODES] = "sparse", -+ [I_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = I_ALIGN, -@@ -449,6 +455,7 @@ static struct opt_params lopts = { - [L_FILE] = "file", - [L_NAME] = "name", - [L_LAZYSBCNTR] = "lazy-count", -+ [L_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = L_AGNUM, -@@ -540,6 +547,7 @@ static struct opt_params nopts = { - [N_SIZE] = "size", - [N_VERSION] = "version", - [N_FTYPE] = "ftype", -+ [N_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = N_SIZE, -@@ -574,6 +582,7 @@ static struct opt_params ropts = { - [R_FILE] = "file", - [R_NAME] = "name", - [R_NOALIGN] = "noalign", -+ [R_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = R_EXTSIZE, -@@ -620,6 +629,7 @@ static struct opt_params sopts = { - .subopts = { - [S_SIZE] = "size", - [S_SECTSIZE] = "sectsize", -+ [S_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = S_SIZE, -@@ -655,6 +665,7 @@ static struct opt_params mopts = { - [M_REFLINK] = "reflink", - [M_INOBTCNT] = "inobtcount", - [M_BIGTIME] = "bigtime", -+ [M_MAX_OPTS] = NULL, - }, - .subopt_params = { - { .index = M_CRC, --- -2.19.1.6.gb485710b diff --git a/1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch b/1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch deleted file mode 100644 index de7f811..0000000 --- a/1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch +++ /dev/null @@ -1,56 +0,0 @@ -From a4b3ccd82a079b63df1630482eaf26c0d4bdf4bc Mon Sep 17 00:00:00 2001 -From: "Darrick J. Wong" -Date: Wed, 13 Jul 2022 20:58:25 -0500 -Subject: [PATCH 1006/1008] xfs_repair: ignore empty xattr leaf blocks - -As detailed in the commit: - -5e572d1a xfs: empty xattr leaf header blocks are not corruption - -empty xattr leaf blocks can be the benign byproduct of the system -going down during the multi-step process of adding a large xattr -to a file that has no xattrs. If we find one at attr fork offset 0, -we should clear it, but this isn't a corruption. - -Signed-off-by: Darrick J. Wong -Reviewed-by: Dave Chinner -Signed-off-by: Eric Sandeen -Signed-off-by: Ferry Meng -Reviewed-by: Joseph Qi ---- - repair/attr_repair.c | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -diff --git a/repair/attr_repair.c b/repair/attr_repair.c -index 5ad81c09..8cd9e2de 100644 ---- a/repair/attr_repair.c -+++ b/repair/attr_repair.c -@@ -584,6 +584,26 @@ process_leaf_attr_block( - firstb = mp->m_sb.sb_blocksize; - stop = xfs_attr3_leaf_hdr_size(leaf); - -+ /* -+ * Empty leaf blocks at offset zero can occur as a race between -+ * setxattr and the system going down, so we only take action if we're -+ * running in modify mode. See xfs_attr3_leaf_verify for details of -+ * how we've screwed this up many times. -+ */ -+ if (!leafhdr.count && da_bno == 0) { -+ if (no_modify) { -+ do_log( -+ _("would clear empty leaf attr block 0, inode %" PRIu64 "\n"), -+ ino); -+ return 0; -+ } -+ -+ do_warn( -+ _("will clear empty leaf attr block 0, inode %" PRIu64 "\n"), -+ ino); -+ return 1; -+ } -+ - /* does the count look sorta valid? */ - if (!leafhdr.count || - leafhdr.count * sizeof(xfs_attr_leaf_entry_t) + stop > --- -2.19.1.6.gb485710b diff --git a/1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch b/1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch deleted file mode 100644 index 68260d2..0000000 --- a/1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 65e52d802372dc59d64c719997a7cc05782934e9 Mon Sep 17 00:00:00 2001 -From: "Darrick J. Wong" -Date: Mon, 4 Apr 2022 11:29:34 -0700 -Subject: [PATCH 1007/1008] mkfs: fix missing validation of -l size against - maximum internal log size - -If a sysadmin specifies a log size explicitly, we don't actually check -that against the maximum internal log size that we compute for the -default log size computation. We're going to add more validation soon, -so refactor the max internal log blocks into a common variable and -add a check. - -Signed-off-by: Darrick J. Wong -Reviewed-by: Christoph Hellwig -Signed-off-by: Ferry Meng -Reviewed-by: Joseph Qi ---- - mkfs/xfs_mkfs.c | 36 +++++++++++++++++++++++------------- - 1 file changed, 23 insertions(+), 13 deletions(-) - -diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c -index 37747698..c9130805 100644 ---- a/mkfs/xfs_mkfs.c -+++ b/mkfs/xfs_mkfs.c -@@ -3184,6 +3184,7 @@ calculate_log_size( - { - struct xfs_sb *sbp = &mp->m_sb; - int min_logblocks; -+ int max_logblocks; /* absolute max for this AG */ - struct xfs_mount mount; - - /* we need a temporary mount to calculate the minimum log size. */ -@@ -3223,6 +3224,19 @@ _("external log device %lld too small, must be at least %lld blocks\n"), - return; - } - -+ /* -+ * Make sure the log fits wholly within an AG -+ * -+ * XXX: If agf->freeblks ends up as 0 because the log uses all -+ * the free space, it causes the kernel all sorts of problems -+ * with per-ag reservations. Right now just back it off one -+ * block, but there's a whole can of worms here that needs to be -+ * opened to decide what is the valid maximum size of a log in -+ * an AG. -+ */ -+ max_logblocks = libxfs_alloc_ag_max_usable(mp) - 1; -+ -+ - /* internal log - if no size specified, calculate automatically */ - if (!cfg->logblocks) { - if (cfg->dblocks < GIGABYTES(1, cfg->blocklog)) { -@@ -3248,21 +3262,10 @@ _("external log device %lld too small, must be at least %lld blocks\n"), - cfg->logblocks = cfg->logblocks >> cfg->blocklog; - } - -- /* Ensure the chosen size meets minimum log size requirements */ -+ /* Ensure the chosen size fits within log size requirements */ - cfg->logblocks = max(min_logblocks, cfg->logblocks); - -- /* -- * Make sure the log fits wholly within an AG -- * -- * XXX: If agf->freeblks ends up as 0 because the log uses all -- * the free space, it causes the kernel all sorts of problems -- * with per-ag reservations. Right now just back it off one -- * block, but there's a whole can of worms here that needs to be -- * opened to decide what is the valid maximum size of a log in -- * an AG. -- */ -- cfg->logblocks = min(cfg->logblocks, -- libxfs_alloc_ag_max_usable(mp) - 1); -+ cfg->logblocks = min(cfg->logblocks, max_logblocks); - - /* and now clamp the size to the maximum supported size */ - cfg->logblocks = min(cfg->logblocks, XFS_MAX_LOG_BLOCKS); -@@ -3270,6 +3273,13 @@ _("external log device %lld too small, must be at least %lld blocks\n"), - cfg->logblocks = XFS_MAX_LOG_BYTES >> cfg->blocklog; - - validate_log_size(cfg->logblocks, cfg->blocklog, min_logblocks); -+ } else if (cfg->logblocks > max_logblocks) { -+ /* check specified log size */ -+ fprintf(stderr, -+_("internal log size %lld too large, must be less than %d\n"), -+ (long long)cfg->logblocks, -+ max_logblocks); -+ usage(); - } - - if (cfg->logblocks > sbp->sb_agblocks - libxfs_prealloc_blocks(mp)) { --- -2.19.1.6.gb485710b diff --git a/1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch b/1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch deleted file mode 100644 index dcc2c3b..0000000 --- a/1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 92f6722af80cee37ddc5aca6955c5fd31ed81322 Mon Sep 17 00:00:00 2001 -From: "Darrick J. Wong" -Date: Fri, 11 Mar 2022 17:32:02 -0800 -Subject: [PATCH 1008/1008] mkfs: don't let internal logs bump the root dir - inode chunk to AG 1 - -Currently, we don't let an internal log consume every last block in an -AG. According to the comment, we're doing this to avoid tripping AGF -verifiers if freeblks==0, but on a modern filesystem this isn't -sufficient to avoid problems because we need to have enough space in the -AG to allocate an aligned root inode chunk, if it should be the case -that the log also ends up in AG 0: - -$ truncate -s 6366g /tmp/a ; mkfs.xfs -f /tmp/a -d agcount=3200 -l agnum=0 -meta-data=/tmp/a isize=512 agcount=3200, agsize=521503 blks - = sectsz=512 attr=2, projid32bit=1 - = crc=1 finobt=1, sparse=1, rmapbt=0 - = reflink=1 bigtime=0 inobtcount=0 -data = bsize=4096 blocks=1668808704, imaxpct=5 - = sunit=0 swidth=0 blks -naming =version 2 bsize=4096 ascii-ci=0, ftype=1 -log =internal log bsize=4096 blocks=521492, version=2 - = sectsz=512 sunit=0 blks, lazy-count=1 -realtime =none extsz=4096 blocks=0, rtextents=0 -mkfs.xfs: root inode created in AG 1, not AG 0 - -Therefore, modify the maximum internal log size calculation to constrain -the maximum internal log size so that the aligned inode chunk allocation -will always succeed. - -Signed-off-by: Darrick J. Wong -Reviewed-by: Christoph Hellwig -Signed-off-by: Ferry Meng -Reviewed-by: Joseph Qi ---- - mkfs/xfs_mkfs.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 47 insertions(+) - -diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c -index c9130805..6d0109a8 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, -@@ -3301,6 +3344,10 @@ _("log ag number %lld too large, must be less than %lld\n"), - } 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.19.1.6.gb485710b diff --git a/dist b/dist new file mode 100644 index 0000000..5aa45c5 --- /dev/null +++ b/dist @@ -0,0 +1 @@ +an8_8 diff --git a/xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch b/xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch new file mode 100644 index 0000000..ec0e2fb --- /dev/null +++ b/xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch @@ -0,0 +1,78 @@ +From 5ca4d781d36946de197ed2d4196c84c8f6b4522f Mon Sep 17 00:00:00 2001 +From: Ian Kent +Date: Mon, 12 Oct 2020 15:40:01 -0400 +Subject: [PATCH] xfsprogs: ignore autofs mount table entries + +Some of the xfsprogs utilities read the mount table via. getmntent(3). + +The mount table may contain (almost always these days since /etc/mtab is +symlinked to /proc/self/mounts) autofs mount entries. During processing +of the mount table entries statfs(2) can be called on mount point paths +which will trigger an automount if those entries are direct or offset +autofs mount triggers (indirect autofs mounts aren't affected). + +This can be a problem when there are a lot of autofs direct or offset +mounts because real mounts will be triggered when statfs(2) is called. +This can be particularly bad if the triggered mounts are NFS mounts and +the server is unavailable leading to lengthy boot times or worse. + +Simply ignoring autofs mount entries during getmentent(3) traversals +avoids the statfs() call that triggers these mounts. If there are +automounted mounts (real mounts) at the time of reading the mount table +these will still be seen in the list so they will be included if that +actually matters to the reader. + +Recent glibc getmntent(3) can ignore autofs mounts but that requires the +autofs user to configure autofs to use the "ignore" pseudo mount option +for autofs mounts. But this isn't yet the autofs default (to prevent +unexpected side effects) so that can't be used. + +The autofs direct and offset automount triggers are pseudo file system +mounts and are more or less useless in terms on file system information +so excluding them doesn't sacrifice useful file system information +either. + +Consequently excluding autofs mounts shouldn't have any adverse side +effects. + +Changes since v1: +- drop hunk from fsr/xfs_fsr.c. + +Signed-off-by: Ian Kent +Reviewed-by: Eric Sandeen +Signed-off-by: Eric Sandeen +Signed-off-by: Pavel Reichl +--- + libfrog/linux.c | 2 ++ + libfrog/paths.c | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/libfrog/linux.c b/libfrog/linux.c +index 40a839d1..a45d99ab 100644 +--- a/libfrog/linux.c ++++ b/libfrog/linux.c +@@ -73,6 +73,8 @@ platform_check_mount(char *name, char *block, struct stat *s, int flags) + * servers. So first, a simple check: does the "dev" start with "/" ? + */ + while ((mnt = getmntent(f)) != NULL) { ++ if (!strcmp(mnt->mnt_type, "autofs")) ++ continue; + if (mnt->mnt_fsname[0] != '/') + continue; + if (stat(mnt->mnt_dir, &mst) < 0) +diff --git a/libfrog/paths.c b/libfrog/paths.c +index 32737223..d6793764 100644 +--- a/libfrog/paths.c ++++ b/libfrog/paths.c +@@ -389,6 +389,8 @@ fs_table_initialise_mounts( + return errno; + + while ((mnt = getmntent(mtp)) != NULL) { ++ if (!strcmp(mnt->mnt_type, "autofs")) ++ continue; + if (!realpath(mnt->mnt_dir, rmnt_dir)) + continue; + if (!realpath(mnt->mnt_fsname, rmnt_fsname)) +-- +2.40.1 + diff --git a/xfsprogs.spec b/xfsprogs.spec index 1398298..8257369 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -1,8 +1,7 @@ -%define anolis_release .0.6 Summary: Utilities for managing the XFS filesystem Name: xfsprogs Version: 5.0.0 -Release: 10%{anolis_release}%{?dist} +Release: 11%{?dist} License: GPL+ and LGPLv2+ Group: System Environment/Base URL: https://xfs.wiki.kernel.org @@ -11,29 +10,7 @@ BuildRequires: gcc BuildRequires: libtool, gettext, libattr-devel, libuuid-devel BuildRequires: readline-devel, libblkid-devel >= 2.17-0.1.git5e51568 BuildRequires: lvm2-devel, libicu-devel >= 4.6 -Requires: glibc Provides: xfs-cmds -Provides: /usr/sbin/fsck.xfs -Provides: /usr/sbin/mkfs.xfs -Provides: /usr/sbin/xfs_admin -Provides: /usr/sbin/xfs_bmap -Provides: /usr/sbin/xfs_copy -Provides: /usr/sbin/xfs_db -Provides: /usr/sbin/xfs_estimate -Provides: /usr/sbin/xfs_freeze -Provides: /usr/sbin/xfs_fsr -Provides: /usr/sbin/xfs_growfs -Provides: /usr/sbin/xfs_info -Provides: /usr/sbin/xfs_io -Provides: /usr/sbin/xfs_logprint -Provides: /usr/sbin/xfs_mdrestore -Provides: /usr/sbin/xfs_metadump -Provides: /usr/sbin/xfs_mkfile -Provides: /usr/sbin/xfs_ncheck -Provides: /usr/sbin/xfs_quota -Provides: /usr/sbin/xfs_repair -Provides: /usr/sbin/xfs_rtcp -Provides: /usr/sbin/xfs_spaceman Obsoletes: xfs-cmds <= %{version} Provides: xfsprogs-qa-devel Obsoletes: xfsprogs-qa-devel <= %{version} @@ -103,18 +80,7 @@ Patch59: xfsprogs-5.13.0-xfs-rename-struct-xfs_legacy_ictimestamp.patch Patch60: xfsprogs-5.11.0-mkfs-fix-wrong-inobtcount-usage-error-output.patch Patch61: xfsprogs-5.12.0-libxfs-expose-inobtcount-in-xfs-geometry.patch Patch62: xfsprogs-5.12.0-libfrog-report-inobtcount-in-geometry.patch - -# Begin: Anolis customized patches -# backport patch from upstream -Patch1001: 1001-xfsprogs-gcc10.patch -Patch1002: 1002-xfsprogs-add-atomic-write-support.patch -Patch1003: 1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch -Patch1004: 1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch -Patch1005: 1005-mkfs-terminate-getsubopt-arrays-properly.patch -Patch1006: 1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch -Patch1007: 1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch -Patch1008: 1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch -# End: Anolis customized patches +Patch63: xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch %description A set of commands to use the XFS filesystem, including mkfs.xfs. @@ -142,14 +108,6 @@ You should install xfsprogs-devel if you want to develop XFS filesystem-specific programs, If you install xfsprogs-devel, you'll also want to install xfsprogs. -%package doc -Summary: Documents for %{name} -BuildArch: noarch -Requires: %{name} = %{version}-%{release} - -%description doc -Doc pages for %{name}. - %prep %setup -q @@ -216,14 +174,7 @@ Doc pages for %{name}. %patch60 -p1 %patch61 -p1 %patch62 -p1 -%patch1001 -p1 -%patch1002 -p1 -%patch1003 -p1 -%patch1004 -p1 -%patch1005 -p1 -%patch1006 -p1 -%patch1007 -p1 -%patch1008 -p1 +%patch63 -p1 %build export tagname=CC @@ -258,6 +209,7 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %postun -p /sbin/ldconfig %files -f %{name}.lang +%doc doc/CHANGES README %{_libdir}/*.so.* %{_mandir}/man5/* %{_mandir}/man8/* @@ -281,29 +233,9 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %{_libdir}/*.so -%files doc -%doc doc/CHANGES README - %changelog -* Mon Apr 24 2023 Ferry Meng - 5.0.0-10.0.6 -- mkfs.xfs: terminate getsubopt arrays properly -- mkfs.xfs: fix internal logs' size -- xfs_repair: ignore empty xattr leaf blocks - -* Mon Nov 21 2022 Joseph Qi - 5.0.0-10.0.5 -- Add fsck log replay support - -* Sat Jul 16 2022 Hangbo Fan 5.0.0-10.0.4 -- Add doc sub package - -* Mon Jun 20 2022 Hongnan Li - 5.0.0-10.0.3 -- mkfs: don't trample the gid set in the protofile - -* Tue May 31 2022 Joseph Qi - 5.0.0-10.0.2 -- Add atomic write support - -* Tue Apr 19 2022 Weitao Zhou - 5.0.0-10.0.1 -- Fix gcc10 -fno-common compile issue for compatible with gcc10 build +* Fri May 19 2023 Pavel Reichl - 5.0.0-11 +- Fix ignore autofs mount table entries (#2208391) * Thu Dec 09 2021 Bill O'Donnell 5.0.0-10 - xfsprogs: enable bigtime and inode btree counter features in RHEL8 (#2024201)) -- Gitee From c4a5b994c7fea934bdad3ab2676115406de14a21 Mon Sep 17 00:00:00 2001 From: pangqing Date: Tue, 19 Apr 2022 18:55:32 +0800 Subject: [PATCH 2/7] fix gcc10 -fno-common compile issue until upstream fixes Signed-off-by: Weitao Zhou --- 1001-xfsprogs-gcc10.patch | 68 +++++++++++++++++++++++++++++++++++++++ xfsprogs.spec | 12 ++++++- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 1001-xfsprogs-gcc10.patch diff --git a/1001-xfsprogs-gcc10.patch b/1001-xfsprogs-gcc10.patch new file mode 100644 index 0000000..cc59715 --- /dev/null +++ b/1001-xfsprogs-gcc10.patch @@ -0,0 +1,68 @@ +From 0af5be8216f8201246e8c847c81531855bd0f31d Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Tue, 19 Apr 2022 18:26:06 +0800 +Subject: [PATCH] xfsprogs: do not redeclare globals provided by libraries + +--- + db/init.c | 1 - + logprint/logprint.c | 5 ++--- + mdrestore/xfs_mdrestore.c | 1 - + 3 files changed, 2 insertions(+), 5 deletions(-) + +diff --git a/db/init.c b/db/init.c +index 455220a..0ac3736 100644 +--- a/db/init.c ++++ b/db/init.c +@@ -27,7 +27,6 @@ static int force; + static struct xfs_mount xmount; + struct xfs_mount *mp; + static struct xlog xlog; +-libxfs_init_t x; + xfs_agnumber_t cur_agno = NULLAGNUMBER; + + static void +diff --git a/logprint/logprint.c b/logprint/logprint.c +index 7754a2a..0d6f682 100644 +--- a/logprint/logprint.c ++++ b/logprint/logprint.c +@@ -24,7 +24,6 @@ int print_buffer; + int print_overwrite; + int print_no_data; + int print_no_print; +-int print_exit = 1; /* -e is now default. specify -c to override */ + static int print_operation = OP_PRINT; + + static void +@@ -132,7 +131,7 @@ main(int argc, char **argv) + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + memset(&mount, 0, sizeof(mount)); +- ++ print_exit = 1; /* -e is now default. specify -c to override */ + progname = basename(argv[0]); + while ((c = getopt(argc, argv, "bC:cdefl:iqnors:tDVv")) != EOF) { + switch (c) { +@@ -152,7 +151,7 @@ main(int argc, char **argv) + case 'e': + /* -e is now default + */ +- print_exit++; ++ print_exit = 1; + break; + case 'C': + print_operation = OP_COPY; +diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c +index 3375e08..1cd399d 100644 +--- a/mdrestore/xfs_mdrestore.c ++++ b/mdrestore/xfs_mdrestore.c +@@ -7,7 +7,6 @@ + #include "libxfs.h" + #include "xfs_metadump.h" + +-char *progname; + static int show_progress = 0; + static int show_info = 0; + static int progress_since_warning = 0; +-- +2.27.0 + diff --git a/xfsprogs.spec b/xfsprogs.spec index 8257369..991fa51 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -1,7 +1,8 @@ +%define anolis_release .0.1 Summary: Utilities for managing the XFS filesystem Name: xfsprogs Version: 5.0.0 -Release: 11%{?dist} +Release: 11%{anolis_release}%{?dist} License: GPL+ and LGPLv2+ Group: System Environment/Base URL: https://xfs.wiki.kernel.org @@ -82,6 +83,11 @@ Patch61: xfsprogs-5.12.0-libxfs-expose-inobtcount-in-xfs-geometry.patch Patch62: xfsprogs-5.12.0-libfrog-report-inobtcount-in-geometry.patch Patch63: xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch +# Begin: Anolis customized patches +# backport patch from upstream +Patch1001: 1001-xfsprogs-gcc10.patch +# End: Anolis customized patches + %description A set of commands to use the XFS filesystem, including mkfs.xfs. @@ -175,6 +181,7 @@ also want to install xfsprogs. %patch61 -p1 %patch62 -p1 %patch63 -p1 +%patch1001 -p1 %build export tagname=CC @@ -234,6 +241,9 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %{_libdir}/*.so %changelog +* Thu Jul 27 2023 Weitao Zhou - 5.0.0-11.0.1 +- Fix gcc10 -fno-common compile issue for compatible with gcc10 build + * Fri May 19 2023 Pavel Reichl - 5.0.0-11 - Fix ignore autofs mount table entries (#2208391) -- Gitee From b74f824e3e12cb8ff4d18b60daf7a0ff901e2929 Mon Sep 17 00:00:00 2001 From: Joseph Qi Date: Tue, 31 May 2022 18:43:58 +0800 Subject: [PATCH 3/7] Add atomic write support Signed-off-by: Joseph Qi --- 1002-xfsprogs-add-atomic-write-support.patch | 53 ++++++++++++++++++++ xfsprogs.spec | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 1002-xfsprogs-add-atomic-write-support.patch diff --git a/1002-xfsprogs-add-atomic-write-support.patch b/1002-xfsprogs-add-atomic-write-support.patch new file mode 100644 index 0000000..f901bf2 --- /dev/null +++ b/1002-xfsprogs-add-atomic-write-support.patch @@ -0,0 +1,53 @@ +From c6f1dcf13e5f16585e2c8e0b750bc13111826e68 Mon Sep 17 00:00:00 2001 +From: Joseph Qi +Date: Mon, 30 May 2022 15:11:22 +0800 +Subject: [PATCH] xfsprogs: add atomic write support + +Signed-off-by: Gao Xiang +Signed-off-by: Joseph Qi +--- + libxfs/xfs_format.h | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h +index 722c9de..894adb9 100644 +--- a/libxfs/xfs_format.h ++++ b/libxfs/xfs_format.h +@@ -450,11 +450,13 @@ xfs_sb_has_compat_feature( + #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ + #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ + #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ ++#define XFS_SB_FEAT_RO_COMPAT_ATOMIC_FILE (1 << 29) /* db atomic file */ + #define XFS_SB_FEAT_RO_COMPAT_ALL \ + (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ + XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ + XFS_SB_FEAT_RO_COMPAT_REFLINK| \ +- XFS_SB_FEAT_RO_COMPAT_INOBTCNT) ++ XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ ++ XFS_SB_FEAT_RO_COMPAT_ATOMIC_FILE) + #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL + static inline bool + xfs_sb_has_ro_compat_feature( +@@ -1158,14 +1160,18 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) + #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ + #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ + ++/* avoid using the highest bit 63 */ ++#define XFS_DIFLAG2_DIO_ATOMIC_WRITE_BIT 60 ++ + #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) + #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) + #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) + #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) ++#define XFS_DIFLAG2_DIO_ATOMIC_WRITE (1ULL << XFS_DIFLAG2_DIO_ATOMIC_WRITE_BIT) + + #define XFS_DIFLAG2_ANY \ + (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ +- XFS_DIFLAG2_BIGTIME) ++ XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_DIO_ATOMIC_WRITE) + + static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) + { +-- +2.19.1.6.gb485710b + diff --git a/xfsprogs.spec b/xfsprogs.spec index 991fa51..e0eb8a4 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -86,6 +86,7 @@ Patch63: xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch # Begin: Anolis customized patches # backport patch from upstream Patch1001: 1001-xfsprogs-gcc10.patch +Patch1002: 1002-xfsprogs-add-atomic-write-support.patch # End: Anolis customized patches %description @@ -182,6 +183,7 @@ also want to install xfsprogs. %patch62 -p1 %patch63 -p1 %patch1001 -p1 +%patch1002 -p1 %build export tagname=CC @@ -243,6 +245,7 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %changelog * Thu Jul 27 2023 Weitao Zhou - 5.0.0-11.0.1 - Fix gcc10 -fno-common compile issue for compatible with gcc10 build +- Add atomic write support (joseph.qi@linux.aliabba.com) * Fri May 19 2023 Pavel Reichl - 5.0.0-11 - Fix ignore autofs mount table entries (#2208391) -- Gitee From 6f624685b2e3175b04107ec79ea28d4bc8f3b330 Mon Sep 17 00:00:00 2001 From: Hongnan Li Date: Thu, 23 Jun 2022 15:00:29 +0800 Subject: [PATCH 4/7] mkfs: don't trample the gid set in the protofile Signed-off-by: Hongnan Li --- ...trample-the-gid-set-in-the-protofile.patch | 88 +++++++++++++++++++ xfsprogs.spec | 3 + 2 files changed, 91 insertions(+) create mode 100644 1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch diff --git a/1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch b/1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch new file mode 100644 index 0000000..5f5547e --- /dev/null +++ b/1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch @@ -0,0 +1,88 @@ +From 79511c6abf13b0ee11050867c817841aaeaa154a Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Mon, 20 Jun 2022 15:33:39 +0800 +Subject: [PATCH] mkfs: don't trample the gid set in the protofile + +Catherine's recent changes to xfs/019 exposed a bug in how libxfs +handles setgid bits. mkfs reads the desired gid in from the protofile, +but if the parent directory is setgid, it will override the user's +setting and (re)set the child's gid to the parent's gid. Overriding +user settings is (probably) not the desired mode of operation, so create +a flag to struct cred to force the gid in the protofile. + +It looks like this has been broken since ~2005. + +Cc: Catherine Hoang +Fixes: 9f064b7e ("Provide mkfs options to easily exercise all inheritable attributes, esp. the extsize allocator hint. Merge of master-melb:xfs-cmds:24370a by kenmcd.") +Signed-off-by: Darrick J. Wong +Reviewed-by: Catherine Hoang +Reviewed-by: Christoph Hellwig +Reviewed-by: Christoph Hellwig +Signed-off-by: Eric Sandeen +Signed-off-by: Hongnan Li +--- + include/xfs_inode.h | 11 +++++++---- + libxfs/util.c | 3 ++- + mkfs/proto.c | 3 ++- + 3 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/include/xfs_inode.h b/include/xfs_inode.h +index ccf72d4..d700193 100644 +--- a/include/xfs_inode.h ++++ b/include/xfs_inode.h +@@ -151,10 +151,13 @@ static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip) + return ip->i_d.di_flags2 & XFS_DIFLAG2_BIGTIME; + } + +-typedef struct cred { +- uid_t cr_uid; +- gid_t cr_gid; +-} cred_t; ++/* Always set the child's GID to this value, even if the parent is setgid. */ ++#define CRED_FORCE_GID (1U << 0) ++struct cred { ++ uid_t cr_uid; ++ gid_t cr_gid; ++ unsigned int cr_flags; ++}; + + extern int libxfs_inode_alloc (struct xfs_trans **, struct xfs_inode *, + mode_t, nlink_t, xfs_dev_t, struct cred *, +diff --git a/libxfs/util.c b/libxfs/util.c +index fd4906f..9741376 100644 +--- a/libxfs/util.c ++++ b/libxfs/util.c +@@ -301,7 +301,8 @@ libxfs_ialloc( + } + + if (pip && (VFS_I(pip)->i_mode & S_ISGID)) { +- ip->i_d.di_gid = pip->i_d.di_gid; ++ if (!(cr->cr_flags & CRED_FORCE_GID)) ++ ip->i_d.di_gid = pip->i_d.di_gid; + if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) + VFS_I(ip)->i_mode |= S_ISGID; + } +diff --git a/mkfs/proto.c b/mkfs/proto.c +index 3bba491..b15f765 100644 +--- a/mkfs/proto.c ++++ b/mkfs/proto.c +@@ -360,7 +360,7 @@ parseproto( + xfs_trans_t *tp; + int val; + int isroot = 0; +- cred_t creds; ++ struct cred creds; + char *value; + struct xfs_name xname; + +@@ -428,6 +428,7 @@ parseproto( + mode |= val; + creds.cr_uid = (int)getnum(getstr(pp), 0, 0, false); + creds.cr_gid = (int)getnum(getstr(pp), 0, 0, false); ++ creds.cr_flags = CRED_FORCE_GID; + xname.name = (unsigned char *)name; + xname.len = name ? strlen(name) : 0; + xname.type = 0; +-- +2.27.0 + diff --git a/xfsprogs.spec b/xfsprogs.spec index e0eb8a4..a6bad0a 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -87,6 +87,7 @@ Patch63: xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch # backport patch from upstream Patch1001: 1001-xfsprogs-gcc10.patch Patch1002: 1002-xfsprogs-add-atomic-write-support.patch +Patch1003: 1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch # End: Anolis customized patches %description @@ -184,6 +185,7 @@ also want to install xfsprogs. %patch63 -p1 %patch1001 -p1 %patch1002 -p1 +%patch1003 -p1 %build export tagname=CC @@ -246,6 +248,7 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* * Thu Jul 27 2023 Weitao Zhou - 5.0.0-11.0.1 - Fix gcc10 -fno-common compile issue for compatible with gcc10 build - Add atomic write support (joseph.qi@linux.aliabba.com) +- mkfs: don't trample the gid set in the protofile (hongnan.li@linux.alibaba.com) * Fri May 19 2023 Pavel Reichl - 5.0.0-11 - Fix ignore autofs mount table entries (#2208391) -- Gitee From 6c2c67b5dc7760fec45e1b62a1330232ec31e4f3 Mon Sep 17 00:00:00 2001 From: HangBo Fan Date: Sun, 17 Jul 2022 12:46:07 +0800 Subject: [PATCH 5/7] spec: add doc sub package --- xfsprogs.spec | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/xfsprogs.spec b/xfsprogs.spec index a6bad0a..8dcd371 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -11,7 +11,29 @@ BuildRequires: gcc BuildRequires: libtool, gettext, libattr-devel, libuuid-devel BuildRequires: readline-devel, libblkid-devel >= 2.17-0.1.git5e51568 BuildRequires: lvm2-devel, libicu-devel >= 4.6 +Requires: glibc Provides: xfs-cmds +Provides: /usr/sbin/fsck.xfs +Provides: /usr/sbin/mkfs.xfs +Provides: /usr/sbin/xfs_admin +Provides: /usr/sbin/xfs_bmap +Provides: /usr/sbin/xfs_copy +Provides: /usr/sbin/xfs_db +Provides: /usr/sbin/xfs_estimate +Provides: /usr/sbin/xfs_freeze +Provides: /usr/sbin/xfs_fsr +Provides: /usr/sbin/xfs_growfs +Provides: /usr/sbin/xfs_info +Provides: /usr/sbin/xfs_io +Provides: /usr/sbin/xfs_logprint +Provides: /usr/sbin/xfs_mdrestore +Provides: /usr/sbin/xfs_metadump +Provides: /usr/sbin/xfs_mkfile +Provides: /usr/sbin/xfs_ncheck +Provides: /usr/sbin/xfs_quota +Provides: /usr/sbin/xfs_repair +Provides: /usr/sbin/xfs_rtcp +Provides: /usr/sbin/xfs_spaceman Obsoletes: xfs-cmds <= %{version} Provides: xfsprogs-qa-devel Obsoletes: xfsprogs-qa-devel <= %{version} @@ -116,6 +138,14 @@ You should install xfsprogs-devel if you want to develop XFS filesystem-specific programs, If you install xfsprogs-devel, you'll also want to install xfsprogs. +%package doc +Summary: Documents for %{name} +BuildArch: noarch +Requires: %{name} = %{version}-%{release} + +%description doc +Doc pages for %{name}. + %prep %setup -q @@ -220,7 +250,6 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %postun -p /sbin/ldconfig %files -f %{name}.lang -%doc doc/CHANGES README %{_libdir}/*.so.* %{_mandir}/man5/* %{_mandir}/man8/* @@ -244,11 +273,15 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* %{_libdir}/*.so +%files doc +%doc doc/CHANGES README + %changelog * Thu Jul 27 2023 Weitao Zhou - 5.0.0-11.0.1 - Fix gcc10 -fno-common compile issue for compatible with gcc10 build - Add atomic write support (joseph.qi@linux.aliabba.com) - mkfs: don't trample the gid set in the protofile (hongnan.li@linux.alibaba.com) +- Add doc sub package (fanhangbo.fhb@alibaba-inc.com) * Fri May 19 2023 Pavel Reichl - 5.0.0-11 - Fix ignore autofs mount table entries (#2208391) -- Gitee From bf9088c705f0d96773556c7d839b2fd9877cdbec Mon Sep 17 00:00:00 2001 From: Joseph Qi Date: Mon, 21 Nov 2022 14:19:59 +0800 Subject: [PATCH 6/7] fsck: add log replay support Signed-off-by: Joseph Qi --- ...replay-log-if-dirty-during-xfs_repai.patch | 79 +++++++++++++++++++ xfsprogs.spec | 3 + 2 files changed, 82 insertions(+) create mode 100644 1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch diff --git a/1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch b/1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch new file mode 100644 index 0000000..3545484 --- /dev/null +++ b/1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch @@ -0,0 +1,79 @@ +From b51b816e769842f9ef422896f89b0cbbcf230b01 Mon Sep 17 00:00:00 2001 +From: Joseph Qi +Date: Thu, 10 Nov 2022 17:14:42 +0800 +Subject: [PATCH] fsck.xfs: try to replay log if dirty during xfs_repair + +It is possible that when the machine crashes, the fs is in inconsistent +state with the journal log not yet replayed. This can drop the machine +into the rescue shell because currently fsck.xfs does not address the +journal replay, which brings maintenance trouble. + +So try to replay log if it is dirty using mount/umount way which is +suggested in xfs_repair manpage. Note that we only do this for root +device so that we don't want to touch data device. + +Administrators have to enable this feature by systemd command options +fsck.mode=force and fsck.repair=yes. For other options, we leave it +behave like before, e.g. drop to the rescue shell if repair detects +any corruptions and need administators repair manually. + +Signed-off-by: Joseph Qi +--- + fsck/xfs_fsck.sh | 31 +++++++++++++++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) + +diff --git a/fsck/xfs_fsck.sh b/fsck/xfs_fsck.sh +index 6af0f224..768611c7 100755 +--- a/fsck/xfs_fsck.sh ++++ b/fsck/xfs_fsck.sh +@@ -31,10 +31,12 @@ repair2fsck_code() { + + AUTO=false + FORCE=false ++REPLAY=false + while getopts ":aApyf" c + do + case $c in +- a|A|p|y) AUTO=true;; ++ a|A|p) AUTO=true;; ++ y) REPLAY=true;; + f) FORCE=true;; + esac + done +@@ -64,7 +66,32 @@ fi + + if $FORCE; then + xfs_repair -e $DEV +- repair2fsck_code $? ++ error=$? ++ if [ $error -eq 2 ] && [ $REPLAY = true ]; then ++ for x in $(cat /proc/cmdline); do ++ case $x in ++ root=*) ++ ROOT="${x#root=}" ++ ;; ++ rootflags=*) ++ ROOTFLAGS="-o ${x#rootflags=}" ++ ;; ++ esac ++ done ++ ++ test -b "$ROOT" || ROOT=$(blkid -t "$ROOT" -o device) ++ if [ $DEV = $ROOT ]; then ++ echo "Replaying log for $DEV" ++ mkdir -p /tmp/replay_mnt || exit 1 ++ mount $DEV /tmp/replay_mnt $ROOTFLAGS || exit 1 ++ umount /tmp/replay_mnt ++ rm -d /tmp/replay_mnt ++ ++ xfs_repair -e $DEV ++ error=$? ++ fi ++ fi ++ repair2fsck_code $error + exit $? + fi + +-- +2.24.4 + diff --git a/xfsprogs.spec b/xfsprogs.spec index 8dcd371..9b4a0de 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -110,6 +110,7 @@ Patch63: xfsprogs-5.9.0-xfs-ignore-autofs-mount-table-entries.patch Patch1001: 1001-xfsprogs-gcc10.patch Patch1002: 1002-xfsprogs-add-atomic-write-support.patch Patch1003: 1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch +Patch1004: 1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch # End: Anolis customized patches %description @@ -216,6 +217,7 @@ Doc pages for %{name}. %patch1001 -p1 %patch1002 -p1 %patch1003 -p1 +%patch1004 -p1 %build export tagname=CC @@ -282,6 +284,7 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* - Add atomic write support (joseph.qi@linux.aliabba.com) - mkfs: don't trample the gid set in the protofile (hongnan.li@linux.alibaba.com) - Add doc sub package (fanhangbo.fhb@alibaba-inc.com) +- Add fsck log replay support (joseph.qi@linux.aliabba.com) * Fri May 19 2023 Pavel Reichl - 5.0.0-11 - Fix ignore autofs mount table entries (#2208391) -- Gitee From 56d4d290522a5d18f5db536034f2783f1931524b Mon Sep 17 00:00:00 2001 From: Ferry Meng Date: Mon, 24 Apr 2023 19:21:36 +0800 Subject: [PATCH 7/7] xfsprogs: bug fix about mkfs.xfs & xfs_repair. backporting four patches to fix bugs. - mkfs.xfs: terminate getsubopt arrays properly - mkfs.xfs: fix internal logs - xfs_repair: ignore empty xattr leaf blocks Signed-off-by: Ferry Meng --- ...-terminate-getsubopt-arrays-properly.patch | 112 ++++++++++++++++++ ...epair-ignore-empty-xattr-leaf-blocks.patch | 56 +++++++++ ...-validation-of-l-size-against-maximu.patch | 92 ++++++++++++++ ...nternal-logs-bump-the-root-dir-inode.patch | 105 ++++++++++++++++ xfsprogs.spec | 11 ++ 5 files changed, 376 insertions(+) create mode 100644 1005-mkfs-terminate-getsubopt-arrays-properly.patch create mode 100644 1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch create mode 100644 1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch create mode 100644 1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch diff --git a/1005-mkfs-terminate-getsubopt-arrays-properly.patch b/1005-mkfs-terminate-getsubopt-arrays-properly.patch new file mode 100644 index 0000000..7d0daa7 --- /dev/null +++ b/1005-mkfs-terminate-getsubopt-arrays-properly.patch @@ -0,0 +1,112 @@ +From e3f705d0c461689fcfd36e405c61df39d9a83e0b Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Wed, 13 Jul 2022 20:58:28 -0500 +Subject: [PATCH 1005/1008] mkfs: terminate getsubopt arrays properly + +Having not drank any (or maybe too much) coffee this morning, I typed: + +$ mkfs.xfs -d agcount=3 -d nrext64=0 +Segmentation fault + +I traced this down to getsubopt walking off the end of the dopts.subopts +array. The manpage says you're supposed to terminate the suboptions +string array with a NULL entry, but the structure definition uses +MAX_SUBOPTS/D_MAX_OPTS directly, which means there is no terminator. + +Explicitly terminate each suboption array with a NULL entry after +making room for it. + +Signed-off-by: Darrick J. Wong +[sandeen: explicitly add NULL terminators & clarify comment] +Reviewed-by: Eric Sandeen +Signed-off-by: Eric Sandeen +Signed-off-by: Ferry Meng +Reviewed-by: Joseph Qi +--- + mkfs/xfs_mkfs.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c +index 36360ba7..37747698 100644 +--- a/mkfs/xfs_mkfs.c ++++ b/mkfs/xfs_mkfs.c +@@ -122,8 +122,11 @@ enum { + M_MAX_OPTS, + }; + +-/* Just define the max options array size manually right now */ +-#define MAX_SUBOPTS D_MAX_OPTS ++/* ++ * Just define the max options array size manually to the largest ++ * enum right now, leaving room for a NULL terminator at the end ++ */ ++#define MAX_SUBOPTS (D_MAX_OPTS + 1) + + #define SUBOPT_NEEDS_VAL (-1LL) + #define MAX_CONFLICTS 8 +@@ -224,6 +227,7 @@ static struct opt_params bopts = { + .name = 'b', + .subopts = { + [B_SIZE] = "size", ++ [B_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = B_SIZE, +@@ -255,6 +259,7 @@ static struct opt_params dopts = { + [D_PROJINHERIT] = "projinherit", + [D_EXTSZINHERIT] = "extszinherit", + [D_COWEXTSIZE] = "cowextsize", ++ [D_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = D_AGCOUNT, +@@ -384,6 +389,7 @@ static struct opt_params iopts = { + [I_ATTR] = "attr", + [I_PROJID32BIT] = "projid32bit", + [I_SPINODES] = "sparse", ++ [I_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = I_ALIGN, +@@ -449,6 +455,7 @@ static struct opt_params lopts = { + [L_FILE] = "file", + [L_NAME] = "name", + [L_LAZYSBCNTR] = "lazy-count", ++ [L_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = L_AGNUM, +@@ -540,6 +547,7 @@ static struct opt_params nopts = { + [N_SIZE] = "size", + [N_VERSION] = "version", + [N_FTYPE] = "ftype", ++ [N_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = N_SIZE, +@@ -574,6 +582,7 @@ static struct opt_params ropts = { + [R_FILE] = "file", + [R_NAME] = "name", + [R_NOALIGN] = "noalign", ++ [R_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = R_EXTSIZE, +@@ -620,6 +629,7 @@ static struct opt_params sopts = { + .subopts = { + [S_SIZE] = "size", + [S_SECTSIZE] = "sectsize", ++ [S_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = S_SIZE, +@@ -655,6 +665,7 @@ static struct opt_params mopts = { + [M_REFLINK] = "reflink", + [M_INOBTCNT] = "inobtcount", + [M_BIGTIME] = "bigtime", ++ [M_MAX_OPTS] = NULL, + }, + .subopt_params = { + { .index = M_CRC, +-- +2.19.1.6.gb485710b diff --git a/1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch b/1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch new file mode 100644 index 0000000..de7f811 --- /dev/null +++ b/1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch @@ -0,0 +1,56 @@ +From a4b3ccd82a079b63df1630482eaf26c0d4bdf4bc Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Wed, 13 Jul 2022 20:58:25 -0500 +Subject: [PATCH 1006/1008] xfs_repair: ignore empty xattr leaf blocks + +As detailed in the commit: + +5e572d1a xfs: empty xattr leaf header blocks are not corruption + +empty xattr leaf blocks can be the benign byproduct of the system +going down during the multi-step process of adding a large xattr +to a file that has no xattrs. If we find one at attr fork offset 0, +we should clear it, but this isn't a corruption. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Dave Chinner +Signed-off-by: Eric Sandeen +Signed-off-by: Ferry Meng +Reviewed-by: Joseph Qi +--- + repair/attr_repair.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/repair/attr_repair.c b/repair/attr_repair.c +index 5ad81c09..8cd9e2de 100644 +--- a/repair/attr_repair.c ++++ b/repair/attr_repair.c +@@ -584,6 +584,26 @@ process_leaf_attr_block( + firstb = mp->m_sb.sb_blocksize; + stop = xfs_attr3_leaf_hdr_size(leaf); + ++ /* ++ * Empty leaf blocks at offset zero can occur as a race between ++ * setxattr and the system going down, so we only take action if we're ++ * running in modify mode. See xfs_attr3_leaf_verify for details of ++ * how we've screwed this up many times. ++ */ ++ if (!leafhdr.count && da_bno == 0) { ++ if (no_modify) { ++ do_log( ++ _("would clear empty leaf attr block 0, inode %" PRIu64 "\n"), ++ ino); ++ return 0; ++ } ++ ++ do_warn( ++ _("will clear empty leaf attr block 0, inode %" PRIu64 "\n"), ++ ino); ++ return 1; ++ } ++ + /* does the count look sorta valid? */ + if (!leafhdr.count || + leafhdr.count * sizeof(xfs_attr_leaf_entry_t) + stop > +-- +2.19.1.6.gb485710b diff --git a/1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch b/1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch new file mode 100644 index 0000000..68260d2 --- /dev/null +++ b/1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch @@ -0,0 +1,92 @@ +From 65e52d802372dc59d64c719997a7cc05782934e9 Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Mon, 4 Apr 2022 11:29:34 -0700 +Subject: [PATCH 1007/1008] mkfs: fix missing validation of -l size against + maximum internal log size + +If a sysadmin specifies a log size explicitly, we don't actually check +that against the maximum internal log size that we compute for the +default log size computation. We're going to add more validation soon, +so refactor the max internal log blocks into a common variable and +add a check. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Ferry Meng +Reviewed-by: Joseph Qi +--- + mkfs/xfs_mkfs.c | 36 +++++++++++++++++++++++------------- + 1 file changed, 23 insertions(+), 13 deletions(-) + +diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c +index 37747698..c9130805 100644 +--- a/mkfs/xfs_mkfs.c ++++ b/mkfs/xfs_mkfs.c +@@ -3184,6 +3184,7 @@ calculate_log_size( + { + struct xfs_sb *sbp = &mp->m_sb; + int min_logblocks; ++ int max_logblocks; /* absolute max for this AG */ + struct xfs_mount mount; + + /* we need a temporary mount to calculate the minimum log size. */ +@@ -3223,6 +3224,19 @@ _("external log device %lld too small, must be at least %lld blocks\n"), + return; + } + ++ /* ++ * Make sure the log fits wholly within an AG ++ * ++ * XXX: If agf->freeblks ends up as 0 because the log uses all ++ * the free space, it causes the kernel all sorts of problems ++ * with per-ag reservations. Right now just back it off one ++ * block, but there's a whole can of worms here that needs to be ++ * opened to decide what is the valid maximum size of a log in ++ * an AG. ++ */ ++ max_logblocks = libxfs_alloc_ag_max_usable(mp) - 1; ++ ++ + /* internal log - if no size specified, calculate automatically */ + if (!cfg->logblocks) { + if (cfg->dblocks < GIGABYTES(1, cfg->blocklog)) { +@@ -3248,21 +3262,10 @@ _("external log device %lld too small, must be at least %lld blocks\n"), + cfg->logblocks = cfg->logblocks >> cfg->blocklog; + } + +- /* Ensure the chosen size meets minimum log size requirements */ ++ /* Ensure the chosen size fits within log size requirements */ + cfg->logblocks = max(min_logblocks, cfg->logblocks); + +- /* +- * Make sure the log fits wholly within an AG +- * +- * XXX: If agf->freeblks ends up as 0 because the log uses all +- * the free space, it causes the kernel all sorts of problems +- * with per-ag reservations. Right now just back it off one +- * block, but there's a whole can of worms here that needs to be +- * opened to decide what is the valid maximum size of a log in +- * an AG. +- */ +- cfg->logblocks = min(cfg->logblocks, +- libxfs_alloc_ag_max_usable(mp) - 1); ++ cfg->logblocks = min(cfg->logblocks, max_logblocks); + + /* and now clamp the size to the maximum supported size */ + cfg->logblocks = min(cfg->logblocks, XFS_MAX_LOG_BLOCKS); +@@ -3270,6 +3273,13 @@ _("external log device %lld too small, must be at least %lld blocks\n"), + cfg->logblocks = XFS_MAX_LOG_BYTES >> cfg->blocklog; + + validate_log_size(cfg->logblocks, cfg->blocklog, min_logblocks); ++ } else if (cfg->logblocks > max_logblocks) { ++ /* check specified log size */ ++ fprintf(stderr, ++_("internal log size %lld too large, must be less than %d\n"), ++ (long long)cfg->logblocks, ++ max_logblocks); ++ usage(); + } + + if (cfg->logblocks > sbp->sb_agblocks - libxfs_prealloc_blocks(mp)) { +-- +2.19.1.6.gb485710b diff --git a/1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch b/1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch new file mode 100644 index 0000000..dcc2c3b --- /dev/null +++ b/1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch @@ -0,0 +1,105 @@ +From 92f6722af80cee37ddc5aca6955c5fd31ed81322 Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Fri, 11 Mar 2022 17:32:02 -0800 +Subject: [PATCH 1008/1008] mkfs: don't let internal logs bump the root dir + inode chunk to AG 1 + +Currently, we don't let an internal log consume every last block in an +AG. According to the comment, we're doing this to avoid tripping AGF +verifiers if freeblks==0, but on a modern filesystem this isn't +sufficient to avoid problems because we need to have enough space in the +AG to allocate an aligned root inode chunk, if it should be the case +that the log also ends up in AG 0: + +$ truncate -s 6366g /tmp/a ; mkfs.xfs -f /tmp/a -d agcount=3200 -l agnum=0 +meta-data=/tmp/a isize=512 agcount=3200, agsize=521503 blks + = sectsz=512 attr=2, projid32bit=1 + = crc=1 finobt=1, sparse=1, rmapbt=0 + = reflink=1 bigtime=0 inobtcount=0 +data = bsize=4096 blocks=1668808704, imaxpct=5 + = sunit=0 swidth=0 blks +naming =version 2 bsize=4096 ascii-ci=0, ftype=1 +log =internal log bsize=4096 blocks=521492, version=2 + = sectsz=512 sunit=0 blks, lazy-count=1 +realtime =none extsz=4096 blocks=0, rtextents=0 +mkfs.xfs: root inode created in AG 1, not AG 0 + +Therefore, modify the maximum internal log size calculation to constrain +the maximum internal log size so that the aligned inode chunk allocation +will always succeed. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Ferry Meng +Reviewed-by: Joseph Qi +--- + mkfs/xfs_mkfs.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 47 insertions(+) + +diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c +index c9130805..6d0109a8 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, +@@ -3301,6 +3344,10 @@ _("log ag number %lld too large, must be less than %lld\n"), + } 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.19.1.6.gb485710b diff --git a/xfsprogs.spec b/xfsprogs.spec index 9b4a0de..0d81bed 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -111,6 +111,10 @@ Patch1001: 1001-xfsprogs-gcc10.patch Patch1002: 1002-xfsprogs-add-atomic-write-support.patch Patch1003: 1003-mkfs-don-t-trample-the-gid-set-in-the-protofile.patch Patch1004: 1004-fsck.xfs-try-to-replay-log-if-dirty-during-xfs_repai.patch +Patch1005: 1005-mkfs-terminate-getsubopt-arrays-properly.patch +Patch1006: 1006-xfs_repair-ignore-empty-xattr-leaf-blocks.patch +Patch1007: 1007-mkfs-fix-missing-validation-of-l-size-against-maximu.patch +Patch1008: 1008-mkfs-don-t-let-internal-logs-bump-the-root-dir-inode.patch # End: Anolis customized patches %description @@ -218,6 +222,10 @@ Doc pages for %{name}. %patch1002 -p1 %patch1003 -p1 %patch1004 -p1 +%patch1005 -p1 +%patch1006 -p1 +%patch1007 -p1 +%patch1008 -p1 %build export tagname=CC @@ -285,6 +293,9 @@ rm -rf $RPM_BUILD_ROOT/%{_mandir}/man8/xfs_scrub* - mkfs: don't trample the gid set in the protofile (hongnan.li@linux.alibaba.com) - Add doc sub package (fanhangbo.fhb@alibaba-inc.com) - Add fsck log replay support (joseph.qi@linux.aliabba.com) +- mkfs.xfs: terminate getsubopt arrays properly (mengferry@linux.alibaba.com) +- mkfs.xfs: fix internal logs' size (mengferry@linux.alibaba.com) +- xfs_repair: ignore empty xattr leaf blocks (mengferry@linux.alibaba.com) * Fri May 19 2023 Pavel Reichl - 5.0.0-11 - Fix ignore autofs mount table entries (#2208391) -- Gitee