All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios
@ 2024-04-17 17:09 Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 01/10] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

I'm not making any attempt here to support large folios.  This is just
to remove uses of the page-based APIs.  There are still a number of
places in ntfs3 which use a struct page, but this is a good start on
the conversions.

Matthew Wilcox (Oracle) (10):
  ntfs3: Convert ntfs_read_folio to use a folio
  ntfs3: Convert ntfs_write_begin to use a folio
  ntfs3: Convert attr_data_read_resident() to take a folio
  ntfs3: Convert ntfs_write_end() to work on a folio
  ntfs3: Convert attr_data_write_resident to use a folio
  ntfs3: Convert attr_make_nonresident to use a folio
  ntfs3: Convert reading $AttrDef to use folios
  ntfs3: Use a folio to read UpCase
  ntfs3: Remove inode_write_data()
  ntfs3: Remove ntfs_map_page and ntfs_unmap_page

 fs/ntfs3/attrib.c       | 65 +++++++++++++---------------------
 fs/ntfs3/inode.c        | 77 +++++++++++++----------------------------
 fs/ntfs3/ntfs_fs.h      | 21 ++---------
 fs/ntfs3/super.c        | 43 ++++++++++++-----------
 include/linux/highmem.h | 31 +++++++++++++++++
 5 files changed, 104 insertions(+), 133 deletions(-)

-- 
2.43.0


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

* [PATCH 01/10] ntfs3: Convert ntfs_read_folio to use a folio
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 02/10] ntfs3: Convert ntfs_write_begin " Matthew Wilcox (Oracle)
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Remove the struct page conversion, and use a folio throughout.  We still
convert back to a struct page for calling some internal functions,
but those will change soon.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/inode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 3c4c878f6d77..f833d9cd383d 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -698,25 +698,24 @@ static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)
 
 static int ntfs_read_folio(struct file *file, struct folio *folio)
 {
-	struct page *page = &folio->page;
 	int err;
-	struct address_space *mapping = page->mapping;
+	struct address_space *mapping = folio->mapping;
 	struct inode *inode = mapping->host;
 	struct ntfs_inode *ni = ntfs_i(inode);
 
 	if (is_resident(ni)) {
 		ni_lock(ni);
-		err = attr_data_read_resident(ni, page);
+		err = attr_data_read_resident(ni, &folio->page);
 		ni_unlock(ni);
 		if (err != E_NTFS_NONRESIDENT) {
-			unlock_page(page);
+			folio_unlock(folio);
 			return err;
 		}
 	}
 
 	if (is_compressed(ni)) {
 		ni_lock(ni);
-		err = ni_readpage_cmpr(ni, page);
+		err = ni_readpage_cmpr(ni, &folio->page);
 		ni_unlock(ni);
 		return err;
 	}
-- 
2.43.0


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

* [PATCH 02/10] ntfs3: Convert ntfs_write_begin to use a folio
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 01/10] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 03/10] ntfs3: Convert attr_data_read_resident() to take " Matthew Wilcox (Oracle)
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Retrieve a folio from the page cache instead of a precise page.
This function is now large folio safe, but its called function is not.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/inode.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index f833d9cd383d..25be12e68d6e 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -901,24 +901,25 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,
 
 	*pagep = NULL;
 	if (is_resident(ni)) {
-		struct page *page =
-			grab_cache_page_write_begin(mapping, pos >> PAGE_SHIFT);
+		struct folio *folio = __filemap_get_folio(mapping,
+				pos >> PAGE_SHIFT, FGP_WRITEBEGIN,
+				mapping_gfp_mask(mapping));
 
-		if (!page) {
-			err = -ENOMEM;
+		if (IS_ERR(folio)) {
+			err = PTR_ERR(folio);
 			goto out;
 		}
 
 		ni_lock(ni);
-		err = attr_data_read_resident(ni, page);
+		err = attr_data_read_resident(ni, &folio->page);
 		ni_unlock(ni);
 
 		if (!err) {
-			*pagep = page;
+			*pagep = &folio->page;
 			goto out;
 		}
-		unlock_page(page);
-		put_page(page);
+		folio_unlock(folio);
+		folio_put(folio);
 
 		if (err != E_NTFS_NONRESIDENT)
 			goto out;
-- 
2.43.0


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

* [PATCH 03/10] ntfs3: Convert attr_data_read_resident() to take a folio
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 01/10] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 02/10] ntfs3: Convert ntfs_write_begin " Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 04/10] ntfs3: Convert ntfs_write_end() to work on " Matthew Wilcox (Oracle)
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Now that all three callers have a folio, pass it in and use
folio_fill_tail() to do the hard work of filling the folio.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/attrib.c  | 27 +++++++++------------------
 fs/ntfs3/inode.c   |  6 +++---
 fs/ntfs3/ntfs_fs.h |  2 +-
 3 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 7aadf5010999..11f90b140122 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -1223,11 +1223,12 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
 	goto out;
 }
 
-int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
+int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio)
 {
 	u64 vbo;
 	struct ATTRIB *attr;
 	u32 data_size;
+	size_t len;
 
 	attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL);
 	if (!attr)
@@ -1236,25 +1237,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
 	if (attr->non_res)
 		return E_NTFS_NONRESIDENT;
 
-	vbo = page->index << PAGE_SHIFT;
+	vbo = folio->index << PAGE_SHIFT;
 	data_size = le32_to_cpu(attr->res.data_size);
-	if (vbo < data_size) {
-		const char *data = resident_data(attr);
-		char *kaddr = kmap_atomic(page);
-		u32 use = data_size - vbo;
-
-		if (use > PAGE_SIZE)
-			use = PAGE_SIZE;
+	if (vbo > data_size)
+		len = 0;
+	else
+		len = min(data_size - vbo, folio_size(folio));
 
-		memcpy(kaddr, data + vbo, use);
-		memset(kaddr + use, 0, PAGE_SIZE - use);
-		kunmap_atomic(kaddr);
-		flush_dcache_page(page);
-		SetPageUptodate(page);
-	} else if (!PageUptodate(page)) {
-		zero_user_segment(page, 0, PAGE_SIZE);
-		SetPageUptodate(page);
-	}
+	folio_fill_tail(folio, 0, resident_data(attr) + vbo, len);
+	folio_mark_uptodate(folio);
 
 	return 0;
 }
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 25be12e68d6e..1eb11c3b480d 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -571,7 +571,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,
 
 	if (is_resident(ni)) {
 		ni_lock(ni);
-		err = attr_data_read_resident(ni, &folio->page);
+		err = attr_data_read_resident(ni, folio);
 		ni_unlock(ni);
 
 		if (!err)
@@ -705,7 +705,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
 
 	if (is_resident(ni)) {
 		ni_lock(ni);
-		err = attr_data_read_resident(ni, &folio->page);
+		err = attr_data_read_resident(ni, folio);
 		ni_unlock(ni);
 		if (err != E_NTFS_NONRESIDENT) {
 			folio_unlock(folio);
@@ -911,7 +911,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,
 		}
 
 		ni_lock(ni);
-		err = attr_data_read_resident(ni, &folio->page);
+		err = attr_data_read_resident(ni, folio);
 		ni_unlock(ni);
 
 		if (!err) {
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index ea5b5e814e63..0b518bf8182a 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -434,7 +434,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
 		  struct ATTRIB **ret);
 int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
 			CLST *len, bool *new, bool zero);
-int attr_data_read_resident(struct ntfs_inode *ni, struct page *page);
+int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio);
 int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
 int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
 		       const __le16 *name, u8 name_len, struct runs_tree *run,
-- 
2.43.0


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

* [PATCH 04/10] ntfs3: Convert ntfs_write_end() to work on a folio
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 03/10] ntfs3: Convert attr_data_read_resident() to take " Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 05/10] ntfs3: Convert attr_data_write_resident to use " Matthew Wilcox (Oracle)
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Convert the passed page back into a folio and use the folio APIs, saving
a few hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/inode.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 1eb11c3b480d..e649d191554d 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -938,6 +938,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,
 int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 		   u32 len, u32 copied, struct page *page, void *fsdata)
 {
+	struct folio *folio = page_folio(page);
 	struct inode *inode = mapping->host;
 	struct ntfs_inode *ni = ntfs_i(inode);
 	u64 valid = ni->i_valid;
@@ -949,23 +950,23 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 		err = attr_data_write_resident(ni, page);
 		ni_unlock(ni);
 		if (!err) {
+			struct buffer_head *head = folio_buffers(folio);
 			dirty = true;
-			/* Clear any buffers in page. */
-			if (page_has_buffers(page)) {
-				struct buffer_head *head, *bh;
+			/* Clear any buffers in folio. */
+			if (head) {
+				struct buffer_head *bh = head;
 
-				bh = head = page_buffers(page);
 				do {
 					clear_buffer_dirty(bh);
 					clear_buffer_mapped(bh);
 					set_buffer_uptodate(bh);
 				} while (head != (bh = bh->b_this_page));
 			}
-			SetPageUptodate(page);
+			folio_mark_uptodate(folio);
 			err = copied;
 		}
-		unlock_page(page);
-		put_page(page);
+		folio_unlock(folio);
+		folio_put(folio);
 	} else {
 		err = generic_write_end(file, mapping, pos, len, copied, page,
 					fsdata);
-- 
2.43.0


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

* [PATCH 05/10] ntfs3: Convert attr_data_write_resident to use a folio
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (3 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 04/10] ntfs3: Convert ntfs_write_end() to work on " Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 06/10] ntfs3: Convert attr_make_nonresident " Matthew Wilcox (Oracle)
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Now that both callers of attr_data_write_resident() have a folio, pass
it in and use memcpy_from_folio() to handle all the gnarly highmem
multi-page problems.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/attrib.c  | 12 ++++--------
 fs/ntfs3/inode.c   |  4 ++--
 fs/ntfs3/ntfs_fs.h |  2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 11f90b140122..64b526fd2dbc 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -1250,7 +1250,7 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio)
 	return 0;
 }
 
-int attr_data_write_resident(struct ntfs_inode *ni, struct page *page)
+int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio)
 {
 	u64 vbo;
 	struct mft_inode *mi;
@@ -1266,17 +1266,13 @@ int attr_data_write_resident(struct ntfs_inode *ni, struct page *page)
 		return E_NTFS_NONRESIDENT;
 	}
 
-	vbo = page->index << PAGE_SHIFT;
+	vbo = folio->index << PAGE_SHIFT;
 	data_size = le32_to_cpu(attr->res.data_size);
 	if (vbo < data_size) {
 		char *data = resident_data(attr);
-		char *kaddr = kmap_atomic(page);
-		u32 use = data_size - vbo;
+		size_t len = min(data_size - vbo, folio_size(folio));
 
-		if (use > PAGE_SIZE)
-			use = PAGE_SIZE;
-		memcpy(data + vbo, kaddr, use);
-		kunmap_atomic(kaddr);
+		memcpy_from_folio(data + vbo, folio, 0, len);
 		mi->dirty = true;
 	}
 	ni->i_valid = data_size;
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index e649d191554d..cd634398d770 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -859,7 +859,7 @@ static int ntfs_resident_writepage(struct folio *folio,
 		return -EIO;
 
 	ni_lock(ni);
-	ret = attr_data_write_resident(ni, &folio->page);
+	ret = attr_data_write_resident(ni, folio);
 	ni_unlock(ni);
 
 	if (ret != E_NTFS_NONRESIDENT)
@@ -947,7 +947,7 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 
 	if (is_resident(ni)) {
 		ni_lock(ni);
-		err = attr_data_write_resident(ni, page);
+		err = attr_data_write_resident(ni, folio);
 		ni_unlock(ni);
 		if (!err) {
 			struct buffer_head *head = folio_buffers(folio);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 0b518bf8182a..d35dc001c2c0 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -435,7 +435,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
 int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
 			CLST *len, bool *new, bool zero);
 int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio);
-int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
+int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio);
 int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
 		       const __le16 *name, u8 name_len, struct runs_tree *run,
 		       CLST vcn);
-- 
2.43.0


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

* [PATCH 06/10] ntfs3: Convert attr_make_nonresident to use a folio
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (4 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 05/10] ntfs3: Convert attr_data_write_resident to use " Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 07/10] ntfs3: Convert reading $AttrDef to use folios Matthew Wilcox (Oracle)
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Fetch a folio from the page cache instead of a page and operate on it.
Take advantage of the new helpers to avoid handling highmem ourselves,
and combine the uptodate + unlock operations into folio_end_read().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/attrib.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 64b526fd2dbc..1972213a663e 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -285,22 +285,20 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
 			if (err)
 				goto out2;
 		} else if (!page) {
-			char *kaddr;
-
-			page = grab_cache_page(ni->vfs_inode.i_mapping, 0);
-			if (!page) {
-				err = -ENOMEM;
+			struct address_space *mapping = ni->vfs_inode.i_mapping;
+			struct folio *folio;
+
+			folio = __filemap_get_folio(mapping, 0,
+					FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
+					mapping_gfp_mask(mapping));
+			if (IS_ERR(folio)) {
+				err = PTR_ERR(folio);
 				goto out2;
 			}
-			kaddr = kmap_atomic(page);
-			memcpy(kaddr, data, rsize);
-			memset(kaddr + rsize, 0, PAGE_SIZE - rsize);
-			kunmap_atomic(kaddr);
-			flush_dcache_page(page);
-			SetPageUptodate(page);
-			set_page_dirty(page);
-			unlock_page(page);
-			put_page(page);
+			folio_fill_tail(folio, 0, data, rsize);
+			folio_mark_dirty(folio);
+			folio_end_read(folio, true);
+			folio_put(folio);
 		}
 	}
 
-- 
2.43.0


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

* [PATCH 07/10] ntfs3: Convert reading $AttrDef to use folios
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (5 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 06/10] ntfs3: Convert attr_make_nonresident " Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

This is now large folio safe, although we're not enabling
large folios yet.  It does eliminate a use of kmap().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/super.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 71dfeb0c4323..f6a9ab0f5cad 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1429,18 +1429,22 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 		goto put_inode_out;
 	}
 
-	for (done = idx = 0; done < bytes; done += PAGE_SIZE, idx++) {
+	done = idx = 0;
+	while (done < bytes) {
 		unsigned long tail = bytes - done;
-		struct page *page = ntfs_map_page(inode->i_mapping, idx);
+		struct folio *folio = read_mapping_folio(inode->i_mapping,
+				idx, NULL);
 
-		if (IS_ERR(page)) {
-			err = PTR_ERR(page);
+		if (IS_ERR(folio)) {
+			err = PTR_ERR(folio);
 			ntfs_err(sb, "Failed to read $AttrDef (%d).", err);
 			goto put_inode_out;
 		}
-		memcpy(Add2Ptr(t, done), page_address(page),
-		       min(PAGE_SIZE, tail));
-		ntfs_unmap_page(page);
+		memcpy_from_folio(Add2Ptr(t, done), folio, 0,
+				min(tail, folio_size(folio)));
+		done += folio_size(folio);
+		idx += folio_nr_pages(folio);
+		folio_put(folio);
 
 		if (!idx && ATTR_STD != t->type) {
 			ntfs_err(sb, "$AttrDef is corrupted.");
-- 
2.43.0


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

* [PATCH 08/10] ntfs3: Use a folio to read UpCase
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (6 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 07/10] ntfs3: Convert reading $AttrDef to use folios Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:32   ` Matthew Wilcox
                     ` (2 more replies)
  2024-04-17 17:09 ` [PATCH 09/10] ntfs3: Remove inode_write_data() Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 10/10] ntfs3: Remove ntfs_map_page and ntfs_unmap_page Matthew Wilcox (Oracle)
  9 siblings, 3 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Add a memcpy_from_folio_le16() which does the byteswapping.
This is now large folio safe and avoids kmap().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/super.c        | 25 +++++++++++--------------
 include/linux/highmem.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index f6a9ab0f5cad..00700598a717 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1493,26 +1493,23 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 		goto put_inode_out;
 	}
 
-	for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
-		const __le16 *src;
+	idx = 0;
+	while (idx < (0x10000 * sizeof(u16) >> PAGE_SHIFT)) {
 		u16 *dst = Add2Ptr(sbi->upcase, idx << PAGE_SHIFT);
-		struct page *page = ntfs_map_page(inode->i_mapping, idx);
+		struct folio *folio = read_mapping_folio(inode->i_mapping,
+				idx, NULL);
+		size_t limit = 0x10000 * sizeof(u16) - idx * PAGE_SIZE;
 
-		if (IS_ERR(page)) {
-			err = PTR_ERR(page);
+		if (IS_ERR(folio)) {
+			err = PTR_ERR(folio);
 			ntfs_err(sb, "Failed to read $UpCase (%d).", err);
 			goto put_inode_out;
 		}
 
-		src = page_address(page);
-
-#ifdef __BIG_ENDIAN
-		for (i = 0; i < PAGE_SIZE / sizeof(u16); i++)
-			*dst++ = le16_to_cpu(*src++);
-#else
-		memcpy(dst, src, PAGE_SIZE);
-#endif
-		ntfs_unmap_page(page);
+		memcpy_from_folio_le16(dst, folio, 0,
+				min(limit, folio_size(folio)));
+		idx += folio_nr_pages(folio);
+		folio_put(folio);
 	}
 
 	shared = ntfs_set_shared(sbi->upcase, 0x10000 * sizeof(short));
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 00341b56d291..20b5d5a5feaf 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -467,6 +467,37 @@ static inline void memcpy_from_folio(char *to, struct folio *folio,
 	} while (len > 0);
 }
 
+#ifdef __BIG_ENDIAN
+static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
+		size_t offset, size_t len)
+{
+	VM_BUG_ON(offset + len > folio_size(folio));
+
+	do {
+		const __le16 *from = kmap_local_folio(folio, offset);
+		size_t chunk = len;
+
+		if (folio_test_highmem(folio) &&
+		    chunk > PAGE_SIZE - offset_in_page(offset))
+			chunk = PAGE_SIZE - offset_in_page(offset);
+
+		for (i = 0; i < chunk / sizeof(*to); i++)
+			*to++ = le16_to_cpu(*from++);
+		kunmap_local(from);
+
+		to += chunk / sizeof(*to);
+		offset += chunk;
+		len -= chunk;
+	} while (len > 0);
+}
+#else
+static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
+		size_t offset, size_t len)
+{
+	memcpy_from_folio((char *)to, folio, offset, len);
+}
+#endif
+
 /**
  * memcpy_to_folio - Copy a range of bytes to a folio.
  * @folio: The folio to write to.
-- 
2.43.0


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

* [PATCH 09/10] ntfs3: Remove inode_write_data()
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (7 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  2024-04-17 17:09 ` [PATCH 10/10] ntfs3: Remove ntfs_map_page and ntfs_unmap_page Matthew Wilcox (Oracle)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

This function has no callers, so remove it.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/inode.c   | 30 ------------------------------
 fs/ntfs3/ntfs_fs.h |  1 -
 2 files changed, 31 deletions(-)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index cd634398d770..693e8b2f562e 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -1086,36 +1086,6 @@ int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,
 	return ret;
 }
 
-int inode_write_data(struct inode *inode, const void *data, size_t bytes)
-{
-	pgoff_t idx;
-
-	/* Write non resident data. */
-	for (idx = 0; bytes; idx++) {
-		size_t op = bytes > PAGE_SIZE ? PAGE_SIZE : bytes;
-		struct page *page = ntfs_map_page(inode->i_mapping, idx);
-
-		if (IS_ERR(page))
-			return PTR_ERR(page);
-
-		lock_page(page);
-		WARN_ON(!PageUptodate(page));
-		ClearPageUptodate(page);
-
-		memcpy(page_address(page), data, op);
-
-		flush_dcache_page(page);
-		SetPageUptodate(page);
-		unlock_page(page);
-
-		ntfs_unmap_page(page);
-
-		bytes -= op;
-		data = Add2Ptr(data, PAGE_SIZE);
-	}
-	return 0;
-}
-
 /*
  * ntfs_reparse_bytes
  *
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index d35dc001c2c0..1582cde21988 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -713,7 +713,6 @@ int ntfs3_write_inode(struct inode *inode, struct writeback_control *wbc);
 int ntfs_sync_inode(struct inode *inode);
 int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,
 		      struct inode *i2);
-int inode_write_data(struct inode *inode, const void *data, size_t bytes);
 struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
 				struct dentry *dentry,
 				const struct cpu_str *uni, umode_t mode,
-- 
2.43.0


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

* [PATCH 10/10] ntfs3: Remove ntfs_map_page and ntfs_unmap_page
  2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
                   ` (8 preceding siblings ...)
  2024-04-17 17:09 ` [PATCH 09/10] ntfs3: Remove inode_write_data() Matthew Wilcox (Oracle)
@ 2024-04-17 17:09 ` Matthew Wilcox (Oracle)
  9 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-04-17 17:09 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

These functions have no more callers, so remove them.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/ntfs_fs.h | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 1582cde21988..c3f71a47fd17 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -907,22 +907,6 @@ static inline bool ntfs_is_meta_file(struct ntfs_sb_info *sbi, CLST rno)
 	       rno == sbi->usn_jrnl_no;
 }
 
-static inline void ntfs_unmap_page(struct page *page)
-{
-	kunmap(page);
-	put_page(page);
-}
-
-static inline struct page *ntfs_map_page(struct address_space *mapping,
-					 unsigned long index)
-{
-	struct page *page = read_mapping_page(mapping, index, NULL);
-
-	if (!IS_ERR(page))
-		kmap(page);
-	return page;
-}
-
 static inline size_t wnd_zone_bit(const struct wnd_bitmap *wnd)
 {
 	return wnd->zone_bit;
-- 
2.43.0


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

* Re: [PATCH 08/10] ntfs3: Use a folio to read UpCase
  2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
@ 2024-04-17 17:32   ` Matthew Wilcox
  2024-04-19  0:30   ` kernel test robot
  2024-04-19  1:12   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: Matthew Wilcox @ 2024-04-17 17:32 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-fsdevel

On Wed, Apr 17, 2024 at 06:09:36PM +0100, Matthew Wilcox (Oracle) wrote:
> Add a memcpy_from_folio_le16() which does the byteswapping.
> This is now large folio safe and avoids kmap().

This patch is missing:

@@ -476,6 +476,7 @@ static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
        do {
                const __le16 *from = kmap_local_folio(folio, offset);
                size_t chunk = len;
+               int i;

                if (folio_test_highmem(folio) &&
                    chunk > PAGE_SIZE - offset_in_page(offset))

I'll send a new version if needed, but I'll wait for other feedback
first.

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

* Re: [PATCH 08/10] ntfs3: Use a folio to read UpCase
  2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
  2024-04-17 17:32   ` Matthew Wilcox
@ 2024-04-19  0:30   ` kernel test robot
  2024-04-19  1:12   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2024-04-19  0:30 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Konstantin Komarov
  Cc: oe-kbuild-all, Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Hi Matthew,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.9-rc4]
[cannot apply to next-20240418]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/ntfs3-Convert-ntfs_read_folio-to-use-a-folio/20240418-011140
base:   linus/master
patch link:    https://lore.kernel.org/r/20240417170941.797116-9-willy%40infradead.org
patch subject: [PATCH 08/10] ntfs3: Use a folio to read UpCase
config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240419/202404190823.2p1A9tNE-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240419/202404190823.2p1A9tNE-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404190823.2p1A9tNE-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/pagemap.h:11,
                    from lib/buildid.c:7:
   include/linux/highmem.h: In function 'memcpy_from_folio_le16':
>> include/linux/highmem.h:484:22: error: 'i' undeclared (first use in this function)
     484 |                 for (i = 0; i < chunk / sizeof(*to); i++)
         |                      ^
   include/linux/highmem.h:484:22: note: each undeclared identifier is reported only once for each function it appears in
--
   In file included from include/linux/bvec.h:10,
                    from include/linux/skbuff.h:17,
                    from include/linux/tcp.h:17,
                    from include/linux/ipv6.h:101,
                    from include/net/addrconf.h:61,
                    from lib/vsprintf.c:41:
   include/linux/highmem.h: In function 'memcpy_from_folio_le16':
>> include/linux/highmem.h:484:22: error: 'i' undeclared (first use in this function)
     484 |                 for (i = 0; i < chunk / sizeof(*to); i++)
         |                      ^
   include/linux/highmem.h:484:22: note: each undeclared identifier is reported only once for each function it appears in
   lib/vsprintf.c: In function 'va_format':
   lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
    1683 |         buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
         |         ^~~


vim +/i +484 include/linux/highmem.h

   469	
   470	#ifdef __BIG_ENDIAN
   471	static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
   472			size_t offset, size_t len)
   473	{
   474		VM_BUG_ON(offset + len > folio_size(folio));
   475	
   476		do {
   477			const __le16 *from = kmap_local_folio(folio, offset);
   478			size_t chunk = len;
   479	
   480			if (folio_test_highmem(folio) &&
   481			    chunk > PAGE_SIZE - offset_in_page(offset))
   482				chunk = PAGE_SIZE - offset_in_page(offset);
   483	
 > 484			for (i = 0; i < chunk / sizeof(*to); i++)
   485				*to++ = le16_to_cpu(*from++);
   486			kunmap_local(from);
   487	
   488			to += chunk / sizeof(*to);
   489			offset += chunk;
   490			len -= chunk;
   491		} while (len > 0);
   492	}
   493	#else
   494	static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
   495			size_t offset, size_t len)
   496	{
   497		memcpy_from_folio((char *)to, folio, offset, len);
   498	}
   499	#endif
   500	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 08/10] ntfs3: Use a folio to read UpCase
  2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
  2024-04-17 17:32   ` Matthew Wilcox
  2024-04-19  0:30   ` kernel test robot
@ 2024-04-19  1:12   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2024-04-19  1:12 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Konstantin Komarov
  Cc: llvm, oe-kbuild-all, Matthew Wilcox (Oracle), ntfs3, linux-fsdevel

Hi Matthew,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.9-rc4]
[cannot apply to next-20240418]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/ntfs3-Convert-ntfs_read_folio-to-use-a-folio/20240418-011140
base:   linus/master
patch link:    https://lore.kernel.org/r/20240417170941.797116-9-willy%40infradead.org
patch subject: [PATCH 08/10] ntfs3: Use a folio to read UpCase
config: s390-allnoconfig (https://download.01.org/0day-ci/archive/20240419/202404190841.KPS2VQgB-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 7089c359a3845323f6f30c44a47dd901f2edfe63)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240419/202404190841.KPS2VQgB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404190841.KPS2VQgB-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from arch/s390/kernel/asm-offsets.c:11:
   In file included from include/linux/kvm_host.h:16:
   In file included from include/linux/mm.h:2208:
   include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from arch/s390/kernel/asm-offsets.c:11:
   In file included from include/linux/kvm_host.h:19:
   In file included from include/linux/msi.h:27:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:78:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from arch/s390/kernel/asm-offsets.c:11:
   In file included from include/linux/kvm_host.h:19:
   In file included from include/linux/msi.h:27:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:78:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from arch/s390/kernel/asm-offsets.c:11:
   In file included from include/linux/kvm_host.h:19:
   In file included from include/linux/msi.h:27:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:78:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     692 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     700 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     708 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     717 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     726 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     735 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   In file included from arch/s390/kernel/asm-offsets.c:11:
   In file included from include/linux/kvm_host.h:41:
   In file included from include/linux/kvm_para.h:5:
   In file included from include/uapi/linux/kvm_para.h:37:
   In file included from arch/s390/include/asm/kvm_para.h:25:
   In file included from arch/s390/include/asm/diag.h:12:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
>> include/linux/highmem.h:484:8: error: use of undeclared identifier 'i'
     484 |                 for (i = 0; i < chunk / sizeof(*to); i++)
         |                      ^
   include/linux/highmem.h:484:15: error: use of undeclared identifier 'i'
     484 |                 for (i = 0; i < chunk / sizeof(*to); i++)
         |                             ^
   include/linux/highmem.h:484:40: error: use of undeclared identifier 'i'
     484 |                 for (i = 0; i < chunk / sizeof(*to); i++)
         |                                                      ^
   13 warnings and 3 errors generated.
   make[3]: *** [scripts/Makefile.build:117: arch/s390/kernel/asm-offsets.s] Error 1
   make[3]: Target 'prepare' not remade because of errors.
   make[2]: *** [Makefile:1197: prepare0] Error 2
   make[2]: Target 'prepare' not remade because of errors.
   make[1]: *** [Makefile:240: __sub-make] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:240: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.


vim +/i +484 include/linux/highmem.h

   469	
   470	#ifdef __BIG_ENDIAN
   471	static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
   472			size_t offset, size_t len)
   473	{
   474		VM_BUG_ON(offset + len > folio_size(folio));
   475	
   476		do {
   477			const __le16 *from = kmap_local_folio(folio, offset);
   478			size_t chunk = len;
   479	
   480			if (folio_test_highmem(folio) &&
   481			    chunk > PAGE_SIZE - offset_in_page(offset))
   482				chunk = PAGE_SIZE - offset_in_page(offset);
   483	
 > 484			for (i = 0; i < chunk / sizeof(*to); i++)
   485				*to++ = le16_to_cpu(*from++);
   486			kunmap_local(from);
   487	
   488			to += chunk / sizeof(*to);
   489			offset += chunk;
   490			len -= chunk;
   491		} while (len > 0);
   492	}
   493	#else
   494	static inline void memcpy_from_folio_le16(u16 *to, struct folio *folio,
   495			size_t offset, size_t len)
   496	{
   497		memcpy_from_folio((char *)to, folio, offset, len);
   498	}
   499	#endif
   500	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2024-04-19  1:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 01/10] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 02/10] ntfs3: Convert ntfs_write_begin " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 03/10] ntfs3: Convert attr_data_read_resident() to take " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 04/10] ntfs3: Convert ntfs_write_end() to work on " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 05/10] ntfs3: Convert attr_data_write_resident to use " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 06/10] ntfs3: Convert attr_make_nonresident " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 07/10] ntfs3: Convert reading $AttrDef to use folios Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
2024-04-17 17:32   ` Matthew Wilcox
2024-04-19  0:30   ` kernel test robot
2024-04-19  1:12   ` kernel test robot
2024-04-17 17:09 ` [PATCH 09/10] ntfs3: Remove inode_write_data() Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 10/10] ntfs3: Remove ntfs_map_page and ntfs_unmap_page Matthew Wilcox (Oracle)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.