mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hyunchul Lee <hyc.lee@gmail.com>
To: Hongling Zeng <zenghongling@kylinos.cn>
Cc: linkinjeon@kernel.org, liubaolin12138@163.com,
	ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 2/6] ntfs: roll back the size update when the attribute lookup fails
Date: Tue, 1 Dec 2026 13:45:24 +0900	[thread overview]
Message-ID: <aw5Q5Mpd5xWCYmqM@hyunchul-PC02> (raw)
In-Reply-To: <20261130030708.59798-3-zenghongling@kylinos.cn>

>  		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

  parent reply	other threads:[~2026-12-01  4:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  3:07 [PATCH v3 0/6] ntfs: synchronize the in-memory size handling Hongling Zeng
2026-11-30  3:07 ` [PATCH v3 1/6] ntfs: mark the record dirtied by a resident write at iomap begin Hongling Zeng
2026-11-30  3:49   ` liubaolin
2026-11-30  3:07 ` [PATCH v3 2/6] ntfs: roll back the size update when the attribute lookup fails Hongling Zeng
2026-11-30  3:49   ` liubaolin
2026-12-01  4:45   ` Hyunchul Lee [this message]
2026-11-30  3:07 ` [PATCH v3 3/6] ntfs: read initialized_size under size_lock in the iomap paths Hongling Zeng
2026-11-30  3:49   ` liubaolin
2026-11-30  3:07 ` [PATCH v3 4/6] ntfs: update the in-memory sizes under the size lock Hongling Zeng
2026-11-30  3:49   ` liubaolin
2026-11-30  3:07 ` [PATCH v3 5/6] ntfs: serialize the mmap write fault initialized size update Hongling Zeng
2026-11-30  3:49   ` liubaolin
2026-11-30  3:07 ` [PATCH v3 6/6] ntfs: read initialized_size under size_lock in the mmap prepare path Hongling Zeng
2026-11-30  3:50   ` liubaolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw5Q5Mpd5xWCYmqM@hyunchul-PC02 \
    --to=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin12138@163.com \
    --cc=ntfs@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zenghongling@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®