Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › Filesystem

What Causes Linux Page-Cache Corruption—and How to Tell a Race From Failing Storage

By Freedom251 Team · · 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Page-cache corruption” is a symptom, not a diagnosis. The page cache is Linux’s normal path for filesystem I/O, so wrong bytes or read errors can originate in a kernel/filesystem race, corrupted RAM or DMA, filesystem metadata and coherency bugs, or a failing device, controller, cable, power path, or firmware. Separate those possibilities by checking repeatability, cache path, kernel and block logs, SMART data, filesystem integrity, and whether the problem follows a kernel/workload or a device and logical block address (LBA).

A successful write does not mean new data is already on the medium. Linux can acknowledge an application write after dirtying a cached page; writeback later sends it to storage, while fsync() is the application’s request for durability. That timing explains many apparent inconsistencies without proving corruption.

As an Amazon Associate I earn from qualifying purchases.

How the page cache works

Linux kernel documentation describes the page cache as “the primary way that the user and the rest of the kernel interact with filesystems.” Ordinary buffered reads, writes, and mmap() accesses use cached memory pages. A read may therefore be served from RAM rather than the device, and a write may update RAM before the corresponding block is written back.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Dirty pages and writeback

When an application writes through the buffered path, the kernel marks the affected page dirty. The application can receive a successful return while the device still contains older data. Background writeback eventually submits the page to the block layer. fsync() (or the appropriate data-synchronization operation) is the application’s durability request; it does not turn a faulty controller, cable, or medium into a reliable one.

The virtual filesystem tracks dirty and writeback state and records writeback errors in file state. An error can therefore surface later than the write that triggered it, sometimes on a subsequent write, flush, or close. Record the exact operation that reported the error instead of assuming it identifies the original fault.

What O_DIRECT changes

O_DIRECT asks the filesystem and block path to bypass the page cache where supported. It has alignment, size, and filesystem-specific restrictions, and it does not bypass the device controller, drive firmware, RAM, or every other cache in the system. A direct read is a useful comparison, not a proof by itself.

What “page-cache corruption” can mean

The same phrase is used for failures at several layers:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Kernel or filesystem race: concurrent truncate, write, mmap(), direct I/O, reflink, or page invalidation can expose stale or wrongly mapped data if a bug exists in a particular kernel/filesystem combination.
  • Memory or DMA corruption: defective RAM, an unreliable memory controller, a bus or device DMA fault, or a CPU problem can alter page contents or page tables before data reaches storage.
  • Filesystem coherency or metadata damage: a crash, software defect, or interrupted update can leave metadata inconsistent, causing the wrong blocks to be read.
  • Storage and I/O-path failure: media errors, a controller reset, link CRC errors, timeouts, power problems, firmware faults, or RAID-layer issues can return bad data or fail writeback.

Because all four can present as incorrect file bytes, an isolated message such as “corrupt page” does not identify the responsible layer.

Race or failing storage? Compare the evidence

Question Evidence favoring a kernel race or memory fault Evidence favoring storage or the I/O path
Reproducibility Nondeterministic, timing-sensitive, or limited to one kernel/filesystem version or workload. Repeatable read or write failure, especially at the same LBA or file offset.
What the failure follows It follows a kernel build, mount option, concurrency pattern, mmap, truncate, reflink, or stress workload. It follows one drive, logical volume, controller port, cable, or LBA when moved or tested elsewhere.
Diagnostics BUG, page-table, KASAN, lockdep, RCU, use-after-free, machine-check, or EDAC reports. Medium, CRC, timeout, reset, transport, controller, or RAID errors in the kernel log; failed SMART tests.
Buffered versus direct reads Cached data is wrong but an aligned direct read after cache eviction returns consistent bytes; this implicates cache or memory handling but does not prove a race. Direct I/O reproduces the same bad bytes or I/O error after cache eviction.
Device health SMART and self-tests remain clean, with no block-layer errors; this only lowers the probability of a drive-media fault. SMART error history or self-tests identify failures or a worsening device condition.
Filesystem check No persistent metadata damage, or damage appears only under the suspect workload. Offline checking finds repeatable metadata or checksum errors that correlate with block errors.

No defensible published statistic establishes what percentage of these incidents are races versus failing storage. Treat the table as a method for weighing evidence, not as a probability calculator.

Investigation procedure

1. Preserve evidence before repairing anything

Make a verified backup or forensic copy if the data is valuable. Save the kernel version and configuration, filesystem type and mount options, device topology, SMART output, and hashes of affected files. Do not run a repair mode or overwrite the suspect volume until the original evidence is protected; repair can change the blocks and logs you need to analyze.

2. Describe the symptom precisely

Write down whether the program observed wrong bytes, EIO, a short read, SIGBUS, a checksum mismatch, or a kernel crash. Record the file offset, length, process, timestamp, kernel version, and whether the access was buffered, memory-mapped, or direct. “The file was corrupt” is too vague to compare with later tests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Repeat through different cache paths

First reread the same region normally and note whether the result changes. If appropriate for the host and workload, let the cache be naturally evicted or perform a controlled diagnostic eviction:

sync
printf 3 | sudo tee /proc/sys/vm/drop_caches

This discards clean page-cache objects and can disrupt a production system, so use it only during a maintenance window and never treat it as a repair. Then perform an aligned direct read using an application that supports direct I/O. A simple diagnostic with GNU dd may look like:

dd if=/path/to/file of=/dev/null iflag=direct bs=4096 status=progress

Block size and offset must satisfy the filesystem and device alignment requirements; an EINVAL result can be an alignment failure rather than evidence of corruption. If buffered and direct results differ, investigate cache coherency, memory, and filesystem interactions while still checking the device path.

4. Correlate kernel, filesystem, and hardware logs

Collect the complete time window from dmesg or the system journal. Look for filesystem warnings and writeback errors, block-layer timeouts or resets, link and CRC reports, controller or RAID messages, and machine-check or EDAC events. A page-cache warning without a block error is not exonerating, and a block reset without a failed SMART test is not exonerating either; correlate timestamps and the affected device.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Run non-destructive device diagnostics

For ATA, SCSI, or NVMe devices, adapt the following smartmontools query to the device type and permissions:

smartctl -H -A -l error -l selftest /dev/sdX

Review the health summary, attributes, error log, and self-test log. Run an appropriate short test first, then an extended test during a maintenance window when the device documentation permits it. If a suspicious LBA range is known, a selective test can target that range. A failed test or a repeatable bad LBA strongly supports a storage-path problem.

A clean SMART result does not certify the entire I/O path: SMART may not expose a bad cable, controller, power supply, RAID layer, firmware interaction, or system RAM. Conversely, a SMART attribute that is merely nonzero must be interpreted using that device family’s definitions and history rather than a generic threshold.

6. Check the filesystem offline

Unmount the volume, boot suitable rescue media if necessary, and run the filesystem-specific checker through the fsck front end. Do not run a repair operation on a mounted filesystem unless that filesystem’s documentation explicitly permits it. Offline checking can reveal metadata inconsistency, but it cannot prove whether the original trigger was a crash, a software race, bad RAM, or failed storage; it is a state assessment and, in repair mode, a destructive change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

7. Reproduce while changing one variable

Use a current known-good kernel and keep the filesystem, device, and workload constant. Then disable the suspected feature or concurrency pattern, move a copy of the file to known-good storage, or test the controller and memory path separately. Interpret the direction of movement:

  • If the failure disappears with a kernel change or follows a specific workload, a software race or memory interaction becomes more likely.
  • If it follows the drive, controller port, RAID member, or LBA, storage or the I/O path becomes more likely.
  • If it appears on multiple independent systems at the same sector, suspect the medium or the data source rather than one host’s page cache.

Change one variable per run and retain hashes and logs; changing the kernel, cable, filesystem, and workload simultaneously destroys the comparison.

8. Use targeted kernel diagnostics for suspected races

Where supported, page-table checking performs synchronous validation and can stop close to an invalid mapping instead of crashing much later. That tighter timing can make a memory-corruption bug easier to associate with the offending operation, although it adds overhead and may expose a crash that would otherwise remain latent.

LKDTM can deliberately inject faults in a controlled test environment to verify that crash-dump collection and alerting work. It is a fault-injection facility, not a production diagnosis and not evidence that the original incident had the same cause.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

9. Escalate with a minimal reproducer

For a kernel or filesystem bug report, include the exact kernel release and configuration, filesystem and mount options, hardware topology, workload and concurrency, file offsets, buffered-versus-direct results, timestamps, complete relevant logs, SMART output, filesystem-check results, and any trace, warning, or crash dump. A small reproducer that fails on one kernel and not another is more valuable than a broad claim that “the cache corrupted a file.”

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to read common outcomes

Direct I/O is clean while buffered I/O is wrong

This pattern raises suspicion of stale cached pages, an invalid mapping, memory corruption, or a filesystem coherency bug. It does not eliminate a device problem: direct and buffered operations can exercise different request sizes, timing, and error paths. Repeat after cache eviction, compare hashes, and inspect kernel diagnostics before assigning blame.

Both paths fail at the same location

Matching bytes or errors at a stable LBA, especially with block-layer messages or a failed self-test, points toward the medium or I/O path. Preserve the data and avoid repeated destructive writes while you arrange replacement or imaging.

The file changes after a successful write and reboot

Check whether the application issued and successfully completed fsync() or an equivalent durability operation, and inspect writeback errors. A write acknowledged before writeback is not proof that the new contents reached stable storage. If the post-reboot contents are inconsistent despite successful durability calls, correlate filesystem, block, controller, and power-event logs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Filesystem checking reports errors after a crash

That result establishes that the filesystem’s current metadata needs attention; it does not identify whether the initiating event was an unclean shutdown, software defect, memory fault, or storage error. Preserve a copy, repair only with a recovery plan, and compare the checker’s findings with block and SMART evidence.

Limits of individual tests

  • SMART: valuable drive-level evidence, but not a complete test of cables, controllers, firmware, RAID, power, or RAM.
  • O_DIRECT: a cache-path comparison with alignment and filesystem caveats, not a guarantee that every cache layer was bypassed.
  • Dropping caches: changes timing and memory pressure and can make a race disappear or appear; it is diagnostic only.
  • fsck: assesses or repairs filesystem state offline; it cannot reconstruct the original cause by itself.
  • One clean reread: insufficient to clear a device or memory subsystem when the fault is intermittent.

A practical decision framework

  1. Back up and capture logs, hashes, versions, mount options, and device diagnostics.
  2. Classify the symptom and compare buffered, evicted-cache, and supported direct reads.
  3. Match timestamps against filesystem, block, controller, machine-check, and EDAC messages.
  4. Run non-destructive SMART and self-tests, then perform an offline filesystem check.
  5. Repeat with one controlled change at a time: kernel, workload feature, cable or port, device, memory, or controller.
  6. Choose the next action from the strongest evidence: isolate or replace storage for stable LBA/media evidence; bisect or report a kernel/filesystem issue for version- and workload-specific failures; test RAM and DMA paths when machine-check or EDAC evidence exists.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

FilesystemKernel debuggingLinuxpage cacheSMARTstorage troubleshooting

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.