mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: dd  <zhongling0719@126.com>
To: "Hyunchul Lee" <hyc.lee@gmail.com>
Cc: "Hongling Zeng" <zenghongling@kylinos.cn>,
	linkinjeon@kernel.org, liubaolin12138@163.com,
	ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re:Re: [PATCH 3/6] ntfs: read initialized_size under size_lock in the iomap paths
Date: Thu, 26 Nov 2026 17:34:45 +0800 (CST)	[thread overview]
Message-ID: <63810a45.6fa0.1a217351ac6.Coremail.zhongling0719@126.com> (raw)
In-Reply-To: <awfxvg7w_i49JxBv@hyunchul-PC02>





At 2026-11-26 16:45:50, "Hyunchul Lee" <hyc.lee@gmail.com> wrote:
>>  	if (!(flags & IOMAP_ZERO) &&
>> -			iomap->type == IOMAP_MAPPED &&
>> -			iomap->offset < ni->initialized_size &&
>> -			iomap->offset + iomap->length > ni->initialized_size) {
>> -		iomap->length = round_up(ni->initialized_size, 1 << inode->i_blkbits) -
>> -			iomap->offset;
>> +			iomap->type == IOMAP_MAPPED) {
>> +		loff_t initialized_size;
>> +
>> +		read_lock_irqsave(&ni->size_lock, irqflags);
>> +		initialized_size = ni->initialized_size;
>> +		read_unlock_irqrestore(&ni->size_lock, irqflags);
>
>Is it safe to read the size again instead of reusing the first one?

No.  The type of the mapping was decided against the first snapshot,
and a concurrent extension in between could clamp a MAPPED extent to a
boundary the type decision never saw.  v2 reuses the first snapshot
for the length adjustment.

>And the size_lock is missing in ntfs_iomap_read_end_io.
You are right, that is a miss: it runs in the bio completion path and holds no
other lock, and on 32-bit the unlocked read can tear.  v2 takes the
size_lock there as well, in the same patch.
Thanks for the review.

>
>-- 
>Thanks,
>Hyunchul

  reply	other threads:[~2026-11-26  9:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  7:35 [PATCH 0/6] ntfs: synchronize the in-memory size handling Hongling Zeng
2026-11-25  7:35 ` [PATCH 1/6] ntfs: mark the record dirtied by a resident write at iomap begin Hongling Zeng
2026-11-26  8:45   ` Hyunchul Lee
2026-11-26  9:31     ` dd
2026-11-25  7:35 ` [PATCH 2/6] ntfs: roll back the size update when the attribute lookup fails Hongling Zeng
2026-11-25 14:05   ` liubaolin
2026-11-26  6:34     ` dd
2026-11-25  7:35 ` [PATCH 3/6] ntfs: read initialized_size under size_lock in the iomap paths Hongling Zeng
2026-11-25 14:07   ` liubaolin
2026-11-26  8:45   ` Hyunchul Lee
2026-11-26  9:34     ` dd [this message]
2026-11-25  7:35 ` [PATCH 4/6] ntfs: update the in-memory sizes under the size lock Hongling Zeng
2026-11-25 14:08   ` liubaolin
2026-11-25  7:35 ` [PATCH 5/6] ntfs: serialize the mmap write fault initialized size update Hongling Zeng
2026-11-25 14:08   ` liubaolin
2026-11-25  7:35 ` [PATCH 6/6] ntfs: read initialized_size under size_lock in the mmap prepare path Hongling Zeng
2026-11-25 14:08   ` 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=63810a45.6fa0.1a217351ac6.Coremail.zhongling0719@126.com \
    --to=zhongling0719@126.com \
    --cc=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®