Convert (most of) ntfs3 to use folios
Subsystems (2)
v2 cover Convert (most of) ntfs3 to use folios
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.
v2:
- Rebase on next-20240422
- Drop "Convert reading $AttrDef to use folios", "Use a folio to read UpCase", "Remove inode_write_data()" and "Remove ntfs_map_page and ntfs_unmap_page" due to changes.
- Add "Convert inode_read_data() to use folios", "Remove calls to set/clear the error flag", "Convert attr_wof_frame_info() to use a folio", "Convert ntfs_get_frame_pages() to use a folio", "Convert ni_readpage_cmpr() to take a folio"
Matthew Wilcox (Oracle) (11):
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 inode_read_data() to use folios
ntfs3: Remove calls to set/clear the error flag
ntfs3: Convert attr_wof_frame_info() to use a folio
ntfs3: Convert ntfs_get_frame_pages() to use a folio
ntfs3: Convert ni_readpage_cmpr() to take a folio
fs/ntfs3/attrib.c | 94 ++++++++++++++++++++-------------------------- fs/ntfs3/file.c | 17 +++++---- fs/ntfs3/frecord.c | 29 +++++++------- fs/ntfs3/inode.c | 73 ++++++++++++++++++----------------- fs/ntfs3/ntfs_fs.h | 8 ++-- 5 files changed, 102 insertions(+), 119 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/11 ntfs3: Convert ntfs_read_folio to use a folio
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.
--- fs/ntfs3/inode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/ntfs3/inode.c +4 -5
@@ -710,25 +710,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; }
Signature · 1 line
2.43.0
PATCH v2 2/11 ntfs3: Convert ntfs_write_begin to use a folio
In reply to Matthew Wilcox (Oracle)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.
--- fs/ntfs3/inode.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/ntfs3/inode.c +9 -8
@@ -913,24 +913,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;
Signature · 1 line
2.43.0
PATCH v2 3/11 ntfs3: Convert attr_data_read_resident() to take a folio
In reply to Matthew Wilcox (Oracle)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.
--- fs/ntfs3/attrib.c | 27 +++++++++------------------ fs/ntfs3/inode.c | 6 +++--- fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 13 insertions(+), 22 deletions(-)
fs/ntfs3/attrib.c +9 -18
@@ -1240,11 +1240,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)
@@ -1253,25 +1254,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 ; }
fs/ntfs3/inode.c +3 -3
@@ -583,7 +583,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, err =0 ; }else {ni_lock (ni); - err =attr_data_read_resident (ni, &folio->page); + err =attr_data_read_resident (ni, folio);ni_unlock (ni);if (!err)
@@ -717,7 +717,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);
@@ -923,7 +923,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) {
fs/ntfs3/ntfs_fs.h +1 -1
@@ -445,7 +445,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,
Signature · 1 line
2.43.0
PATCH v2 4/11 ntfs3: Convert ntfs_write_end() to work on a folio
In reply to Matthew Wilcox (Oracle)Convert the passed page back into a folio and use the folio APIs, saving a few hidden calls to compound_head().
--- fs/ntfs3/inode.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/ntfs3/inode.c +8 -7
@@ -950,6 +950,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;
@@ -961,23 +962,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);
Signature · 1 line
2.43.0
PATCH v2 5/11 ntfs3: Convert attr_data_write_resident to use a folio
In reply to Matthew Wilcox (Oracle)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.
--- fs/ntfs3/attrib.c | 12 ++++-------- fs/ntfs3/inode.c | 4 ++-- fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-)
fs/ntfs3/attrib.c +4 -8
@@ -1267,7 +1267,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;
@@ -1283,17 +1283,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;
fs/ntfs3/inode.c +2 -2
@@ -871,7 +871,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 )
@@ -959,7 +959,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);
fs/ntfs3/ntfs_fs.h +1 -1
@@ -446,7 +446,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);
Signature · 1 line
2.43.0
PATCH v2 6/11 ntfs3: Convert attr_make_nonresident to use a folio
In reply to Matthew Wilcox (Oracle)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().
--- fs/ntfs3/attrib.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
fs/ntfs3/attrib.c +12 -14
@@ -302,22 +302,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); } }
Signature · 1 line
2.43.0
PATCH v2 7/11 ntfs3: Convert inode_read_data() to use folios
In reply to Matthew Wilcox (Oracle)This is now large folio safe, although we're not enabling large folios yet. It does eliminate a use of kmap().
--- fs/ntfs3/inode.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
fs/ntfs3/inode.c +12 -14
@@ -1103,25 +1103,23 @@ int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,*/ int inode_read_data (struct inode *inode,void *data,size_t bytes) { -pgoff_t idx; +pgoff_t idx =0 ;struct address_space *mapping = inode->i_mapping; -for (idx =0 ; bytes; idx++) { -size_t op = bytes >PAGE_SIZE ?PAGE_SIZE : bytes; -struct page *page =read_mapping_page (mapping, idx,NULL ); -void *kaddr; +while (bytes) { +struct folio *folio =read_mapping_folio (mapping, idx,NULL ); +size_t nr; -if (IS_ERR (page)) -return PTR_ERR (page); +if (IS_ERR (folio)) +return PTR_ERR (folio); - kaddr =kmap_atomic (page); -memcpy (data, kaddr, op); -kunmap_atomic (kaddr); - -put_page (page); + nr =min (bytes,folio_size (folio)); +memcpy_from_folio (data, folio,0 , nr); + data +=folio_size (folio); + idx +=folio_nr_pages (folio); +folio_put (folio); - bytes -= op; - data =Add2Ptr (data,PAGE_SIZE ); + bytes -= nr; }return 0 ; }
Signature · 1 line
2.43.0
PATCH v2 8/11 ntfs3: Remove calls to set/clear the error flag
In reply to Matthew Wilcox (Oracle)Nobody checks the error flag on ntfs3 folios, so stop setting and clearing it.
--- fs/ntfs3/frecord.c | 4 ---- 1 file changed, 4 deletions(-)
fs/ntfs3/frecord.c +0 -4
@@ -2143,9 +2143,6 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) err =ni_read_frame (ni, frame_vbo, pages, pages_per_frame); out1: -if (err) -SetPageError (page); -for (i =0 ; i < pages_per_frame; i++) { pg = pages[i];if (i == idx || !pg)
@@ -2718,7 +2715,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,for (i =0 ; i < pages_per_frame; i++) { pg = pages[i];kunmap (pg); -ClearPageError (pg);SetPageUptodate (pg); }
Signature · 1 line
2.43.0
PATCH v2 9/11 ntfs3: Convert attr_wof_frame_info() to use a folio
In reply to Matthew Wilcox (Oracle)This involves converting all users of offs_page to offs_folio, but it's worth it because we get rid of a lot of hidden calls to compound_head(). We continue to use order-0 folios here, and convert back to a struct page to call ntfs_bio_pages().
--- fs/ntfs3/attrib.c | 29 +++++++++++++++-------------- fs/ntfs3/frecord.c | 12 ++++++------ fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-)
fs/ntfs3/attrib.c +15 -14
@@ -1380,7 +1380,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,u32 voff;u8 bytes_per_off;char *addr; -struct page *page; +struct folio *folio;int i, err;__le32 *off32;__le64 *off64;
@@ -1425,18 +1425,18 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, wof_size =le64_to_cpu (attr->nres.data_size);down_write (&ni->file.run_lock); - page = ni->file.offs_page; -if (!page) { - page =alloc_page (GFP_KERNEL ); -if (!page) { + folio = ni->file.offs_folio; +if (!folio) { + folio =folio_alloc (GFP_KERNEL ,0 ); +if (!folio) { err = -ENOMEM ; goto out; } - page->index =-1 ; - ni->file.offs_page = page; + folio->index =-1 ; + ni->file.offs_folio = folio; } -lock_page (page); - addr =page_address (page); +folio_lock (folio); + addr =folio_address (folio);if (vbo[1 ]) { voff = vbo[1 ] & (PAGE_SIZE -1 );
@@ -1452,7 +1452,8 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, do { pgoff_t index = vbo[i] >> PAGE_SHIFT; - if (index != page->index) { + if (index != folio->index) { + struct page *page = &folio->page; u64 from = vbo[i] & ~(u64)(PAGE_SIZE - 1); u64 to = min(from + PAGE_SIZE, wof_size);
@@ -1465,10 +1466,10 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, err =ntfs_bio_pages (sbi, run, &page,1 , from, to - from,REQ_OP_READ );if (err) { - page->index =-1 ; + folio->index =-1 ; goto out1; } - page->index = index; + folio->index = index; }if (i) {
@@ -1506,7 +1507,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, *ondisk_size = off[1 ] - off[0 ]; out1: -unlock_page (page); +folio_unlock (folio); out:up_write (&ni->file.run_lock);return err;
@@ -2645,4 +2646,4 @@ bool attr_check(const struct ATTRIB *attr, struct ntfs_sb_info *sbi,ntfs_set_state (sbi,NTFS_DIRTY_ERROR );return false; -} +}
fs/ntfs3/frecord.c +6 -6
@@ -122,10 +122,10 @@ void ni_clear(struct ntfs_inode *ni)else {run_close (&ni->file.run);#ifdef CONFIG_NTFS3_LZX_XPRESS -if (ni->file.offs_page) { +if (ni->file.offs_folio) {/* On-demand allocated page for offsets. */ -put_page (ni->file.offs_page); - ni->file.offs_page =NULL ; +folio_put (ni->file.offs_folio); + ni->file.offs_folio =NULL ; }#endif }
@@ -2359,9 +2359,9 @@ int ni_decompress_file(struct ntfs_inode *ni)/* Clear cached flag. */ ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK ; -if (ni->file.offs_page) { -put_page (ni->file.offs_page); - ni->file.offs_page =NULL ; +if (ni->file.offs_folio) { +folio_put (ni->file.offs_folio); + ni->file.offs_folio =NULL ; } mapping->a_ops = &ntfs_aops;
fs/ntfs3/ntfs_fs.h +1 -1
@@ -394,7 +394,7 @@ struct ntfs_inode {struct rw_semaphore run_lock;struct runs_tree run;#ifdef CONFIG_NTFS3_LZX_XPRESS -struct page *offs_page; +struct folio *offs_folio;#endif } file; };
Signature · 1 line
2.43.0
PATCH v2 10/11 ntfs3: Convert ntfs_get_frame_pages() to use a folio
In reply to Matthew Wilcox (Oracle)The function still takes an array of pages, but use a folio internally. This function would deadlock against itself if used with large folios (as it locks each page), so we can be a little sloppy with the conversion back from folio to page for now.
--- fs/ntfs3/file.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/ntfs3/file.c +9 -8
@@ -824,23 +824,24 @@ static int ntfs_get_frame_pages(struct address_space *mapping, pgoff_t index, *frame_uptodate = true;for (npages =0 ; npages < pages_per_frame; npages++, index++) { -struct page *page; +struct folio *folio; - page =find_or_create_page (mapping, index, gfp_mask); -if (!page) { + folio =__filemap_get_folio (mapping, index, +FGP_LOCK |FGP_ACCESSED |FGP_CREAT , gfp_mask); +if (IS_ERR (folio)) {while (npages--) { - page = pages[npages]; -unlock_page (page); -put_page (page); + folio =page_folio (pages[npages]); +folio_unlock (folio); +folio_put (folio); }return -ENOMEM ; } -if (!PageUptodate (page)) +if (!folio_test_uptodate (folio)) *frame_uptodate = false; - pages[npages] = page; + pages[npages] = &folio->page; }return 0 ;
Signature · 1 line
2.43.0
PATCH v2 11/11 ntfs3: Convert ni_readpage_cmpr() to take a folio
In reply to Matthew Wilcox (Oracle)We still use an array of pages for the decompression, but this removes a few calls to compound_head().
--- fs/ntfs3/frecord.c | 13 +++++++------ fs/ntfs3/inode.c | 2 +- fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
fs/ntfs3/frecord.c +7 -6
@@ -2085,12 +2085,12 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,* When decompressing, we typically obtain more than one page per reference. * We inject the additional pages into the page cache. */ -int ni_readpage_cmpr (struct ntfs_inode *ni,struct page *page) +int ni_readpage_cmpr (struct ntfs_inode *ni,struct folio *folio) {int err;struct ntfs_sb_info *sbi = ni->mi.sbi; -struct address_space *mapping = page->mapping; -pgoff_t index = page->index; +struct address_space *mapping = folio->mapping; +pgoff_t index = folio->index;u64 frame_vbo, vbo = (u64 )index <<PAGE_SHIFT ;struct page **pages =NULL ;/* Array of at most 16 pages. stack? */ u8 frame_bits;
@@ -2100,7 +2100,8 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page)struct page *pg;if (vbo >=i_size_read (&ni->vfs_inode)) { -SetPageUptodate (page); +folio_zero_range (folio,0 ,folio_size (folio)); +folio_mark_uptodate (folio); err =0 ; goto out; }
@@ -2124,7 +2125,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) goto out; } - pages[idx] = page; + pages[idx] = &folio->page; index = frame_vbo >>PAGE_SHIFT ; gfp_mask =mapping_gfp_mask (mapping);
@@ -2154,7 +2155,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) out:/* At this point, err contains 0 or -EIO depending on the "critical" page. */ kfree (pages); -unlock_page (page); +folio_unlock (folio);return err; }
fs/ntfs3/inode.c +1 -1
@@ -727,7 +727,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)if (is_compressed (ni)) {ni_lock (ni); - err =ni_readpage_cmpr (ni, &folio->page); + err =ni_readpage_cmpr (ni, folio);ni_unlock (ni);return err; }
fs/ntfs3/ntfs_fs.h +1 -1
@@ -577,7 +577,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint);#define _ni_write_inode (i, w) ni_write_inode(i, w, __func__)int ni_fiemap (struct ntfs_inode *ni,struct fiemap_extent_info *fieinfo,__u64 vbo,__u64 len); -int ni_readpage_cmpr (struct ntfs_inode *ni,struct page *page); +int ni_readpage_cmpr (struct ntfs_inode *ni,struct folio *folio);int ni_decompress_file (struct ntfs_inode *ni);int ni_read_frame (struct ntfs_inode *ni,u64 frame_vbo,struct page **pages,u32 pages_per_frame);
Signature · 1 line
2.43.0
Konstantin Komarov
maintainerQuoted 28 lines · Matthew Wilcox (Oracle)
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.
v2:
- Rebase on next-20240422
- Drop "Convert reading $AttrDef to use folios", "Use a folio to read UpCase", "Removeinode_write_data()" and "Removentfs_map_pageandntfs_unmap_page" due to changes.
- Add "Convertinode_read_data()to use folios", "Remove calls to set/clear the error flag", "Convertattr_wof_frame_info()to use a folio", "Convertntfs_get_frame_pages()to use a folio", "Convertni_readpage_cmpr()to take a folio"Matthew Wilcox (Oracle) (11):
ntfs3: Convertntfs_read_folioto use a folio
ntfs3: Convertntfs_write_beginto use a folio
ntfs3: Convertattr_data_read_resident()to take a folio
ntfs3: Convertntfs_write_end()to work on a folio
ntfs3: Convertattr_data_write_residentto use a folio
ntfs3: Convertattr_make_nonresidentto use a folio
ntfs3: Convertinode_read_data()to use folios
ntfs3: Remove calls to set/clear the error flag
ntfs3: Convertattr_wof_frame_info()to use a folio
ntfs3: Convertntfs_get_frame_pages()to use a folio
ntfs3: Convertni_readpage_cmpr()to take a folio
Quoted 7 lines
fs/ntfs3/attrib.c | 94 ++++++++++++++++++++-------------------------- fs/ntfs3/file.c | 17 +++++---- fs/ntfs3/frecord.c | 29 +++++++------- fs/ntfs3/inode.c | 73 ++++++++++++++++++----------------- fs/ntfs3/ntfs_fs.h | 8 ++-- 5 files changed, 102 insertions(+), 119 deletions(-)
Hi Matthew,
We have started testing the switch to folio as you proposed in v1. Some of our tests went down.
After adapting I will add your patches with some minor changes.