Skip to content

Conversation

@felixfontein
Copy link
Collaborator

SUMMARY

Backport of #11033 to stable-11.

CC @jnaab

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

filesystem

…ns#11033)

Internally XFS uses allocation groups. Allocation groups have a maximum
size of 1 TiB - 1 block. For devices >= 4 TiB XFS uses max size
allocation groups. If a filesystem is extended and the last allocation
group is already at max size, a new allocation group is added. An
allocation group seems to require at least 64 4 KiB blocks.

For devices with integer TiB size (>4), this creates a filesystem that
has initially has 1 unused block per TiB size. The `resize` option
detects this unused space, and tries to resize the filesystem.  The
xfs_growfs call is successful (exit 0), but does not increase the file
system size. This is detected as repeated change in the task.

Test case:
```
- hosts: localhost
  tasks:
    - ansible.builtin.command:
        cmd: truncate -s 4T /media/xfs.img
        creates: /media/xfs.img
      notify: loopdev xfs

    - ansible.builtin.meta: flush_handlers

    - name: pickup xfs.img resize
      ansible.builtin.command:
        cmd: losetup -c /dev/loop0
      changed_when: false

    - community.general.filesystem:
        dev: "/dev/loop0"
        fstype: "xfs"

    - ansible.posix.mount:
        src: "/dev/loop0"
        fstype: "xfs"
        path: "/media/xfs"
        state: "mounted"

    # always shows a diff even for newly created filesystems
    - community.general.filesystem:
        dev: "/dev/loop0"
        fstype: "xfs"
        resizefs: true

  handlers:
    - name: loopdev xfs
      ansible.builtin.command:
        cmd: losetup /dev/loop0 /media/xfs.img
```

NB: If the last allocation group is not yet at max size, the filesystem
can be resized. Detecting this requires considering the XFS topology.
Other filesystems (at least ext4) also seem to require a minimum
increment after the initial device size, but seem to use the entire
device after initial creation.

Fun observation: creating a 64(+) TiB filesystem leaves a 64(+) block
gap at the end, that is allocated in a subsequent xfs_growfs call.

Co-authored-by: Johannes Naab <[email protected]>
(cherry picked from commit f594320)
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug module module plugins plugin (any type) labels Nov 7, 2025
@felixfontein felixfontein merged commit dce8b50 into ansible-collections:stable-11 Nov 8, 2025
156 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug This issue/PR relates to a bug module module plugins plugin (any type)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants