Skip to content

Commit d86f2de

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
romfs: Convert romfs_read_folio() to use a folio
Remove the conversion back to struct page and use the folio APIs instead of the page APIs. It's probably more trouble than it's worth to support large folios in romfs, so there are still PAGE_SIZE assumptions in this function. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent f4c5147 commit d86f2de

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

fs/romfs/super.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,15 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos);
101101
*/
102102
static int romfs_read_folio(struct file *file, struct folio *folio)
103103
{
104-
struct page *page = &folio->page;
105-
struct inode *inode = page->mapping->host;
104+
struct inode *inode = folio->mapping->host;
106105
loff_t offset, size;
107106
unsigned long fillsize, pos;
108107
void *buf;
109108
int ret;
110109

111-
buf = kmap(page);
112-
if (!buf)
113-
return -ENOMEM;
110+
buf = kmap_local_folio(folio, 0);
114111

115-
/* 32 bit warning -- but not for us :) */
116-
offset = page_offset(page);
112+
offset = folio_pos(folio);
117113
size = i_size_read(inode);
118114
fillsize = 0;
119115
ret = 0;
@@ -125,20 +121,14 @@ static int romfs_read_folio(struct file *file, struct folio *folio)
125121

126122
ret = romfs_dev_read(inode->i_sb, pos, buf, fillsize);
127123
if (ret < 0) {
128-
SetPageError(page);
129124
fillsize = 0;
130125
ret = -EIO;
131126
}
132127
}
133128

134-
if (fillsize < PAGE_SIZE)
135-
memset(buf + fillsize, 0, PAGE_SIZE - fillsize);
136-
if (ret == 0)
137-
SetPageUptodate(page);
138-
139-
flush_dcache_page(page);
140-
kunmap(page);
141-
unlock_page(page);
129+
buf = folio_zero_tail(folio, fillsize, buf);
130+
kunmap_local(buf);
131+
folio_end_read(folio, ret == 0);
142132
return ret;
143133
}
144134

0 commit comments

Comments
 (0)