Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Remove __folio_index again
@ 2026-06-08 21:06 Matthew Wilcox (Oracle)
  2026-06-08 21:06 ` [PATCH v2 1/6] ntfs: Inline zero_partial_compressed_page() Matthew Wilcox (Oracle)
                   ` (7 more replies)
  0 siblings, 8 replies; 35+ 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

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

 fs/ntfs/compress.c         | 53 ++++++++++++++++----------------------
 include/linux/mm_types.h   |  7 +----
 mm/zpdesc.h                |  2 --
 tools/mm/show_page_info.py |  1 -
 4 files changed, 23 insertions(+), 40 deletions(-)

-- 
2.47.3



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

* [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)
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 35+ 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] 35+ 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
                     ` (2 more replies)
  2026-06-08 21:06 ` [PATCH v2 3/6] ntfs: Use zero_user_segment() " Matthew Wilcox (Oracle)
                   ` (5 subsequent siblings)
  7 siblings, 3 replies; 35+ 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] 35+ 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
                     ` (2 more replies)
  2026-06-08 21:06 ` [PATCH v2 4/6] ntfs: Remove references to page->__folio_index Matthew Wilcox (Oracle)
                   ` (4 subsequent siblings)
  7 siblings, 3 replies; 35+ 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] 35+ 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)
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 35+ 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] 35+ 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
                     ` (2 more replies)
  2026-06-08 21:06 ` [PATCH v2 6/6] mm: Remove __folio_index Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  7 siblings, 3 replies; 35+ 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] 35+ 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-10  8:24   ` Vishal Moola
  2026-06-09  5:06 ` [PATCH v2 0/6] Remove __folio_index again Namjae Jeon
  2026-06-28  6:42 ` Andrew Morton
  7 siblings, 2 replies; 35+ 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] 35+ 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; 35+ 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] 35+ 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-07-06  1:58   ` Hyunchul Lee
  2 siblings, 0 replies; 35+ 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] 35+ 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
  2026-06-13  9:41   ` Lance Yang
  2 siblings, 0 replies; 35+ 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] 35+ 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; 35+ 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] 35+ 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
  2026-06-28  6:42 ` Andrew Morton
  7 siblings, 0 replies; 35+ 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] 35+ 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-10 20:02     ` Matthew Wilcox
  2026-06-09 18:44   ` David Hildenbrand (Arm)
  2026-06-10  8:23   ` Vishal Moola
  2 siblings, 1 reply; 35+ 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] 35+ 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
  2026-06-13  9:41   ` Lance Yang
  2 siblings, 0 replies; 35+ 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] 35+ 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
  2026-07-06  1:58   ` Hyunchul Lee
  2 siblings, 1 reply; 35+ 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] 35+ 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; 35+ 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] 35+ 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
  2026-06-13  7:06         ` Lance Yang
  0 siblings, 1 reply; 35+ 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] 35+ 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)
  2026-06-10  8:24   ` Vishal Moola
  1 sibling, 0 replies; 35+ 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] 35+ 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)
  2026-06-10  8:23   ` Vishal Moola
  2 siblings, 0 replies; 35+ 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] 35+ 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)
@ 2026-06-10  8:23   ` Vishal Moola
  2 siblings, 0 replies; 35+ messages in thread
From: Vishal Moola @ 2026-06-10  8:23 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Andrew Morton, linux-fsdevel, linux-mm, Ye Liu

On Mon, Jun 08, 2026 at 10:06:15PM +0100, 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>

Reviewed-by: Vishal Moola <vishal.moola@gmail.com>


^ permalink raw reply	[flat|nested] 35+ 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)
@ 2026-06-10  8:24   ` Vishal Moola
  1 sibling, 0 replies; 35+ messages in thread
From: Vishal Moola @ 2026-06-10  8:24 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Andrew Morton, linux-fsdevel, linux-mm

On Mon, Jun 08, 2026 at 10:06:16PM +0100, 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>

Reviewed-by: Vishal Moola <vishal.moola@gmail.com>


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

* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
  2026-06-09 11:59   ` Ye Liu
@ 2026-06-10 20:02     ` Matthew Wilcox
  2026-06-13  3:02       ` Ye Liu
  0 siblings, 1 reply; 35+ messages in thread
From: Matthew Wilcox @ 2026-06-10 20:02 UTC (permalink / raw)
  To: Ye Liu; +Cc: Andrew Morton, linux-fsdevel, linux-mm

On Tue, Jun 09, 2026 at 07:59:28PM +0800, Ye Liu wrote:
> 
> 在 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.

Thanks, but could you explain why you don't just call dump_page()?
It's more comprehensive and will continue to be maintained.


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

* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
  2026-06-10 20:02     ` Matthew Wilcox
@ 2026-06-13  3:02       ` Ye Liu
  2026-06-13  3:18         ` Matthew Wilcox
  0 siblings, 1 reply; 35+ messages in thread
From: Ye Liu @ 2026-06-13  3:02 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-fsdevel, linux-mm



在 2026/6/11 04:02, Matthew Wilcox 写道:
> On Tue, Jun 09, 2026 at 07:59:28PM +0800, Ye Liu wrote:
>>
>> 在 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.
> 
> Thanks, but could you explain why you don't just call dump_page()?
> It's more comprehensive and will continue to be maintained.

This script is based on the drgn tool, but the drgn tool does not
have a dump_page helper. What kind of method do you mean by      
directly calling it?                                             

-- 
Thanks,
Ye Liu



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

* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
  2026-06-13  3:02       ` Ye Liu
@ 2026-06-13  3:18         ` Matthew Wilcox
  2026-06-13  4:16           ` Ye Liu
  0 siblings, 1 reply; 35+ messages in thread
From: Matthew Wilcox @ 2026-06-13  3:18 UTC (permalink / raw)
  To: Ye Liu; +Cc: Andrew Morton, linux-fsdevel, linux-mm

On Sat, Jun 13, 2026 at 11:02:06AM +0800, Ye Liu wrote:
> 在 2026/6/11 04:02, Matthew Wilcox 写道:
> > Thanks, but could you explain why you don't just call dump_page()?
> > It's more comprehensive and will continue to be maintained.
> 
> This script is based on the drgn tool, but the drgn tool does not
> have a dump_page helper. What kind of method do you mean by      
> directly calling it?                                             

void dump_page(const struct page *page, const char *reason)

in mm/debug.c


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

* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
  2026-06-13  3:18         ` Matthew Wilcox
@ 2026-06-13  4:16           ` Ye Liu
  2026-06-13 16:15             ` Matthew Wilcox
  0 siblings, 1 reply; 35+ messages in thread
From: Ye Liu @ 2026-06-13  4:16 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-fsdevel, linux-mm



在 2026/6/13 11:18, Matthew Wilcox 写道:
> On Sat, Jun 13, 2026 at 11:02:06AM +0800, Ye Liu wrote:
>> 在 2026/6/11 04:02, Matthew Wilcox 写道:
>>> Thanks, but could you explain why you don't just call dump_page()?
>>> It's more comprehensive and will continue to be maintained.
>>
>> This script is based on the drgn tool, but the drgn tool does not
>> have a dump_page helper. What kind of method do you mean by      
>> directly calling it?                                             
> 
> void dump_page(const struct page *page, const char *reason)
> 
> in mm/debug.c

I’m aware of this kernel function, but could you please clarify
how to call it from a user program?               
Or how to achieve the direct call you mentioned?

-- 
Thanks,
Ye Liu



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

* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
  2026-06-09 15:55       ` Usama Arif
@ 2026-06-13  7:06         ` Lance Yang
  0 siblings, 0 replies; 35+ messages in thread
From: Lance Yang @ 2026-06-13  7:06 UTC (permalink / raw)
  To: usama.arif, willy; +Cc: akpm, linux-fsdevel, linux-mm, Lance Yang


On Tue, Jun 09, 2026 at 04:55:03PM +0100, Usama Arif wrote:
[...]
>> 
>> 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.

Right. Let me try to make one case easier to see.

Assume:

  PAGE_SIZE             = 4096
  page->__folio_index   = 2
  pos                   = 8192
  initialized_size      = 9000
  i_size                = 12000

Before the patch, the relevant code was:

	if ((page->__folio_index >= (initialized_size >> PAGE_SHIFT)) &&
			(initialized_size < i_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);
	}

For this page, the outer check was true:

  page->__folio_index >= (initialized_size >> PAGE_SHIFT)
  2 >= (9000 >> 12)
  2 >= 2

and initialized_size < i_size was also true:

  initialized_size < i_size
  9000 < 12000

but the inner check was false:

  ((s64)page->__folio_index << PAGE_SHIFT) >= initialized_size
  (2 << 12) >= 9000
  8192 >= 9000

So the old code reached the tail-zeroing case:

  kp_ofs = 9000 & ~PAGE_MASK = 808

and zeroed page offset 808..4095, i.e. file offset 9000..12287.

After this patch, the outer check became:

loff_t pos = page_offset(page);

if ((pos >= initialized_size) && (initialized_size < i_size)) 

For the same page:

  pos >= initialized_size
  8192 >= 9000

so the first half of the outer check is false, and the block is skipped
entirely.

Cheers, Lance


^ permalink raw reply	[flat|nested] 35+ 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
@ 2026-06-13  9:41   ` Lance Yang
  2026-06-15 12:18     ` Namjae Jeon
  2 siblings, 1 reply; 35+ messages in thread
From: Lance Yang @ 2026-06-13  9:41 UTC (permalink / raw)
  To: willy; +Cc: akpm, linux-fsdevel, linux-mm, hyc.lee, usama.arif, Lance Yang


On Mon, Jun 08, 2026 at 10:06:13PM +0100, Matthew Wilcox (Oracle) 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

Just a thought.

This file still seems to have a few more page_address() users where the
kmap_local_page() return value is not used.

Should the rest of them be cleaned up in this series too?

Cheers, Lance


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

* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
  2026-06-13  4:16           ` Ye Liu
@ 2026-06-13 16:15             ` Matthew Wilcox
  2026-06-14  1:57               ` Ye Liu
  0 siblings, 1 reply; 35+ messages in thread
From: Matthew Wilcox @ 2026-06-13 16:15 UTC (permalink / raw)
  To: Ye Liu; +Cc: Andrew Morton, linux-fsdevel, linux-mm

On Sat, Jun 13, 2026 at 12:16:38PM +0800, Ye Liu wrote:
> 在 2026/6/13 11:18, Matthew Wilcox 写道:
> > On Sat, Jun 13, 2026 at 11:02:06AM +0800, Ye Liu wrote:
> >> 在 2026/6/11 04:02, Matthew Wilcox 写道:
> >>> Thanks, but could you explain why you don't just call dump_page()?
> >>> It's more comprehensive and will continue to be maintained.
> >>
> >> This script is based on the drgn tool, but the drgn tool does not
> >> have a dump_page helper. What kind of method do you mean by      
> >> directly calling it?                                             
> > 
> > void dump_page(const struct page *page, const char *reason)
> > 
> > in mm/debug.c
> 
> I’m aware of this kernel function, but could you please clarify
> how to call it from a user program?               
> Or how to achieve the direct call you mentioned?

https://drgn.readthedocs.io/en/latest/release_highlights/0.0.28.html


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

* Re: [PATCH v2 5/6] show_page_info: Remove printing of page index
  2026-06-13 16:15             ` Matthew Wilcox
@ 2026-06-14  1:57               ` Ye Liu
  0 siblings, 0 replies; 35+ messages in thread
From: Ye Liu @ 2026-06-14  1:57 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-fsdevel, linux-mm



在 2026/6/14 00:15, Matthew Wilcox 写道:
> On Sat, Jun 13, 2026 at 12:16:38PM +0800, Ye Liu wrote:
>> 在 2026/6/13 11:18, Matthew Wilcox 写道:
>>> On Sat, Jun 13, 2026 at 11:02:06AM +0800, Ye Liu wrote:
>>>> 在 2026/6/11 04:02, Matthew Wilcox 写道:
>>>>> Thanks, but could you explain why you don't just call dump_page()?
>>>>> It's more comprehensive and will continue to be maintained.
>>>>
>>>> This script is based on the drgn tool, but the drgn tool does not
>>>> have a dump_page helper. What kind of method do you mean by      
>>>> directly calling it?                                             
>>>
>>> void dump_page(const struct page *page, const char *reason)
>>>
>>> in mm/debug.c
>>
>> I’m aware of this kernel function, but could you please clarify
>> how to call it from a user program?               
>> Or how to achieve the direct call you mentioned?
> 
> https://drgn.readthedocs.io/en/latest/release_highlights/0.0.28.html

Note that this feature is currently experimental, only supported on x86-64.
Furthermore, I tried calling_function() a long time ago,
which caused the system to crash, so I haven't used it since.

-- 
Thanks,
Ye Liu



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

* Re: [PATCH v2 3/6] ntfs: Use zero_user_segment() in handle_bounds_compressed_page()
  2026-06-13  9:41   ` Lance Yang
@ 2026-06-15 12:18     ` Namjae Jeon
  0 siblings, 0 replies; 35+ messages in thread
From: Namjae Jeon @ 2026-06-15 12:18 UTC (permalink / raw)
  To: Lance Yang; +Cc: willy, akpm, linux-fsdevel, linux-mm, hyc.lee, usama.arif

[-- Attachment #1: Type: text/plain, Size: 909 bytes --]

On Sat, Jun 13, 2026 at 6:41 PM Lance Yang <lance.yang@linux.dev> wrote:
>
>
> On Mon, Jun 08, 2026 at 10:06:13PM +0100, Matthew Wilcox (Oracle) 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
>
> Just a thought.
>
> This file still seems to have a few more page_address() users where the
> kmap_local_page() return value is not used.
>
> Should the rest of them be cleaned up in this series too?
Matthew previously requested to fix that. I am waiting for this series
to be merged before applying the attached patch.
Thanks.

[-- Attachment #2: 0001-ntfs-fix-kmap_local_page-usage-in-compress.patch --]
[-- Type: text/x-patch, Size: 7262 bytes --]

From ebc5d6d7d6ea3cadfa59f83331b66b85ee5240e7 Mon Sep 17 00:00:00 2001
From: Namjae Jeon <linkinjeon@kernel.org>
Date: Mon, 15 Jun 2026 21:07:19 +0900
Subject: [PATCH] ntfs: fix kmap_local_page() usage in compress

Several compressed I/O paths discard the address returned by
kmap_local_page() and later access or unmap the page using page_address().
This is invalid for highmem pages, and local mappings must also be unmapped
using the address returned by kmap_local_page().

Map each destination page in ntfs_decompress() only while producing the
current sub-block. Use memcpy_from_page(), memcpy_to_page(), and
memzero_page() for the other page accesses. Remove unnecessary local
mappings from ntfs_write_cb(), where pages are accessed through the vmap()
mapping.

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ntfs/compress.c | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index eae0339a8518..2671bca521b3 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -176,6 +176,7 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 
 	/* Variables for uncompressed data / destination. */
 	struct page *dp;	/* Current destination page being worked on. */
+	u8 *dp_kaddr;		/* Local kmap for the current destination page. */
 	u8 *dp_addr;		/* Current pointer into dp. */
 	u8 *dp_sb_start;	/* Start of current sub-block in dp. */
 	u8 *dp_sb_end;		/* End of current sb in dp (dp_sb_start + NTFS_SB_SIZE). */
@@ -190,6 +191,7 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 	/* Default error code. */
 	int err = -EOVERFLOW;
 
+	dp_kaddr = NULL;
 	ntfs_debug("Entering, cb_size = 0x%x.", cb_size);
 do_next_sb:
 	ntfs_debug("Beginning sub-block at offset = 0x%zx in the cb.",
@@ -222,7 +224,6 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 				 */
 				handle_bounds_compressed_page(dp, i_size,
 						initialized_size);
-				kunmap_local(page_address(dp));
 				SetPageUptodate(dp);
 				unlock_page(dp);
 				if (di == xpage)
@@ -268,7 +269,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 	}
 
 	/* We have a valid destination page. Setup the destination pointers. */
-	dp_addr = (u8 *)page_address(dp) + do_sb_start;
+	dp_kaddr = kmap_local_page(dp);
+	dp_addr = dp_kaddr + do_sb_start;
 
 	/* Now, we are ready to process the current sub-block (sb). */
 	if (!(le16_to_cpup((__le16 *)cb) & NTFS_SB_IS_COMPRESSED)) {
@@ -289,6 +291,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 		/* Advance destination position to next sub-block. */
 		*dest_ofs += NTFS_SB_SIZE;
 		*dest_ofs &= ~PAGE_MASK;
+		kunmap_local(dp_kaddr);
+		dp_kaddr = NULL;
 		if (!(*dest_ofs)) {
 finalize_page:
 			/*
@@ -323,6 +327,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 		}
 		/* We have finished the current sub-block. */
 		*dest_ofs &= ~PAGE_MASK;
+		kunmap_local(dp_kaddr);
+		dp_kaddr = NULL;
 		if (!(*dest_ofs))
 			goto finalize_page;
 		goto do_next_sb;
@@ -428,6 +434,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[],
 	goto do_next_tag;
 
 return_overflow:
+	if (dp_kaddr)
+		kunmap_local(dp_kaddr);
 	ntfs_error(NULL, "Failed. Returning -EOVERFLOW.");
 	goto return_error;
 }
@@ -556,7 +564,6 @@ int ntfs_read_compressed_block(struct folio *folio)
 			 * least wasting our time.
 			 */
 			if (!PageDirty(page) && (!PageUptodate(page))) {
-				kmap_local_page(page);
 				continue;
 			}
 			unlock_page(page);
@@ -642,8 +649,7 @@ int ntfs_read_compressed_block(struct folio *folio)
 		}
 
 		lock_page(lpage);
-		memcpy(cb_pos, page_address(lpage) + page_ofs,
-		       vol->cluster_size);
+		memcpy_from_page(cb_pos, lpage, page_ofs, vol->cluster_size);
 		unlock_page(lpage);
 		put_page(lpage);
 		cb_pos += vol->cluster_size;
@@ -682,14 +688,7 @@ int ntfs_read_compressed_block(struct folio *folio)
 		for (; cur_page < cb_max_page; cur_page++) {
 			page = pages[cur_page];
 			if (page) {
-				if (likely(!cur_ofs))
-					clear_page(page_address(page));
-				else
-					memset(page_address(page) + cur_ofs, 0,
-							PAGE_SIZE -
-							cur_ofs);
-				flush_dcache_page(page);
-				kunmap_local(page_address(page));
+				memzero_page(page, cur_ofs, PAGE_SIZE - cur_ofs);
 				SetPageUptodate(page);
 				unlock_page(page);
 				if (cur_page == xpage)
@@ -707,8 +706,7 @@ int ntfs_read_compressed_block(struct folio *folio)
 		if (cb_max_ofs && cb_pos < cb_end) {
 			page = pages[cur_page];
 			if (page)
-				memset(page_address(page) + cur_ofs, 0,
-						cb_max_ofs - cur_ofs);
+				memzero_page(page, cur_ofs, cb_max_ofs - cur_ofs);
 			/*
 			 * No need to update cb_pos at this stage:
 			 *	cb_pos += cb_max_ofs - cur_ofs;
@@ -729,7 +727,7 @@ int ntfs_read_compressed_block(struct folio *folio)
 		for (; cur_page < cb_max_page; cur_page++) {
 			page = pages[cur_page];
 			if (page)
-				memcpy(page_address(page) + cur_ofs, cb_pos,
+				memcpy_to_page(page, cur_ofs, cb_pos,
 						PAGE_SIZE - cur_ofs);
 			cb_pos += PAGE_SIZE - cur_ofs;
 			cur_ofs = 0;
@@ -740,7 +738,7 @@ int ntfs_read_compressed_block(struct folio *folio)
 		if (cb_max_ofs && cb_pos < cb_end) {
 			page = pages[cur_page];
 			if (page)
-				memcpy(page_address(page) + cur_ofs, cb_pos,
+				memcpy_to_page(page, cur_ofs, cb_pos,
 						cb_max_ofs - cur_ofs);
 			cb_pos += cb_max_ofs - cur_ofs;
 			cur_ofs = cb_max_ofs;
@@ -757,7 +755,6 @@ int ntfs_read_compressed_block(struct folio *folio)
 				 */
 				handle_bounds_compressed_page(page, i_size,
 						initialized_size);
-				kunmap_local(page_address(page));
 				SetPageUptodate(page);
 				unlock_page(page);
 				if (cur2_page == xpage)
@@ -793,7 +790,6 @@ int ntfs_read_compressed_block(struct folio *folio)
 				page = pages[prev_cur_page];
 				if (page) {
 					flush_dcache_page(page);
-					kunmap_local(page_address(page));
 					unlock_page(page);
 					if (prev_cur_page != xpage)
 						put_page(page);
@@ -817,7 +813,6 @@ int ntfs_read_compressed_block(struct folio *folio)
 				"Still have pages left! Terminating them with extreme prejudice.  Inode 0x%llx, page index 0x%lx.",
 				ni->mft_no, folio->index);
 			flush_dcache_folio(folio);
-			kunmap_local(page_address(page));
 			folio_unlock(folio);
 			if (cur_page != xpage)
 				folio_put(folio);
@@ -855,7 +850,6 @@ int ntfs_read_compressed_block(struct folio *folio)
 		page = pages[i];
 		if (page) {
 			flush_dcache_page(page);
-			kunmap_local(page_address(page));
 			unlock_page(page);
 			if (i != xpage)
 				put_page(page);
@@ -1307,7 +1301,6 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages,
 		}
 		pages_disk[i] = pg;
 		lock_page(pg);
-		kmap_local_page(pg);
 	}
 
 	outbuf = vmap(pages_disk, pages_count, VM_MAP, PAGE_KERNEL);
@@ -1442,7 +1435,6 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages,
 	for (i = 0; i < pages_count; i++) {
 		pg = pages_disk[i];
 		if (pg) {
-			kunmap_local(page_address(pg));
 			unlock_page(pg);
 			put_page(pg);
 		}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 35+ 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)
                   ` (6 preceding siblings ...)
  2026-06-09  5:06 ` [PATCH v2 0/6] Remove __folio_index again Namjae Jeon
@ 2026-06-28  6:42 ` Andrew Morton
  7 siblings, 0 replies; 35+ messages in thread
From: Andrew Morton @ 2026-06-28  6:42 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: linux-fsdevel, linux-mm, Namjae Jeon, Hyunchul Lee

On Mon,  8 Jun 2026 22:06:10 +0100 "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.

I'm assuming we'll be seeing a v3 of this series?

AI review might have a few niggles with these changes and it might have
found some pre-existing issues in the ntfs code which ntfs maintainers
might want to check out:

	https://sashiko.dev/#/patchset/20260608210618.3437216-1-willy@infradead.org


^ permalink raw reply	[flat|nested] 35+ 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-07-06  1:58   ` Hyunchul Lee
  2026-07-08  0:08     ` Hyunchul Lee
  2 siblings, 1 reply; 35+ messages in thread
From: Hyunchul Lee @ 2026-07-06  1:58 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Andrew Morton, linux-fsdevel, linux-mm, Namjae Jeon, usama.arif,
	lance.yang

Hi Matthew,

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>
> ---
>  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)) {

I think the following change would address the review comments for
this patch and patch 3/6.

if ((pos + PAGE_SIZE > 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] 35+ messages in thread

* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
  2026-07-06  1:58   ` Hyunchul Lee
@ 2026-07-08  0:08     ` Hyunchul Lee
  2026-07-09 23:28       ` Namjae Jeon
  0 siblings, 1 reply; 35+ messages in thread
From: Hyunchul Lee @ 2026-07-08  0:08 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Andrew Morton, linux-fsdevel, linux-mm, Namjae Jeon, usama.arif,
	lance.yang

Hi Matthew,

2026년 7월 6일 (월) 오전 10:58, Hyunchul Lee <hyc.lee@gmail.com>님이 작성:
>
> Hi Matthew,
>
> 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>
> > ---
> >  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)) {
>
> I think the following change would address the review comments for
> this patch and patch 3/6.
>

Would you mind if I continue working on this series?
I would fix the above if-condition and add Co-developed-by for my changes.

Please let me know if that's okay with you.

> if ((pos + PAGE_SIZE > 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



-- 
Thanks,
Hyunchul


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

* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
  2026-07-08  0:08     ` Hyunchul Lee
@ 2026-07-09 23:28       ` Namjae Jeon
  2026-07-10  5:43         ` Hyunchul Lee
  0 siblings, 1 reply; 35+ messages in thread
From: Namjae Jeon @ 2026-07-09 23:28 UTC (permalink / raw)
  To: Hyunchul Lee
  Cc: Matthew Wilcox (Oracle), Andrew Morton, linux-fsdevel, linux-mm,
	usama.arif, lance.yang

> > > 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)) {
> >
> > I think the following change would address the review comments for
> > this patch and patch 3/6.
> >
>
> Would you mind if I continue working on this series?
> I would fix the above if-condition and add Co-developed-by for my changes.
>
> Please let me know if that's okay with you.
Could you please provide the updated ntfs patches so I can apply them
to the ntfs tree?
Thanks.


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

* Re: [PATCH v2 2/6] ntfs: Remove use of __folio_index in handle_bounds_compressed_page()
  2026-07-09 23:28       ` Namjae Jeon
@ 2026-07-10  5:43         ` Hyunchul Lee
  0 siblings, 0 replies; 35+ messages in thread
From: Hyunchul Lee @ 2026-07-10  5:43 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Matthew Wilcox (Oracle), Andrew Morton, linux-fsdevel, linux-mm,
	usama.arif, lance.yang

2026년 7월 10일 (금) 오전 8:28, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>
> > > > 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)) {
> > >
> > > I think the following change would address the review comments for
> > > this patch and patch 3/6.
> > >
> >
> > Would you mind if I continue working on this series?
> > I would fix the above if-condition and add Co-developed-by for my changes.
> >
> > Please let me know if that's okay with you.
> Could you please provide the updated ntfs patches so I can apply them
> to the ntfs tree?

Okay, I will send those patches.

> Thanks.



-- 
Thanks,
Hyunchul


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

end of thread, other threads:[~2026-07-10  5:43 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this 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-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)
2026-06-09  0:19   ` Hyunchul Lee
2026-06-09 13:17   ` Usama Arif
2026-06-09 14:34     ` Matthew Wilcox
2026-06-09 15:55       ` Usama Arif
2026-06-13  7:06         ` Lance Yang
2026-07-06  1:58   ` Hyunchul Lee
2026-07-08  0:08     ` Hyunchul Lee
2026-07-09 23:28       ` Namjae Jeon
2026-07-10  5:43         ` Hyunchul Lee
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
2026-06-13  9:41   ` Lance Yang
2026-06-15 12:18     ` Namjae Jeon
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
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-10 20:02     ` Matthew Wilcox
2026-06-13  3:02       ` Ye Liu
2026-06-13  3:18         ` Matthew Wilcox
2026-06-13  4:16           ` Ye Liu
2026-06-13 16:15             ` Matthew Wilcox
2026-06-14  1:57               ` Ye Liu
2026-06-09 18:44   ` David Hildenbrand (Arm)
2026-06-10  8:23   ` Vishal Moola
2026-06-08 21:06 ` [PATCH v2 6/6] mm: Remove __folio_index Matthew Wilcox (Oracle)
2026-06-09 18:43   ` David Hildenbrand (Arm)
2026-06-10  8:24   ` Vishal Moola
2026-06-09  5:06 ` [PATCH v2 0/6] Remove __folio_index again Namjae Jeon
2026-06-28  6:42 ` Andrew Morton

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