Re: [RFC PATCH] fs/ntfs3: prevent positive E_NTFS_NONRESIDENT from reaching writeback error handling

From: Vidhu Sarwal

Date: Sat Jul 25 2026 - 00:16:01 EST


On Thu, Jul 23, 2026 at 7:03 PM Jori Koolstra <jkoolstra@xxxxxxxxx> wrote:
>
> Should attr_data_write_resident() be returning positive values on error?
> If this is correct, and this is a matter of data corruption you can use
> EFSCORRUPTED (EIO may also be fine if this is what NTFS uses in other
> places).

Yes. attr_data_write_resident() intentionally returns the positive
internal status code E_NTFS_NONRESIDENT when it detects that the DATA
attribute has become non-resident. This is an ntfs3 specific
used internally to signal the transition rather than a standard errno.

The issue is that ntfs_writepages() propagates this internal status into
the generic writeback error handling without translating it first. The
MM writeback code expects either 0 or a negative errno, so the positive
value triggers the WARN_ON_ONCE(*error > 0).

I chose -EIO because this is not filesystem metadata corruption. The
race is between is_resident() and attr_make_nonresident(), leaving the
filesystem in a valid state but causing an internal status code to
escape outside ntfs3. I think EFSCORRUPTED would imply metadata
corruption, which didnt happen here.

Thanks,
Vidhu