Skip to content

Fix AIX inode collection: use correct df format and include NFS mounts - #3409

Merged
dbwiddis merged 4 commits into
oshi:masterfrom
jank:fix/aix-filesystem-inode-df-command
Jun 26, 2026
Merged

dbwiddis merged 4 commits into
oshi:masterfrom
jank:fix/aix-filesystem-inode-df-command

Conversation

@jank

@jank jank commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

`AixFileSystem.getFileStoreMatching()` has two bugs in its inode-data collection step that affect AIX systems in production:

1. Wrong `df` command. The code ran `df -i`, which is a Linux/POSIX flag that does not exist on AIX. The AIX-native equivalent is `df -F %n %l` (format specifiers: `%n` = free file nodes / Ifree, `%l` = used file nodes / Iused). On real AIX hosts, `df -i` either fails or produces no parseable inode output, causing all file stores to report 0 inodes.

Note: the format string must not be quoted. `df -F "%n %l"` (with shell quotes) causes AIX to treat the entire string as a single specifier, silently dropping `%l` and outputting only the Ifree column.

2. NFS mounts silently dropped. The inode-data loop filtered with `line.startsWith("/")`. On AIX, NFS entries in `df` output appear as `hostname:/path` or `192.168.x.x:/path`, which do not start with `/`. All NFS file stores therefore reported 0 inodes regardless.

Both issues were observed on AIX 7.x production systems.

Fix

  • Switch to `df -F %n %l` (AIX-native inode format, unquoted); use `-T local` instead of `-l` for local-only filtering.
  • Replace `line.startsWith("/")` with a regex `^(?:[\w.]+:)?/` that matches both local device paths (`/dev/hd4`) and NFS `host:/path` entries.
  • Fix column parsing: `df -F %n %l` always emits four columns (Filesystem, 512-blocks, Ifree, Iused); parse Ifree as `split[length-2]` and Iused as `split[length-1]`, and tighten the guard to `>= 4`.
  • Correct a free/used swap: the previous relative-index code assigned Ifree to `used` and Iused to `free`, so `inodeFreeMap` was populated with the used count.
  • Update the sample output comment to reflect actual `df -F %n %l` output from an AIX 7.2 host.

Testing

AIX is not in CI. Manual verification on AIX 7.2 confirms that:

  • Local file stores now show correct non-zero inode counts.
  • `/proc` (which outputs `-` for all columns) is handled gracefully via `ParseUtil.parseLongOrDefault` returning 0L.
  • NFS-mounted file stores are no longer silently skipped.

Summary by CodeRabbit

  • Bug Fixes

    • Improved filesystem inode reporting on AIX by enhancing how filesystem/mount output is detected and matched, leading to more accurate inode statistics.
    • Fixed inode free/used/total calculation for matched filesystems, improving the correctness of disk usage details shown in system reports.
  • Documentation

    • Updated the 7.3.2 changelog with a dedicated entry describing the AIX inode reporting fix.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b7bf3b38-1fba-4683-9d04-23ed1e126cc5

📥 Commits

Reviewing files that changed from the base of the PR and between fa9825a and d41f7cf.

📒 Files selected for processing (1)
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Codacy Static Code Analysis

📝 Walkthrough

Walkthrough

AixFileSystem switches AIX inode collection to regex-filtered df -F parsing, computes total and free inode counts from parsed fields, and adds a 7.3.2 changelog entry for the fix.

Changes

AIX filesystem inode parsing

Layer / File(s) Summary
Regex-based inode parsing
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java, CHANGELOG.md
Adds Pattern support and a filesystem regex, replaces df -i parsing with df -F %n %l inode parsing in getFileStoreMatching, and documents the fix in the 7.3.2 changelog section.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit sniffed the df trail,
Found regex tracks without a fail.
Free and used in tidy sight,
Changelog tucked in warm moonlight.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main AIX inode collection fix and NFS mount handling changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java`:
- Around line 73-79: The inode parsing in AixFileSystem is mapping the AIX df -F
columns backwards: split[length - 2] should populate the used inode count and
split[length - 1] should populate the free inode count according to the "%l %n"
output order. Update the assignments in the FS_PATTERN parsing block so
inodeTotalMap still uses used + free, but inodeFreeMap stores the value from the
free-inodes column, keeping the logic aligned with ParseUtil.split and the AIX
df -F format.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5f687786-723f-410a-9a59-b50c0afa9a7e

📥 Commits

Reviewing files that changed from the base of the PR and between 3968ba0 and 621b233.

📒 Files selected for processing (1)
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
🔇 Additional comments (1)
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java (1)

13-13: LGTM!

Also applies to: 44-44, 58-59, 73-75

@jank

jank commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor Author

I will do another round of review on AIX regarding parsing of the df results and post my findings here.
AIX behavior confirmed on test system. df -F "%n %l" silently swallows the 2nd formatting option. Because the 512-blocks column is always shown this got misinterpreted.
Correction is to us df -F %n %l.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 3-5: The changelog heading hierarchy is inconsistent because the
current subsection uses a fifth-level heading and skips levels from the section
above. Update the heading under the top-level changelog section in CHANGELOG.md
to a second-level heading so it matches the existing hierarchy and avoids
triggering markdownlint heading-increment, keeping the “Bug Fixes and
Improvements” section aligned with the rest of the document.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 70f9a5d3-e3e7-4972-ae96-4ce31bb151bd

📥 Commits

Reviewing files that changed from the base of the PR and between 4eb2c28 and fa9825a.

📒 Files selected for processing (1)
  • CHANGELOG.md
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🪛 markdownlint-cli2 (0.22.1)
CHANGELOG.md

[warning] 3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h5

(MD001, heading-increment)

Comment thread CHANGELOG.md Resolved
@dbwiddis

Copy link
Copy Markdown
Member

Thanks for the fix!

AIX is not in CI. Manual verification on AIX 7.2 ...

We do test AIX in the cfarm GitHub workflow, although that only runs on push to master.

Still, it represents a missing test or incorrect assumption.

@codecov

codecov Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.00%. Comparing base (38cce21) to head (d41f7cf).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3409      +/-   ##
============================================
- Coverage     75.04%   75.00%   -0.05%     
  Complexity       76       76              
============================================
  Files           579      579              
  Lines         21353    21353              
  Branches       3554     3554              
============================================
- Hits          16025    16016       -9     
+ Misses         3305     3304       -1     
- Partials       2023     2033      +10     
Flag Coverage Δ
freebsd 26.32% <ø> (-0.01%) ⬇️
linux 30.88% <ø> (-0.03%) ⬇️
macos 31.25% <ø> (ø)
openbsd 25.79% <ø> (-0.01%) ⬇️
solaris 27.87% <ø> (ø)
windows 39.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis

dbwiddis commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

1. Wrong df command. The code ran df -i, which is a Linux/POSIX flag that does not exist on AIX. The AIX-native equivalent is df -F %n %l (format specifiers: %n = free file nodes / Ifree, %l = used file nodes / Iused). On real AIX hosts, df -i either fails or produces no parseable inode output, causing all file stores to report 0 inodes.

This may be true on AIX 7.1 and 7.2. The only AIX access I have is the GCC Compile Farm machine which runs AIX 7.3:

$ ssh aix
Last login: Wed Jun 17 04:41:16 CUT 2026 on ssh from 20.172.37.236
*******************************************************************************
*                                                                             *
*                                                                             *
*  Welcome to AIX Version 7.3!                                                *
*                                                                             *
*                                                                             *
*  Please see the README file in /usr/lpp/bos for information pertinent to    *
*  this release of the AIX Operating System.                                  *
*                                                                             *
*                                                                             *
*  Add /opt/freeware/bin to $PATH for additional FOSS software.               *
*                                                                             *
*                                                                             *
*******************************************************************************

$ df -i
Filesystem    512-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4         8388608   7200008   15%     3279     1% /
/dev/hd2         6160384    523360   92%    45819    36% /usr
/dev/hd9var      5767168   5319792    8%     1301     1% /var
/dev/hd3         5767168   5605376    3%     6544     2% /tmp
/dev/hd1          131072    130304    1%        9     1% /homehd1
/dev/hd11admin     262144    261384    1%        5     1% /admin
/proc                  -         -    -        -      - /proc
/dev/hd10opt    11796480   1861416   85%    35223    12% /opt
/dev/livedump     524288    523552    1%        4     1% /var/adm/ras/livedump
/dev/hd01      880803840 118251768   87%  7816806    30% /home
/ahafs                 -         -    -       35     1% /aha
/dev/ramdisk0  134217728  56321920   59%   739489    10% /scratch

The proposed replacement seems to produce the appropriate output:

$ df -F %n %l
Filesystem    512-blocks     Ifree    Iused
/dev/hd4         8388608   839601     3279 
/dev/hd2         6160384    81996    45819 
/dev/hd9var      5767168   594103     1301 
/dev/hd3         5767168   634579     6544 
/dev/hd1          131072    14565        9 
/dev/hd11admin     262144    29133        5 
/proc                  -        -        - 
/dev/hd10opt    11796480   260337    35223 
/dev/livedump     524288    58200        4 
/dev/hd01      880803840 18662559  7816806 
/ahafs                 -    32733       35 
/dev/ramdisk0  134217728  7470790   739489

Given this block of code is only getting the inode values, it's a reasonable compatibility adjustment: please add a note in a comment about the choice to use this command line for AIX 7.1-7.2 compatibility.

AIX 7.3 added POSIX df -i support; earlier versions only support the
native format-specifier syntax, so df -F %n %l is used for compatibility.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@dbwiddis
dbwiddis merged commit 1985db3 into oshi:master Jun 26, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants