* [PATCH v2 1/6] ntfs: Inline zero_partial_compressed_page()
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
@ 2026-06-08 21:06 ` Matthew Wilcox (Oracle)
2026-06-09 0:18 ` Hyunchul Lee
2026-06-08 21:06 ` [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page() Matthew Wilcox (Oracle)
` (5 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-06-08 21:06 UTC (permalink / raw)
To: Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm, Namjae Jeon
zero_partial_compressed_page() has one caller and the next commit
will make changes to it that make it inelegant to split across two
functions.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
---
fs/ntfs/compress.c | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index 76bd806b41ed..c904858dff3d 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -96,26 +96,6 @@ void free_compression_buffers(void)
mutex_unlock(&ntfs_cb_lock);
}
-/*
- * zero_partial_compressed_page - zero out of bounds compressed page region
- * @page: page to zero
- * @initialized_size: initialized size of the attribute
- */
-static void zero_partial_compressed_page(struct page *page,
- const s64 initialized_size)
-{
- u8 *kp = page_address(page);
- unsigned int kp_ofs;
-
- ntfs_debug("Zeroing page region outside initialized size.");
- if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
- clear_page(kp);
- return;
- }
- kp_ofs = initialized_size & ~PAGE_MASK;
- memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
-}
-
/*
* handle_bounds_compressed_page - test for&handle out of bounds compressed page
* @page: page to check and handle
@@ -126,8 +106,18 @@ static inline void handle_bounds_compressed_page(struct page *page,
const loff_t i_size, const s64 initialized_size)
{
if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
- (initialized_size < i_size))
- zero_partial_compressed_page(page, initialized_size);
+ (initialized_size < i_size)) {
+ u8 *kp = page_address(page);
+ unsigned int kp_ofs;
+
+ ntfs_debug("Zeroing page region outside initialized size.");
+ if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
+ clear_page(kp);
+ return;
+ }
+ kp_ofs = initialized_size & ~PAGE_MASK;
+ memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
+ }
}
/*
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v2 1/6] ntfs: Inline zero_partial_compressed_page()
2026-06-08 21:06 ` [PATCH v2 1/6] ntfs: Inline zero_partial_compressed_page() Matthew Wilcox (Oracle)
@ 2026-06-09 0:18 ` Hyunchul Lee
0 siblings, 0 replies; 19+ messages in thread
From: Hyunchul Lee @ 2026-06-09 0:18 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Andrew Morton, linux-fsdevel, linux-mm, Namjae Jeon
2026년 6월 9일 (화) 오전 6:07, Matthew Wilcox (Oracle) <willy@infradead.org>님이 작성:
>
> zero_partial_compressed_page() has one caller and the next commit
> will make changes to it that make it inelegant to split across two
> functions.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> fs/ntfs/compress.c | 34 ++++++++++++----------------------
> 1 file changed, 12 insertions(+), 22 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index 76bd806b41ed..c904858dff3d 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -96,26 +96,6 @@ void free_compression_buffers(void)
> mutex_unlock(&ntfs_cb_lock);
> }
>
> -/*
> - * zero_partial_compressed_page - zero out of bounds compressed page region
> - * @page: page to zero
> - * @initialized_size: initialized size of the attribute
> - */
> -static void zero_partial_compressed_page(struct page *page,
> - const s64 initialized_size)
> -{
> - u8 *kp = page_address(page);
> - unsigned int kp_ofs;
> -
> - ntfs_debug("Zeroing page region outside initialized size.");
> - if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
> - clear_page(kp);
> - return;
> - }
> - kp_ofs = initialized_size & ~PAGE_MASK;
> - memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
> -}
> -
> /*
> * handle_bounds_compressed_page - test for&handle out of bounds compressed page
> * @page: page to check and handle
> @@ -126,8 +106,18 @@ static inline void handle_bounds_compressed_page(struct page *page,
> const loff_t i_size, const s64 initialized_size)
> {
> if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
> - (initialized_size < i_size))
> - zero_partial_compressed_page(page, initialized_size);
> + (initialized_size < i_size)) {
> + u8 *kp = page_address(page);
> + unsigned int kp_ofs;
> +
> + ntfs_debug("Zeroing page region outside initialized size.");
> + if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
> + clear_page(kp);
> + return;
> + }
> + kp_ofs = initialized_size & ~PAGE_MASK;
> + memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
> + }
> }
>
> /*
> --
> 2.47.3
>
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
2026-06-08 21:06 ` [PATCH v2 1/6] ntfs: Inline zero_partial_compressed_page() Matthew Wilcox (Oracle)
@ 2026-06-08 21:06 ` Matthew Wilcox (Oracle)
2026-06-09 0:19 ` Hyunchul Lee
2026-06-09 13:17 ` Usama Arif
2026-06-08 21:06 ` [PATCH v2 3/6] ntfs: Use zero_user_segment() " Matthew Wilcox (Oracle)
` (4 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-06-08 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
Nobody is supposed to use page->__folio_index. Use page_offset()
instead, and simplify by working exclusively in loff_t instead of mixing
up loff_t and pgoff_t.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ntfs/compress.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index c904858dff3d..b279f38636d6 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -105,13 +105,14 @@ void free_compression_buffers(void)
static inline void handle_bounds_compressed_page(struct page *page,
const loff_t i_size, const s64 initialized_size)
{
- if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
- (initialized_size < i_size)) {
+ loff_t pos = page_offset(page);
+
+ if ((pos >= initialized_size) && (initialized_size < i_size)) {
u8 *kp = page_address(page);
unsigned int kp_ofs;
ntfs_debug("Zeroing page region outside initialized size.");
- if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
+ if (pos >= initialized_size) {
clear_page(kp);
return;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
2026-06-08 21:06 ` [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page() Matthew Wilcox (Oracle)
@ 2026-06-09 0:19 ` Hyunchul Lee
2026-06-09 13:17 ` Usama Arif
1 sibling, 0 replies; 19+ messages in thread
From: Hyunchul Lee @ 2026-06-09 0:19 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Andrew Morton, linux-fsdevel, linux-mm
2026년 6월 9일 (화) 오전 6:06, Matthew Wilcox (Oracle) <willy@infradead.org>님이 작성:
>
> Nobody is supposed to use page->__folio_index. Use page_offset()
> instead, and simplify by working exclusively in loff_t instead of mixing
> up loff_t and pgoff_t.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> fs/ntfs/compress.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index c904858dff3d..b279f38636d6 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -105,13 +105,14 @@ void free_compression_buffers(void)
> static inline void handle_bounds_compressed_page(struct page *page,
> const loff_t i_size, const s64 initialized_size)
> {
> - if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
> - (initialized_size < i_size)) {
> + loff_t pos = page_offset(page);
> +
> + if ((pos >= initialized_size) && (initialized_size < i_size)) {
> u8 *kp = page_address(page);
> unsigned int kp_ofs;
>
> ntfs_debug("Zeroing page region outside initialized size.");
> - if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
> + if (pos >= initialized_size) {
> clear_page(kp);
> return;
> }
> --
> 2.47.3
>
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
2026-06-08 21:06 ` [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page() Matthew Wilcox (Oracle)
2026-06-09 0:19 ` Hyunchul Lee
@ 2026-06-09 13:17 ` Usama Arif
2026-06-09 14:34 ` Matthew Wilcox
1 sibling, 1 reply; 19+ messages in thread
From: Usama Arif @ 2026-06-09 13:17 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Usama Arif, Andrew Morton, linux-fsdevel, linux-mm
On Mon, 8 Jun 2026 22:06:12 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
> Nobody is supposed to use page->__folio_index. Use page_offset()
> instead, and simplify by working exclusively in loff_t instead of mixing
> up loff_t and pgoff_t.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/ntfs/compress.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index c904858dff3d..b279f38636d6 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -105,13 +105,14 @@ void free_compression_buffers(void)
> static inline void handle_bounds_compressed_page(struct page *page,
> const loff_t i_size, const s64 initialized_size)
> {
> - if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
> - (initialized_size < i_size)) {
> + loff_t pos = page_offset(page);
> +
> + if ((pos >= initialized_size) && (initialized_size < i_size)) {
> u8 *kp = page_address(page);
> unsigned int kp_ofs;
>
> ntfs_debug("Zeroing page region outside initialized size.");
> - if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
> + if (pos >= initialized_size) {
Ah should have raised my comment in patch 3 here.
> clear_page(kp);
> return;
> }
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
2026-06-09 13:17 ` Usama Arif
@ 2026-06-09 14:34 ` Matthew Wilcox
2026-06-09 15:55 ` Usama Arif
0 siblings, 1 reply; 19+ messages in thread
From: Matthew Wilcox @ 2026-06-09 14:34 UTC (permalink / raw)
To: Usama Arif; +Cc: Andrew Morton, linux-fsdevel, linux-mm
[Editing your response to patch 3 into here]
On Tue, Jun 09, 2026 at 06:17:23AM -0700, Usama Arif wrote:
> On Mon, 8 Jun 2026 22:06:12 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
>
> > Nobody is supposed to use page->__folio_index. Use page_offset()
> > instead, and simplify by working exclusively in loff_t instead of mixing
> > up loff_t and pgoff_t.
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> > fs/ntfs/compress.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> > index c904858dff3d..b279f38636d6 100644
> > --- a/fs/ntfs/compress.c
> > +++ b/fs/ntfs/compress.c
> > @@ -105,13 +105,14 @@ void free_compression_buffers(void)
> > static inline void handle_bounds_compressed_page(struct page *page,
> > const loff_t i_size, const s64 initialized_size)
> > {
> > - if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
> > - (initialized_size < i_size)) {
> > + loff_t pos = page_offset(page);
> > +
> > + if ((pos >= initialized_size) && (initialized_size < i_size)) {
> > u8 *kp = page_address(page);
> > unsigned int kp_ofs;
> >
> > ntfs_debug("Zeroing page region outside initialized size.");
> > - if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
> > + if (pos >= initialized_size) {
>
> Is the else branch over here unreacheable as the outer if statement
> already had if ((pos >= initialized_size) &&...
Are you saying my transformation is non-equivalent (and I have
introduced a bug), or are you noting that this is a pre-existing bug?
If the latter, is the error that the else branch exists, or did the
author intend to write a different test?
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
2026-06-09 14:34 ` Matthew Wilcox
@ 2026-06-09 15:55 ` Usama Arif
0 siblings, 0 replies; 19+ messages in thread
From: Usama Arif @ 2026-06-09 15:55 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Andrew Morton, linux-fsdevel, linux-mm
On 09/06/2026 15:34, Matthew Wilcox wrote:
> [Editing your response to patch 3 into here]
>
> On Tue, Jun 09, 2026 at 06:17:23AM -0700, Usama Arif wrote:
>> On Mon, 8 Jun 2026 22:06:12 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
>>
>>> Nobody is supposed to use page->__folio_index. Use page_offset()
>>> instead, and simplify by working exclusively in loff_t instead of mixing
>>> up loff_t and pgoff_t.
>>>
>>> Signed-off-by: Mattinnhew Wilcox (Oracle) <willy@infradead.org>
>>> ---
>>> fs/ntfs/compress.c | 7 ++++---
>>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
>>> index c904858dff3d..b279f38636d6 100644
>>> --- a/fs/ntfs/compress.c
>>> +++ b/fs/ntfs/compress.c
>>> @@ -105,13 +105,14 @@ void free_compression_buffers(void)
>>> static inline void handle_bounds_compressed_page(struct page *page,
>>> const loff_t i_size, const s64 initialized_size)
>>> {
>>> - if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
>>> - (initialized_size < i_size)) {
>>> + loff_t pos = page_offset(page);
>>> +
>>> + if ((pos >= initialized_size) && (initialized_size < i_size)) {
>>> u8 *kp = page_address(page);
>>> unsigned int kp_ofs;
>>>
>>> ntfs_debug("Zeroing page region outside initialized size.");
>>> - if (((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size) {
>>> + if (pos >= initialized_size) {
>>
>> Is the else branch over here unreacheable as the outer if statement
>> already had if ((pos >= initialized_size) &&...
>
> Are you saying my transformation is non-equivalent (and I have
> introduced a bug), or are you noting that this is a pre-existing bug?
>
> If the latter, is the error that the else branch exists, or did the
> author intend to write a different test?
The transformation is non-equivalent.
The original code's outer and inner tests are not the same test.
outer: page->__folio_index >= (initialized_size >> PAGE_SHIFT)
inner: page->__folio_index << PAGE_SHIFT
These differ when initialized_size is not page aligned, because the
outer right-hand side floors and the inner left-hand side doesn't.
After your patch, both the outer test and inner test is:
pos >= initialized_size
I think the fix to make it equivaltent is to relax the outer test
so that it includes PAGE_SIZE (maybe?). i.e. make your outer if
statement to be the below to make it equivalent?
if ((pos + PAGE_SIZE > initialized_size) && (initialized_size < i_size)) {
And then the else branch in your code should hopefully make sense.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 3/6] ntfs: Use zero_user_segment() in handle_bounds_compressed_page()
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
2026-06-08 21:06 ` [PATCH v2 1/6] ntfs: Inline zero_partial_compressed_page() Matthew Wilcox (Oracle)
2026-06-08 21:06 ` [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page() Matthew Wilcox (Oracle)
@ 2026-06-08 21:06 ` Matthew Wilcox (Oracle)
2026-06-09 0:20 ` Hyunchul Lee
2026-06-09 13:07 ` Usama Arif
2026-06-08 21:06 ` [PATCH v2 4/6] ntfs: Remove references to page->__folio_index Matthew Wilcox (Oracle)
` (3 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-06-08 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
This fixes handle_bounds_compressed_page() on highmem memory
as page_address() does not work on memory which has been kmap_local(),
only on kmap() memory.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ntfs/compress.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index b279f38636d6..89067fecf5a0 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -108,16 +108,16 @@ static inline void handle_bounds_compressed_page(struct page *page,
loff_t pos = page_offset(page);
if ((pos >= initialized_size) && (initialized_size < i_size)) {
- u8 *kp = page_address(page);
- unsigned int kp_ofs;
+ size_t offset;
ntfs_debug("Zeroing page region outside initialized size.");
- if (pos >= initialized_size) {
- clear_page(kp);
- return;
- }
- kp_ofs = initialized_size & ~PAGE_MASK;
- memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
+ if (pos >= initialized_size)
+ offset = 0;
+ else
+ offset = offset_in_page(initialized_size);
+ zero_user_segment(page, offset, PAGE_SIZE);
+ } else {
+ flush_dcache_page(page);
}
}
@@ -222,7 +222,6 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
*/
handle_bounds_compressed_page(dp, i_size,
initialized_size);
- flush_dcache_page(dp);
kunmap_local(page_address(dp));
SetPageUptodate(dp);
unlock_page(dp);
@@ -758,7 +757,6 @@ int ntfs_read_compressed_block(struct folio *folio)
*/
handle_bounds_compressed_page(page, i_size,
initialized_size);
- flush_dcache_page(page);
kunmap_local(page_address(page));
SetPageUptodate(page);
unlock_page(page);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v2 3/6] ntfs: Use zero_user_segment() in handle_bounds_compressed_page()
2026-06-08 21:06 ` [PATCH v2 3/6] ntfs: Use zero_user_segment() " Matthew Wilcox (Oracle)
@ 2026-06-09 0:20 ` Hyunchul Lee
2026-06-09 13:07 ` Usama Arif
1 sibling, 0 replies; 19+ messages in thread
From: Hyunchul Lee @ 2026-06-09 0:20 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Andrew Morton, linux-fsdevel, linux-mm, Namjae Jeon
2026년 6월 9일 (화) 오전 6:06, Matthew Wilcox (Oracle) <willy@infradead.org>님이 작성:
>
> This fixes handle_bounds_compressed_page() on highmem memory
> as page_address() does not work on memory which has been kmap_local(),
> only on kmap() memory.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> fs/ntfs/compress.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index b279f38636d6..89067fecf5a0 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -108,16 +108,16 @@ static inline void handle_bounds_compressed_page(struct page *page,
> loff_t pos = page_offset(page);
>
> if ((pos >= initialized_size) && (initialized_size < i_size)) {
> - u8 *kp = page_address(page);
> - unsigned int kp_ofs;
> + size_t offset;
>
> ntfs_debug("Zeroing page region outside initialized size.");
> - if (pos >= initialized_size) {
> - clear_page(kp);
> - return;
> - }
> - kp_ofs = initialized_size & ~PAGE_MASK;
> - memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
> + if (pos >= initialized_size)
> + offset = 0;
> + else
> + offset = offset_in_page(initialized_size);
> + zero_user_segment(page, offset, PAGE_SIZE);
> + } else {
> + flush_dcache_page(page);
> }
> }
>
> @@ -222,7 +222,6 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
> */
> handle_bounds_compressed_page(dp, i_size,
> initialized_size);
> - flush_dcache_page(dp);
> kunmap_local(page_address(dp));
> SetPageUptodate(dp);
> unlock_page(dp);
> @@ -758,7 +757,6 @@ int ntfs_read_compressed_block(struct folio *folio)
> */
> handle_bounds_compressed_page(page, i_size,
> initialized_size);
> - flush_dcache_page(page);
> kunmap_local(page_address(page));
> SetPageUptodate(page);
> unlock_page(page);
> --
> 2.47.3
>
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v2 3/6] ntfs: Use zero_user_segment() in handle_bounds_compressed_page()
2026-06-08 21:06 ` [PATCH v2 3/6] ntfs: Use zero_user_segment() " Matthew Wilcox (Oracle)
2026-06-09 0:20 ` Hyunchul Lee
@ 2026-06-09 13:07 ` Usama Arif
1 sibling, 0 replies; 19+ messages in thread
From: Usama Arif @ 2026-06-09 13:07 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Usama Arif, Andrew Morton, linux-fsdevel, linux-mm
On Mon, 8 Jun 2026 22:06:13 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
> This fixes handle_bounds_compressed_page() on highmem memory
> as page_address() does not work on memory which has been kmap_local(),
> only on kmap() memory.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/ntfs/compress.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index b279f38636d6..89067fecf5a0 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -108,16 +108,16 @@ static inline void handle_bounds_compressed_page(struct page *page,
> loff_t pos = page_offset(page);
>
> if ((pos >= initialized_size) && (initialized_size < i_size)) {
> - u8 *kp = page_address(page);
> - unsigned int kp_ofs;
> + size_t offset;
>
> ntfs_debug("Zeroing page region outside initialized size.");
> - if (pos >= initialized_size) {
> - clear_page(kp);
> - return;
> - }
> - kp_ofs = initialized_size & ~PAGE_MASK;
> - memset(kp + kp_ofs, 0, PAGE_SIZE - kp_ofs);
> + if (pos >= initialized_size)
> + offset = 0;
> + else
> + offset = offset_in_page(initialized_size);
Is the else branch over here unreacheable as the outer if statement
already had if ((pos >= initialized_size) &&...
> + zero_user_segment(page, offset, PAGE_SIZE);
> + } else {
> + flush_dcache_page(page);
> }
> }
>
> @@ -222,7 +222,6 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
> */
> handle_bounds_compressed_page(dp, i_size,
> initialized_size);
> - flush_dcache_page(dp);
> kunmap_local(page_address(dp));
> SetPageUptodate(dp);
> unlock_page(dp);
> @@ -758,7 +757,6 @@ int ntfs_read_compressed_block(struct folio *folio)
> */
> handle_bounds_compressed_page(page, i_size,
> initialized_size);
> - flush_dcache_page(page);
> kunmap_local(page_address(page));
> SetPageUptodate(page);
> unlock_page(page);
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 4/6] ntfs: Remove references to page->__folio_index
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2026-06-08 21:06 ` [PATCH v2 3/6] ntfs: Use zero_user_segment() " Matthew Wilcox (Oracle)
@ 2026-06-08 21:06 ` Matthew Wilcox (Oracle)
2026-06-09 0:22 ` Hyunchul Lee
2026-06-08 21:06 ` [PATCH v2 5/6] show_page_info: Remove printing of page index Matthew Wilcox (Oracle)
` (2 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-06-08 21:06 UTC (permalink / raw)
To: Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm,
Christoph Hellwig, Hyunchul Lee, Namjae Jeon
Pages don't have indexes, folios have indexes. Correct this in
ntfs_read_compressed_block() and also remove a use of page->mapping
while I'm in here. Also convert the calls to unlock_page() and
flush_dcache_page().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Fixes: 495e90fa3348 (ntfs: update attrib operations)
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
---
fs/ntfs/compress.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index 89067fecf5a0..eae0339a8518 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -455,14 +455,14 @@ int ntfs_read_compressed_block(struct folio *folio)
struct page *page = &folio->page;
loff_t i_size;
s64 initialized_size;
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = folio->mapping;
struct ntfs_inode *ni = NTFS_I(mapping->host);
struct ntfs_volume *vol = ni->vol;
struct super_block *sb = vol->sb;
struct runlist_element *rl;
unsigned long flags;
u8 *cb, *cb_pos, *cb_end;
- unsigned long offset, index = page->__folio_index;
+ unsigned long offset, index = folio->index;
u32 cb_size = ni->itype.compressed.block_size;
u64 cb_size_mask = cb_size - 1UL;
s64 vcn;
@@ -811,14 +811,16 @@ int ntfs_read_compressed_block(struct folio *folio)
for (cur_page = 0; cur_page < max_page; cur_page++) {
page = pages[cur_page];
if (page) {
+ folio = page_folio(page);
+
ntfs_error(vol->sb,
"Still have pages left! Terminating them with extreme prejudice. Inode 0x%llx, page index 0x%lx.",
- ni->mft_no, page->__folio_index);
- flush_dcache_page(page);
+ ni->mft_no, folio->index);
+ flush_dcache_folio(folio);
kunmap_local(page_address(page));
- unlock_page(page);
+ folio_unlock(folio);
if (cur_page != xpage)
- put_page(page);
+ folio_put(folio);
pages[cur_page] = NULL;
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v2 4/6] ntfs: Remove references to page->__folio_index
2026-06-08 21:06 ` [PATCH v2 4/6] ntfs: Remove references to page->__folio_index Matthew Wilcox (Oracle)
@ 2026-06-09 0:22 ` Hyunchul Lee
0 siblings, 0 replies; 19+ messages in thread
From: Hyunchul Lee @ 2026-06-09 0:22 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Andrew Morton, linux-fsdevel, linux-mm, Christoph Hellwig,
Namjae Jeon
2026년 6월 9일 (화) 오전 6:06, Matthew Wilcox (Oracle) <willy@infradead.org>님이 작성:
>
> Pages don't have indexes, folios have indexes. Correct this in
> ntfs_read_compressed_block() and also remove a use of page->mapping
> while I'm in here. Also convert the calls to unlock_page() and
> flush_dcache_page().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> Fixes: 495e90fa3348 (ntfs: update attrib operations)
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Hyunchul Lee <hyc.lee@gmail.com>
> Cc: Namjae Jeon <linkinjeon@kernel.org>
> ---
> fs/ntfs/compress.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index 89067fecf5a0..eae0339a8518 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -455,14 +455,14 @@ int ntfs_read_compressed_block(struct folio *folio)
> struct page *page = &folio->page;
> loff_t i_size;
> s64 initialized_size;
> - struct address_space *mapping = page->mapping;
> + struct address_space *mapping = folio->mapping;
> struct ntfs_inode *ni = NTFS_I(mapping->host);
> struct ntfs_volume *vol = ni->vol;
> struct super_block *sb = vol->sb;
> struct runlist_element *rl;
> unsigned long flags;
> u8 *cb, *cb_pos, *cb_end;
> - unsigned long offset, index = page->__folio_index;
> + unsigned long offset, index = folio->index;
> u32 cb_size = ni->itype.compressed.block_size;
> u64 cb_size_mask = cb_size - 1UL;
> s64 vcn;
> @@ -811,14 +811,16 @@ int ntfs_read_compressed_block(struct folio *folio)
> for (cur_page = 0; cur_page < max_page; cur_page++) {
> page = pages[cur_page];
> if (page) {
> + folio = page_folio(page);
> +
> ntfs_error(vol->sb,
> "Still have pages left! Terminating them with extreme prejudice. Inode 0x%llx, page index 0x%lx.",
> - ni->mft_no, page->__folio_index);
> - flush_dcache_page(page);
> + ni->mft_no, folio->index);
> + flush_dcache_folio(folio);
> kunmap_local(page_address(page));
> - unlock_page(page);
> + folio_unlock(folio);
> if (cur_page != xpage)
> - put_page(page);
> + folio_put(folio);
> pages[cur_page] = NULL;
> }
> }
> --
> 2.47.3
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 5/6] show_page_info: Remove printing of page index
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2026-06-08 21:06 ` [PATCH v2 4/6] ntfs: Remove references to page->__folio_index Matthew Wilcox (Oracle)
@ 2026-06-08 21:06 ` Matthew Wilcox (Oracle)
2026-06-09 11:59 ` Ye Liu
2026-06-09 18:44 ` David Hildenbrand (Arm)
2026-06-08 21:06 ` [PATCH v2 6/6] mm: Remove __folio_index Matthew Wilcox (Oracle)
2026-06-09 5:06 ` [PATCH v2 0/6] Remove __folio_index again Namjae Jeon
6 siblings, 2 replies; 19+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-06-08 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm, Ye Liu
Pages don't have indexes, folios have indexes. Just delete it. This
script is going to become increasingly barren unless somebody steps up
to maintain it.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Ye Liu <liuye@kylinos.cn>
---
tools/mm/show_page_info.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/mm/show_page_info.py b/tools/mm/show_page_info.py
index c46d8ea283d7..69094ef50719 100644
--- a/tools/mm/show_page_info.py
+++ b/tools/mm/show_page_info.py
@@ -91,7 +91,6 @@ def show_page_state(page, addr, mm, pid, task):
"Page Virtual": hex(page_to_virt(page).value_()),
"Page Refcount": page._refcount.counter.value_(),
"Page Mapcount": page._mapcount.counter.value_(),
- "Page Index": hex(page.__folio_index.value_()),
"Page Memcg Data": hex(page.memcg_data.value_()),
}
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
2026-06-08 21:06 ` [PATCH v2 5/6] show_page_info: Remove printing of page index Matthew Wilcox (Oracle)
@ 2026-06-09 11:59 ` Ye Liu
2026-06-09 18:44 ` David Hildenbrand (Arm)
1 sibling, 0 replies; 19+ messages in thread
From: Ye Liu @ 2026-06-09 11:59 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-fsdevel, linux-mm
在 2026/6/9 05:06, Matthew Wilcox (Oracle) 写道:
> Pages don't have indexes, folios have indexes. Just delete it. This
> script is going to become increasingly barren unless somebody steps up
> to maintain it.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: Ye Liu <liuye@kylinos.cn>
> ---
> tools/mm/show_page_info.py | 1 -
> 1 file changed, 1 deletion(-)
LGTM, thanks for cleaning this up.
Reviewed-by: Ye Liu <liuye@kylinos.cn>
>
> diff --git a/tools/mm/show_page_info.py b/tools/mm/show_page_info.py
> index c46d8ea283d7..69094ef50719 100644
> --- a/tools/mm/show_page_info.py
> +++ b/tools/mm/show_page_info.py
> @@ -91,7 +91,6 @@ def show_page_state(page, addr, mm, pid, task):
> "Page Virtual": hex(page_to_virt(page).value_()),
> "Page Refcount": page._refcount.counter.value_(),
> "Page Mapcount": page._mapcount.counter.value_(),
> - "Page Index": hex(page.__folio_index.value_()),
> "Page Memcg Data": hex(page.memcg_data.value_()),
> }
>
--
Thanks,
Ye Liu
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
2026-06-08 21:06 ` [PATCH v2 5/6] show_page_info: Remove printing of page index Matthew Wilcox (Oracle)
2026-06-09 11:59 ` Ye Liu
@ 2026-06-09 18:44 ` David Hildenbrand (Arm)
1 sibling, 0 replies; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-09 18:44 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-fsdevel, linux-mm, Ye Liu
On 6/8/26 23:06, Matthew Wilcox (Oracle) wrote:
> Pages don't have indexes, folios have indexes. Just delete it. This
> script is going to become increasingly barren unless somebody steps up
> to maintain it.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: Ye Liu <liuye@kylinos.cn>
> ---
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 6/6] mm: Remove __folio_index
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2026-06-08 21:06 ` [PATCH v2 5/6] show_page_info: Remove printing of page index Matthew Wilcox (Oracle)
@ 2026-06-08 21:06 ` Matthew Wilcox (Oracle)
2026-06-09 18:43 ` David Hildenbrand (Arm)
2026-06-09 5:06 ` [PATCH v2 0/6] Remove __folio_index again Namjae Jeon
6 siblings, 1 reply; 19+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-06-08 21:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
People have been abusing the existence of __folio_index. Since that
was too subtle for them, unname it entirely. Now we can't use it in the
FOLIO_MATCH, TABLE_MATCH and ZPDESC_MATCH macros, but that's OK, since
we don't care whether these fields alias index or some other field.
Also remove page->share since all users have been converted to use
folio->share and I'm absolutely certain somebody will start to access
folio->index through page->share if it's not removed.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/mm_types.h | 7 +------
mm/zpdesc.h | 2 --
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index a308e2c23b82..2f2ba262b963 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -101,10 +101,7 @@ struct page {
struct llist_node pcp_llist;
};
struct address_space *mapping;
- union {
- pgoff_t __folio_index; /* Our offset within mapping. */
- unsigned long share; /* share count for fsdax */
- };
+ unsigned long :1; /* formerly index */
/**
* @private: Mapping-private opaque data.
* Usually used for buffer_heads if PagePrivate.
@@ -511,7 +508,6 @@ FOLIO_MATCH(flags, flags);
FOLIO_MATCH(lru, lru);
FOLIO_MATCH(mapping, mapping);
FOLIO_MATCH(compound_info, lru);
-FOLIO_MATCH(__folio_index, index);
FOLIO_MATCH(private, private);
FOLIO_MATCH(_mapcount, _mapcount);
FOLIO_MATCH(_refcount, _refcount);
@@ -612,7 +608,6 @@ TABLE_MATCH(flags, pt_flags);
TABLE_MATCH(compound_info, pt_list);
TABLE_MATCH(compound_info, _pt_pad_1);
TABLE_MATCH(mapping, __page_mapping);
-TABLE_MATCH(__folio_index, pt_index);
TABLE_MATCH(rcu_head, pt_rcu_head);
TABLE_MATCH(page_type, __page_type);
TABLE_MATCH(_refcount, __page_refcount);
diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index b8258dc78548..194392afd3a7 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -54,8 +54,6 @@ struct zpdesc {
ZPDESC_MATCH(flags, flags);
ZPDESC_MATCH(lru, lru);
ZPDESC_MATCH(mapping, movable_ops);
-ZPDESC_MATCH(__folio_index, next);
-ZPDESC_MATCH(__folio_index, handle);
ZPDESC_MATCH(private, zspage);
ZPDESC_MATCH(page_type, first_obj_offset);
ZPDESC_MATCH(_refcount, _refcount);
--
2.47.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v2 6/6] mm: Remove __folio_index
2026-06-08 21:06 ` [PATCH v2 6/6] mm: Remove __folio_index Matthew Wilcox (Oracle)
@ 2026-06-09 18:43 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-09 18:43 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton; +Cc: linux-fsdevel, linux-mm
On 6/8/26 23:06, Matthew Wilcox (Oracle) wrote:
> People have been abusing the existence of __folio_index. Since that
> was too subtle for them, unname it entirely. Now we can't use it in the
> FOLIO_MATCH, TABLE_MATCH and ZPDESC_MATCH macros, but that's OK, since
> we don't care whether these fields alias index or some other field.
> Also remove page->share since all users have been converted to use
> folio->share and I'm absolutely certain somebody will start to access
> folio->index through page->share if it's not removed.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 0/6] Remove __folio_index again
2026-06-08 21:06 [PATCH v2 0/6] Remove __folio_index again Matthew Wilcox (Oracle)
` (5 preceding siblings ...)
2026-06-08 21:06 ` [PATCH v2 6/6] mm: Remove __folio_index Matthew Wilcox (Oracle)
@ 2026-06-09 5:06 ` Namjae Jeon
6 siblings, 0 replies; 19+ messages in thread
From: Namjae Jeon @ 2026-06-09 5:06 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: Andrew Morton, linux-fsdevel, linux-mm
On Tue, Jun 9, 2026 at 6:06 AM Matthew Wilcox (Oracle)
<willy@infradead.org> wrote:
>
> I renamed page->index to page->__folio_index a year ago. That proved to
> be insufficient to prevent people from using it, so take more extreme
> measures to make it inaccessible except through struct folio.
>
> v2:
> - Split patch 1 into patches 1-3
> - Remove inversion of the i_size condition
> - Use page_offset() instead of page_pgoff()
> - Preserve the call to flush_dcache_page() in all circumstances
> - Use offset_in_page() instead of open-coding it
> - Remove shadowing definition of struct folio in patch 4
> - Delete the printing of page->index in show_page_info.py
> - Unname the padding where folio stores index instead of trying to
> create an unguessable name (Arnd)
> - Justify removal of page->share in patch 6
>
> Matthew Wilcox (Oracle) (6):
> ntfs: Inline zero_partial_compressed_page()
> ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
> ntfs: Use zero_user_segment() in handle_bounds_compressed_page()
> ntfs: Remove references to page->__folio_index
> show_page_info: Remove printing of page index
> mm: Remove __folio_index
For ntfs part,
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread