#3647 PR merged: Skip unsupported mkfs.xfs -i sparse= on older xfsprogs¶
Labels: enhancement, bug, fixed / solved / done
sebastian-koehler opened issue at 2026-10-01 17:19:¶
-
Type: Bug Fix
-
Impact: High —
rear recovercurrently fails to (re)create the root filesystem at all on any target whosemkfs.xfspredates-i sparse=support (e.g. RHEL 7.9 / xfsprogs 4.5.0), and the failure isn't a clean abort: the disk-layout-recreation menu just keeps re-running the same failing command forever, which looks like a hang rather than an error. -
Reference to related issue (URL): None filed — found during live end-to-end NBU recovery testing, not tracked as a separate issue.
-
How was this pull request tested?
Reproduced on a real RHEL 7.9 NetBackup client (
xfsprogs/mkfs.xfs4.5.0).rear recoverconsistently failed at the disk-layout-recreation step with:mkfs.xfs -f -m uuid=... -i sparse=0 ... /dev/mapper/rhel-root unknown option -i sparse=0Confirmed via the captured
rear recoverlog andlsblk/xfs_info output thatxfs_infoon this xfsprogs version already reports aspinodesattribute, but the pairedmkfs.xfsbinary doesn't accept-i sparse=at filesystem-creation time — soxfs_parse()was generating an option the localmkfs.xfscan't handle. Validated the fix withbash -n, then deployed it into the live booted rescue environment on the same RHEL 7.9 host for arear recoverretest. -
Description of the changes in this pull request:
Adds
mkfs_xfs_supports_sparse_inodes()tousr/share/rear/lib/filesystems-functions.sh, which probes the target's ownmkfs.xfsusage output (run without a device argument) to check whether it actually supports the-i sparse=suboption, rather than assuming a fixed xfsprogs version cutoff.xfs_parse()now skips emitting-i sparse=...when the probe says it's unsupported, so filesystem recreation falls back tomkfs.xfsdefaults for that option instead of failing outright.The probe matches on a word boundary (
grep -qw 'sparse') rather than a plain substring, so it only fires on the literalsparsesuboption inmkfs.xfs's usage output and can't false-positive on some other option name that merely contains "sparse" as a substring.
codacy-production commented at 2026-10-01 17:20:¶
Up to standards ✅¶
🟢 Issues 0 issues
> > > **Results:** > `0` new issues > > [View in > Codacy](https://app.codacy.com/gh/rear/rear/pull-requests/3647/issues) >
NEW Get contextual insights on your PRs based on Codacy's
metrics, along with PR and Jira context, without leaving GitHub. Enable
AI
reviewer
TIP This summary will be updated as you push new changes.
svlv commented at 2026-10-02 07:15:¶
The sparse option is hanled in filesystems-functions.sh. It was
added by me:
# xfs_info v4.5.0 on RHEL 7 reports 'spinodes' instead of 'sparse'
xfs_param_iname[18]="spinodes"
xfs_param_search[18]="metadata_section"
xfs_param_opt[18]="-i"
xfs_param_name[18]="sparse"
Since we are using a custom rescue system with an updated version of
xfs-progs, the issue was not encountered.
However, mkfs.xfs on RHEL 7 indeed does not support the
-i sparse=0|1 option, which leads to errors during filesystem
recreation.
jsmeix commented at 2026-10-02 10:52:¶
@svlv
thank you for having a look here!
Could you perhaps review the changes here
(as far as time permits)?
Because I am not an XFS user I cannot properly review
XFS specific changes (if at all and provided time permits
I could only check if XFS with defaults works on SLE15).
Here (from plain reading the code) I am in particular
wondering about the spinodes vs sparse confusion
and if now all will be OK with this pull request?
svlv commented at 2026-10-02 11:02:¶
@jsmeix
Could you perhaps review the changes here
(as far as time permits)?
Sure, at first glance and after a quick verification, this change is correct. However, I need some more time to verify it thoroughly.
jsmeix commented at 2026-10-02 11:30:¶
@sebastian-koehler
is there a reason why you placed your new
function mkfs_xfs_supports_sparse_inodes()
in between all those btrfs related functions
and not directly before the xfs_parse function
where mkfs_xfs_supports_sparse_inodes is called?
As far as I see the xfs_parse function is the only place
where mkfs_xfs_supports_sparse_inodes is called
so the mkfs_xfs_supports_sparse_inodes function
might be even better defined nested inside
its only caller function xfs_parse to make clear
that mkfs_xfs_supports_sparse_inodes is not intended
to be used as a global generic function?
On the other hand if mkfs_xfs_supports_sparse_inodes
is intended to be used as a global generic function
then it should not be defined nested in xfs_parse
(regardless that this might even work, see below).
In general regarding nested helper functions
for only one other function see those examples:
In usr/share/rear/lib/layout-functions.sh
the function apply_layout_mappings()
with its nested helper functions
add_replacement() has_replacement() get_replacement()
In usr/share/rear/lib/bootloader-functions.sh
the function make_syslinux_config
with its nested helper functions
syslinux_menu syslinux_menu_help
and the function create_grub2_cfg
with its nested helper functions
create_grub2_serial_entry create_grub2_rear_boot_entry
create_grub2_boot_next_entry create_grub2_reboot_entry
create_grub2_exit_entry
In usr/share/rear/lib/bootloader-functions.sh
note in particular the comment at the end of the
the function create_grub2_cfg function
that nested helper functions must be 'unset'
because bash does not support 'local function ...'
$ function foo () { echo "in foo" ; function nested () { echo "in nested" ; } ; nested ; echo "leaving foo" ; }
$ foo
in foo
in nested
leaving foo
$ type -a nested
nested is a function
nested ()
{
echo "in nested"
}
$ unset -f foo nested
$ function foo () { echo "in foo" ; function nested () { echo "in nested" ; } ; nested ; echo "leaving foo" ; unset -f nested ; }
$ foo
in foo
in nested
leaving foo
$ type -a nested
bash: type: nested: not found
Only in the special case that a function which is meant
to be used as a global generic function but only
provided another function was called before,
the function should be defined nested in that other
(prerequirement) function to ensure the function
cannot be called before its prerequirement function
was called.
See
https://github.com/rear/rear/pull/3648
and
https://github.com/rear/rear/wiki/Coding-Style#functions
svlv commented at 2026-10-02 14:21:¶
Here (from plain reading the code) I am in particular
wondering about the spinodes vs sparse confusion
and if now all will be OK with this pull request?
The problem is that xfs_info reports the sparse feature differently:
as spinodes (a contraction of sparse inodes) on RHEL7, and as sparse
since RHEL8, I believe.
Please compare the output of xfs_info on RHEL7 and RHEL10:
[root@rhel7 ~]# xfs_info /dev/mapper/rhel-root
meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0 <===
data = bsize=4096 blocks=4455424, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
root@rhel10:~# xfs_info /dev/mapper/rhel-root
meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=1665280 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1 <===
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=0
data = bsize=4096 blocks=6661120, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=0
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Since mkfs.xfs uses sparse=0|1, I added the corresponding mapping to
cover both spinodes and sparse.
By the way, the following information is provided in man mkfs.xfs on
RHEL 7:
sparse[=value]
Enable sparse inode chunk allocation.
This experimental option is not available in RHEL7.
jsmeix commented at 2026-10-05 08:38:¶
@rear/contributors
I would like to merge it tomorrow afternoon
unless objections appear.
jsmeix commented at 2026-10-05 08:39:¶
@sebastian-koehler
thank you for your issue report and your fix!
@svlv @gdha
thank you for your review!
[Export of Github issue for rear/rear.]