From: liubaolin <liubaolin12138@163.com>
To: Matthias Goergens <matthias.goergens@gmail.com>,
Namjae Jeon <linkinjeon@kernel.org>,
Hyunchul Lee <hyc.lee@gmail.com>
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] ntfs: set the attribute list size before reserving space for it
Date: Mon, 28 Sep 2026 02:11:16 +0800 [thread overview]
Message-ID: <e3c533d3-6f76-4fd4-bbeb-932f81b39920@163.com> (raw)
In-Reply-To: <a3db61194cd4c2a472963aa6d9e9563ceb8efd33.1790503811.git.matthias.goergens@gmail.com>
在 2026/9/27 18:57, Matthias Goergens 写道:
> ntfs_attrlist_update_locked() resizes the attribute list and then, for
> $MFT, tries to reserve the maximum list size. When that allocation
> fails with -ENOSPC it falls back to ntfs_attrlist_repack(), which reads
> the list through ntfs_inode_attr_pread(). The read stops at i_size,
> but i_size is only updated after the reserve, so when the list has just
> grown the repack gets a short read and returns -EIO. Only -ENOSPC from
> the reserve is ignored, so the -EIO fails the $MFT extension and with
> it the file creation that needed a new mft record.
>
> On a 32 MiB volume with 512-byte clusters whose $MFT has a non-resident
> attribute list, 591 of 1500 creations of empty files succeed and the
> rest fail with EIO while 742 KiB is still free:
>
> ntfs: (device vda): ntfs_attrlist_update_locked(): Failed to reserve attribute list space
> ntfs: Failed add attr entry to attrlist
> ntfs: MP update failed
> ntfs: (device vda): ntfs_mft_record_alloc(): Failed to extend mft data allocation.
>
> Update i_size as soon as the list has been resized. File creation then
> goes on until the volume is full and fails with ENOSPC.
>
> Fixes: b1d732e62a5b ("ntfs: repack $MFT/$ATTRIBUTE LIST")
> Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
> ---
> The volume is frag.img from
> https://github.com/matthiasgoergens/linux/tree/reproducer/2026-09-26-ntfs-mft-runlist
> (mft-bootstrap/frag.img.xz); creating empty files on it until one fails
> is enough. Tested with KASAN and lockdep: after the patch the files
> written before the volume filled read back intact after a remount, and
> ntfsfix and ntfsresize --info find nothing wrong with the image.
> ---
> fs/ntfs/attrlist.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs/attrlist.c b/fs/ntfs/attrlist.c
> index 1bbd2bc62c582..62dfb96e31a3c 100644
> --- a/fs/ntfs/attrlist.c
> +++ b/fs/ntfs/attrlist.c
> @@ -252,6 +252,9 @@ int ntfs_attrlist_update_locked(struct ntfs_inode *base_ni,
> return err;
> }
>
> + /* ntfs_attrlist_repack() below reads the list up to i_size. */
> + i_size_write(attr_vi, base_ni->attr_list_size);
> +
> /*
> * Reserve the maximum legal list size while the MFT metadata area is
> * still easy to allocate contiguously. This prevents a later list entry
> @@ -279,8 +282,6 @@ int ntfs_attrlist_update_locked(struct ntfs_inode *base_ni,
> }
> }
>
> - i_size_write(attr_vi, base_ni->attr_list_size);
> -
> if (NInoNonResident(attr_ni) && !NInoAttrListNonResident(base_ni))
> NInoSetAttrListNonResident(base_ni);
>
Looks good to me.
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
next prev parent reply other threads:[~2026-09-27 18:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 10:57 [PATCH 0/3] ntfs: fix spurious EIO and ENOSPC on nearly full volumes Matthias Goergens
2026-09-27 10:57 ` [PATCH 1/3] ntfs: set the attribute list size before reserving space for it Matthias Goergens
2026-09-27 18:11 ` liubaolin [this message]
2026-09-27 10:57 ` [PATCH 2/3] ntfs: restart the zone search when the allocation hint fails Matthias Goergens
2026-09-27 18:06 ` liubaolin
2026-09-27 10:57 ` [PATCH 3/3] ntfs: do not refuse fallocate() when the MFT zone is empty Matthias Goergens
2026-09-27 18:11 ` 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=e3c533d3-6f76-4fd4-bbeb-932f81b39920@163.com \
--to=liubaolin12138@163.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.goergens@gmail.com \
--cc=ntfs@lists.linux.dev \
/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®