Re: [PATCH v5 2/6] ntfs: roll back the size update when the attribute lookup fails

From: Hyunchul Lee

Date: Tue Dec 01 2026 - 19:10:23 EST


> +/* Undo the deferred size update like ntfs_write_rollback() does. */
> +static void ntfs_inode_rollback_enlarge(struct inode *vi,
> + struct ntfs_inode *mrec_ni, s64 new_data_size,
> + s64 old_data_size, s64 old_alloc_size)
> +{
> + struct ntfs_inode *ni = NTFS_I(vi);
> + bool stream = ntfs_inode_is_named_stream(ni);
> + unsigned long flags;
> + s64 current_data_size;
> + int rollback_err = 0;
> +
> + if (stream)
> + truncate_setsize(vi, old_data_size);
> +
> + mutex_lock(&mrec_ni->mrec_lock);
> + read_lock_irqsave(&ni->size_lock, flags);
> + current_data_size = ni->data_size;
> + read_unlock_irqrestore(&ni->size_lock, flags);
> + if (current_data_size == new_data_size) {
> + /* Free only what the write allocated. */
> + s64 keep = max(old_data_size, old_alloc_size);
> +
> + if (ni->allocated_size > keep)
> + rollback_err = __ntfs_attr_truncate_vfs(ni, keep,
> + keep);
> + if (!rollback_err && ni->data_size != old_data_size)
> + rollback_err = ntfs_attr_set_data_size(ni,
> + old_data_size);

I think this part can be extracted into a helper so that both this
rollback path and ntfs_write_rollback() can share it.

Other than that, this series looks good to me.

Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx>

--
Thanks,
Hyunchul