Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Linux Sector count Fact #81246

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open

Conversation

lukecdavidson
Copy link

SUMMARY

The sectors fact returned is currently incorrect. Leading to the bug #26280. The current method for getting the sectors is to read /size from sysfs (i.e. /sys/block/zram0/size). Linux creates this number assuming the sector size is 512. Ansible then multiplies this sector count by 512 to get the disk size. This will result in a correct disk size, but the sector count is incorrect. This PR fixes the sector count that is returned.

Fixes #26280

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

Module for gathering facts for linux hardware.

ADDITIONAL INFORMATION

Sector count is reported correctly by fdisk fdisk -l /dev/zram0:

Disk /dev/zram0: 8 GiB, 8589934592 bytes, 2097152 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Snippet of a device with block size of 4096 before the change ansible localhost -m setup -a filter='devices'

            "zram0": {
                "holders": [],
                "host": "",
                "links": {
                    "ids": [],
                    "labels": [],
                    "masters": [],
                    "uuids": []
                },
                "model": null,
                "partitions": {},
                "removable": "0",
                "rotational": "0",
                "sas_address": null,
                "sas_device_handle": null,
                "scheduler_mode": "",
                "sectors": "16777216",
                "sectorsize": "4096",
                "size": "8.00 GB",
                "support_discard": "4096",
                "vendor": null,
                "virtual": 1
            }

Device from ansible localhost -m setup -a filter='devices' after the change

            "zram0": {
                "holders": [],
                "host": "",
                "links": {
                    "ids": [],
                    "labels": [],
                    "masters": [],
                    "uuids": []
                },
                "model": null,
                "partitions": {},
                "removable": "0",
                "rotational": "0",
                "sas_address": null,
                "sas_device_handle": null,
                "scheduler_mode": "",
                "sectors": 2097152,
                "sectorsize": "4096",
                "size": "8.00 GB",
                "support_discard": "4096",
                "vendor": null,
                "virtual": 1
            }

Size is still correct and the sector count is now correct.

@ansibot ansibot added needs_triage Needs a first human triage before being processed. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. merge_commit This PR contains at least one merge commit. Please resolve! has_issue labels Jul 13, 2023
@ansibot
Copy link
Contributor

ansibot commented Jul 13, 2023

@lukecdavidson this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Jul 13, 2023
@ansibot ansibot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. labels Jul 13, 2023
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 25, 2023
@ansibot ansibot added the bug This issue/PR relates to a bug. label Aug 8, 2023
@mkrizek mkrizek removed the merge_commit This PR contains at least one merge commit. Please resolve! label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug. has_issue stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disk size still wrong, depending on block size in Linux
4 participants