Re:Re: [PATCH 1/6] ntfs: mark the record dirtied by a resident write at iomap begin

From: dd

Date: Thu Nov 26 2026 - 04:32:17 EST






At 2026-11-26 16:45:06, "Hyunchul Lee" <hyc.lee@xxxxxxxxx> wrote:
>Hi Hongling,
>
>>
>> + /*
>> + * The record holding a resident attribute can be an extent record.
>> + * Mark the record the lookup found dirty here, while the search
>> + * context still points at it. The writeout of the record cannot
>> + * overtake the inline copy: it is serialized by the mrec_lock held
>> + * until iomap_end.
>> + */
>> + mark_mft_record_dirty(ctx->ntfs_ino);
>> +
>
>If the write fails before the data is copied into the resident
>attribute, the MFT record is still marked dirty and may be written back
>even if its contents have not changed.
>

That can happen, but it is harmless. The mark only sets I_DIRTY_DATASYNC
on the base vfs inode (__mark_mft_record_dirty()), and the record is
written out by __ntfs_write_inode(), which takes the base mrec_lock
before touching any record. The write path holds that lock until
iomap_end, so the writeback cannot see the record mid-copy: in the
failed-write case it writes one record with unchanged contents, in a
write that is already failing. The base record already gets the same
treatment: ntfs_write_iomap_end_resident() marks it dirty regardless of
how much was copied.

Deferring the mark to iomap_end would have to carry the inode of the
record there: begin releases the search context before returning, and
iomap_end only sees the base inode.

Thanks for the review.

--
Hongling
>> a = ctx->attr;
>> /* The total length of the attribute value. */
>> attr_len = le32_to_cpu(a->data.resident.value_length);
>> --
>> 2.25.1
>>
>
>--
>Thanks,
>Hyunchul