public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ntfs: use base mft_no when looking up base inode for extent record
@ 2026-04-30 11:54 DaeMyung Kang
  2026-05-01 13:04 ` Hyunchul Lee
  2026-05-04 11:00 ` Namjae Jeon
  0 siblings, 2 replies; 3+ messages in thread
From: DaeMyung Kang @ 2026-04-30 11:54 UTC (permalink / raw)
  To: Namjae Jeon, Hyunchul Lee; +Cc: linux-fsdevel, linux-kernel, DaeMyung Kang

When the mft record is an extent record, ntfs_may_write_mft_record()
looks up its base inode in the icache. The hash key passed to
find_inode_nowait() must be the base inode's mft number (na.mft_no,
set just above to MREF_LE(m->base_mft_record)), but the code passes
@mft_no, the extent record's own number.

find_inode_nowait() uses its second argument as the hashval, so the
lookup lands in the wrong bucket and almost always returns NULL.
ntfs_may_write_mft_record() then returns false and the writeback
path (ntfs_write_mft_block()) skips that extent record, leaving the
on-disk copy permanently out of sync with the in-memory one.

The original ilookup5_nowait() call this conversion replaced used
na.mft_no.  Restore that.

Fixes: 115380f9a2f9 ("ntfs: update mft operations")
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
---
 fs/ntfs/mft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 7d989267a82b..ef423303565d 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -833,7 +833,7 @@ static bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const u64 mft_no,
 		vi = igrab(mft_vi);
 		WARN_ON(vi != mft_vi);
 	} else {
-		vi = find_inode_nowait(sb, mft_no, ntfs_test_inode_wb, &na);
+		vi = find_inode_nowait(sb, na.mft_no, ntfs_test_inode_wb, &na);
 		if (na.state == NI_BeingDeleted || na.state == NI_BeingCreated)
 			return false;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ntfs: use base mft_no when looking up base inode for extent record
  2026-04-30 11:54 [PATCH] ntfs: use base mft_no when looking up base inode for extent record DaeMyung Kang
@ 2026-05-01 13:04 ` Hyunchul Lee
  2026-05-04 11:00 ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: Hyunchul Lee @ 2026-05-01 13:04 UTC (permalink / raw)
  To: DaeMyung Kang; +Cc: Namjae Jeon, linux-fsdevel, linux-kernel

2026년 4월 30일 (목) 오후 8:54, DaeMyung Kang <charsyam@gmail.com>님이 작성:
>
> When the mft record is an extent record, ntfs_may_write_mft_record()
> looks up its base inode in the icache. The hash key passed to
> find_inode_nowait() must be the base inode's mft number (na.mft_no,
> set just above to MREF_LE(m->base_mft_record)), but the code passes
> @mft_no, the extent record's own number.
>
> find_inode_nowait() uses its second argument as the hashval, so the
> lookup lands in the wrong bucket and almost always returns NULL.
> ntfs_may_write_mft_record() then returns false and the writeback
> path (ntfs_write_mft_block()) skips that extent record, leaving the
> on-disk copy permanently out of sync with the in-memory one.
>
> The original ilookup5_nowait() call this conversion replaced used
> na.mft_no.  Restore that.
>
> Fixes: 115380f9a2f9 ("ntfs: update mft operations")
> Signed-off-by: DaeMyung Kang <charsyam@gmail.com>

Looks good to me.

Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>


> ---
>  fs/ntfs/mft.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 7d989267a82b..ef423303565d 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -833,7 +833,7 @@ static bool ntfs_may_write_mft_record(struct ntfs_volume *vol, const u64 mft_no,
>                 vi = igrab(mft_vi);
>                 WARN_ON(vi != mft_vi);
>         } else {
> -               vi = find_inode_nowait(sb, mft_no, ntfs_test_inode_wb, &na);
> +               vi = find_inode_nowait(sb, na.mft_no, ntfs_test_inode_wb, &na);
>                 if (na.state == NI_BeingDeleted || na.state == NI_BeingCreated)
>                         return false;
>         }
> --
> 2.43.0
>


--
Thanks,
Hyunchul

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ntfs: use base mft_no when looking up base inode for extent record
  2026-04-30 11:54 [PATCH] ntfs: use base mft_no when looking up base inode for extent record DaeMyung Kang
  2026-05-01 13:04 ` Hyunchul Lee
@ 2026-05-04 11:00 ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2026-05-04 11:00 UTC (permalink / raw)
  To: DaeMyung Kang; +Cc: Hyunchul Lee, linux-fsdevel, linux-kernel

On Thu, Apr 30, 2026 at 8:54 PM DaeMyung Kang <charsyam@gmail.com> wrote:
>
> When the mft record is an extent record, ntfs_may_write_mft_record()
> looks up its base inode in the icache. The hash key passed to
> find_inode_nowait() must be the base inode's mft number (na.mft_no,
> set just above to MREF_LE(m->base_mft_record)), but the code passes
> @mft_no, the extent record's own number.
>
> find_inode_nowait() uses its second argument as the hashval, so the
> lookup lands in the wrong bucket and almost always returns NULL.
> ntfs_may_write_mft_record() then returns false and the writeback
> path (ntfs_write_mft_block()) skips that extent record, leaving the
> on-disk copy permanently out of sync with the in-memory one.
>
> The original ilookup5_nowait() call this conversion replaced used
> na.mft_no.  Restore that.
>
> Fixes: 115380f9a2f9 ("ntfs: update mft operations")
> Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Applied it to #ntfs-next
Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-04 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 11:54 [PATCH] ntfs: use base mft_no when looking up base inode for extent record DaeMyung Kang
2026-05-01 13:04 ` Hyunchul Lee
2026-05-04 11:00 ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox