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

From: Hyunchul Lee

Date: Mon Nov 30 2026 - 23:45:32 EST


> if (ret) {
> - ntfs_error(sb, "Failed to look up attr %#x", ni->type);
> + int rollback_err;
> +
> + /*
> + * The truncation already happened, so undo it
> + * before returning the error. A resident resize
> + * shrinks the value in place, and the conversion
> + * to non-resident uses FGP_NOWAIT, so it never
> + * sleeps on a folio under mrec_lock.
> + */

Could you trim down comments in this series?

> +static void ntfs_inode_rollback_enlarge(struct inode *vi,
> + struct ntfs_inode *mrec_ni, s64 new_data_size,
> + s64 old_data_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)
> + filemap_invalidate_lock(vi->i_mapping);
> +
> + 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)
> + rollback_err = __ntfs_attr_truncate_vfs(ni, old_data_size,
> + old_data_size);
> + mutex_unlock(&mrec_ni->mrec_lock);
> + if (rollback_err) {
> + /*
> + * The sizes may be inconsistent now.
> + * Mark the volume and sync i_size with
> + * data_size.
> + */
> + read_lock_irqsave(&ni->size_lock, flags);
> + current_data_size = ni->data_size;
> + read_unlock_irqrestore(&ni->size_lock, flags);
> + i_size_write(vi, current_data_size);
> + NVolSetErrors(ni->vol);
> + ntfs_error(vi->i_sb, "Failed to roll back the size update: %d",
> + rollback_err);
> + } else if (current_data_size != new_data_size) {
> + /* A concurrent write took over the extension. */
> + i_size_write(vi, current_data_size);
> + }
> +
> + if (!stream)
> + filemap_invalidate_unlock(vi->i_mapping);
> +}

Could you reuse rollback functions which were introduced by the patch [1]?

[1]: https://lore.kernel.org/ntfs/aw4WTiSNWO7JYxww@hyunchul-PC02/T/#t

--
Thanks,
Hyunchul