From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796525678; b=ChCWosssOYqC8iIVUP3V8mU9GSp/2Y/n77W0IGg2NhSs+FzRE21NdX/w6SVJe0U1raAm KROzBaK1ZohHtHj/B04ktB/tk/44UmTjDGREhBfgQW5PMjaq9rWeWIebS42iNfWqetwQW EaDV03L8Jsaj+2/hggHeTESK7nk2qxTiyf3BMC5KE3qGxINElEQejxaw4LnBr98CKVfb5 mjpnca8acAoJAIXWGIMLLyBgbleqtc5cwh2L9XrJLnQYnuMFYvbHks8qfpkRwhLkeIOai NZGg2t5gsZP+cGfkyhbRJbBrlnFNRdpaK0sEKyTS7ZUBW3lbBiEUKtF3xjisM9F+jzg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796525678; h=DMARC-Filter:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=VzujnIyHLUHSaod4S4FgKLfzQFj2UXQJbG7YCungiT8=; b=pAvErEbGwEZLi6erAsZkzejd64Wdv29lEPRLHouTbcP7iWiTRz14ZZ4VdizTL3tsJw0q zQcpZg93TvQA4pPbQqMD5ymioqHpAITnsI8VFFVJrUibxruhoh87sOVjsEXzz2OcnNBAk c0MfQ3Nu7/Hr3V23Y6NG+LTR1DIwU4TZ6/V/5ufBttNzOoEp0Z1awNtIU6qkUVdRkkf1R oIlWFfEToNFrMFdpfZVk/HrPGhzHl+vzPpxK3OEGCTuEkhT8NoN+qbRiVT5xF5wQ2UD7/ rq5T12lvfDRIW/+BQIe/TP0XRKn3PoLXjImjWWOmKWqBetSIeJX+dy1hQOhHew3KZQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=NRbgvTVQ; arc=none smtp.remote-ip=220.197.31.4 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4961A606A31F for ; Sun, 6 Dec 2026 02:54:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4961A606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=NRbgvTVQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:To:From: Content-Type; bh=VzujnIyHLUHSaod4S4FgKLfzQFj2UXQJbG7YCungiT8=; b=NRbgvTVQYsG4oej8pD3MGx5PgiU7bsmZ/GEc2bKsn0F12d3l9Tj66GT2OWZn9E +Wga+cXN8/rXio4MvijyTkWR/G6CwAwDSZ3LGROIJ6Gt3u9SiEdbUgCwnnfQmEVY tvVCznH10hKIPk9QqBIhYoTQIm5IVlFxM+WlQPK1Jornw= Message-ID: Date: Sun, 6 Dec 2026 10:53:52 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 0/6] ntfs: synchronize the in-memory size handling To: Hongling Zeng , linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org References: <20261202054112.1138977-1-zenghongling@kylinos.cn> Content-Language: en-US From: liubaolin In-Reply-To: <20261202054112.1138977-1-zenghongling@kylinos.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:PygvCgDnU5dAzhRrjS3EKA--.48851S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxWFyxJr15Kw17Xw4DZrWkWFg_yoWrJFWkpr W2gF9xKr4qv347Krnakr18JFWFgw4rJFyUXry3KF1xAwn3KF13XFWUt340qrWkArZ3tryq yr4DZ34fCr98ZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zR373PUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6QGjbmsUzkEozgAA3z 在 2026/12/2 13:41, Hongling Zeng 写道: > The in-memory size fields of an ntfs inode - data_size, > initialized_size, allocated_size and the compressed size - are > meant to be protected by size_lock, but the iomap readers and the > runtime writers reach them without the lock in several paths, and > the mmap write fault path extends initialized_size without the MFT > record lock every other caller of ntfs_attr_set_initialized_size() > holds. > > The first two patches fix bugs found while auditing those paths: a > resident write whose data can land in an extent record that is > never marked dirty, and a failed write that leaves the attribute > extended. The remaining four close the races: the iomap paths > take a coherent snapshot of initialized_size, the writers publish > the sizes under size_lock, the fault path is serialized with the > MFT record lock, and the mmap prepare path reads initialized_size > under the size lock. > > This series is based on ntfs-next. > > Compile-tested on x86_64. > > Changes in v6: > > - 1/6: trim the comments (Hyunchul Lee). > > - 2/6: snapshot the old allocation only for a non-resident attribute; > a resident allocated_size counts bytes, not clusters. The whole > series carries Hyunchul's reviewed-by. > > Changes in v5: > > - 0002: roll the sizes back with __ntfs_attr_truncate_vfs() and > ntfs_attr_set_data_size(): only the clusters the failed write > allocated are freed, the allocation that predates the write is > preserved (Hyunchul Lee). > > - 0001: carry the inode of the record the lookup found in > iomap->private, and mark that record dirty in iomap_end, after > the data is copied, so a write that failed before copying > anything leaves an unchanged record alone. Point the Fixes tag > at 5aec1efb11ab, the commit that dropped the extent record > dirtying (Hyunchul Lee). > > - Trim the comments across the series (Hyunchul Lee). > > Changes in v4: > > - 0002: leave the folios beyond the old EOF in place when rolling > back an internal attribute: its callers hold the base mft record > lock there, which the folio locks of truncate_setsize() would > invert against. Recompute the modified flag after the rollback, > so a failed write the rollback restored completely does not > update the base file times of a named stream. > > Changes in v3: > > - Rebased onto the rewritten ntfs-next tip. > > - 0004: merge the i_size_write() upstream added to > ntfs_ir_reparent(), kept outside size_lock like the other > i_size_write() calls. > > Changes in v2: > > - 0002: defer the non-resident rollback to > ntfs_inode_attr_pwrite(), which truncates without mrec_lock held, > avoiding a deadlock with writeback. > > - 0003: reuse the first initialized_size snapshot in the length > adjustment, and take size_lock in ntfs_iomap_read_end_io() > (Hyunchul Lee). > > - 0004: hold size_lock across the index root size updates in > ntfs_ir_reparent(). > > Hongling Zeng (6): > ntfs: mark the record dirtied by a resident write in iomap_end > ntfs: roll back the size update when the attribute lookup fails > ntfs: read initialized_size under size_lock in the iomap paths > ntfs: update the in-memory sizes under the size lock > ntfs: serialize the mmap write fault initialized size update > ntfs: read initialized_size under size_lock in the mmap prepare path > > fs/ntfs/aops.c | 3 + > fs/ntfs/attrib.c | 49 ++++++++++++++-- > fs/ntfs/file.c | 11 +++- > fs/ntfs/index.c | 5 ++ > fs/ntfs/inode.c | 143 ++++++++++++++++++++++++++++++++++++++++++----- > fs/ntfs/iomap.c | 67 +++++++++++++++++----- > 6 files changed, 244 insertions(+), 34 deletions(-) > This series looks good to me. Thanks for the work. Reviewed-by: Baolin Liu