Skip to content

Commit 424f8cb

Browse files
committed
Merge patch series "Finish converting jffs2 to folios"
Matthew Wilcox (Oracle) <willy@infradead.org> says: This patch series applies on top of fs-next. After applying these two patches, there are no more references to 'struct page' in jffs2. I obviously haven't tested it at all beyond compilation. * patches from https://lore.kernel.org/r/20240814195915.249871-1-willy@infradead.org: jffs2: Use a folio in jffs2_garbage_collect_dnode() jffs2: Convert jffs2_do_readpage_nolock to take a folio Link: https://lore.kernel.org/r/20240814195915.249871-1-willy@infradead.org Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 3e673d6 + 2da4c51 commit 424f8cb

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

fs/jffs2/file.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,37 +77,35 @@ const struct address_space_operations jffs2_file_address_operations =
7777
.write_end = jffs2_write_end,
7878
};
7979

80-
static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
80+
static int jffs2_do_readpage_nolock(struct inode *inode, struct folio *folio)
8181
{
8282
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
8383
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
84-
unsigned char *pg_buf;
84+
unsigned char *kaddr;
8585
int ret;
8686

8787
jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
88-
__func__, inode->i_ino, pg->index << PAGE_SHIFT);
88+
__func__, inode->i_ino, folio->index << PAGE_SHIFT);
8989

90-
BUG_ON(!PageLocked(pg));
90+
BUG_ON(!folio_test_locked(folio));
9191

92-
pg_buf = kmap(pg);
93-
/* FIXME: Can kmap fail? */
94-
95-
ret = jffs2_read_inode_range(c, f, pg_buf, pg->index << PAGE_SHIFT,
92+
kaddr = kmap_local_folio(folio, 0);
93+
ret = jffs2_read_inode_range(c, f, kaddr, folio->index << PAGE_SHIFT,
9694
PAGE_SIZE);
95+
kunmap_local(kaddr);
9796

9897
if (!ret)
99-
SetPageUptodate(pg);
98+
folio_mark_uptodate(folio);
10099

101-
flush_dcache_page(pg);
102-
kunmap(pg);
100+
flush_dcache_folio(folio);
103101

104102
jffs2_dbg(2, "readpage finished\n");
105103
return ret;
106104
}
107105

108106
int __jffs2_read_folio(struct file *file, struct folio *folio)
109107
{
110-
int ret = jffs2_do_readpage_nolock(folio->mapping->host, &folio->page);
108+
int ret = jffs2_do_readpage_nolock(folio->mapping->host, folio);
111109
folio_unlock(folio);
112110
return ret;
113111
}
@@ -221,7 +219,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
221219
*/
222220
if (!folio_test_uptodate(folio)) {
223221
mutex_lock(&f->sem);
224-
ret = jffs2_do_readpage_nolock(inode, &folio->page);
222+
ret = jffs2_do_readpage_nolock(inode, folio);
225223
mutex_unlock(&f->sem);
226224
if (ret) {
227225
folio_unlock(folio);

fs/jffs2/gc.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
11711171
uint32_t alloclen, offset, orig_end, orig_start;
11721172
int ret = 0;
11731173
unsigned char *comprbuf = NULL, *writebuf;
1174-
struct page *page;
1174+
struct folio *folio;
11751175
unsigned char *pg_ptr;
11761176

11771177
memset(&ri, 0, sizeof(ri));
@@ -1317,25 +1317,25 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
13171317
BUG_ON(start > orig_start);
13181318
}
13191319

1320-
/* The rules state that we must obtain the page lock *before* f->sem, so
1320+
/* The rules state that we must obtain the folio lock *before* f->sem, so
13211321
* drop f->sem temporarily. Since we also hold c->alloc_sem, nothing's
13221322
* actually going to *change* so we're safe; we only allow reading.
13231323
*
13241324
* It is important to note that jffs2_write_begin() will ensure that its
1325-
* page is marked Uptodate before allocating space. That means that if we
1326-
* end up here trying to GC the *same* page that jffs2_write_begin() is
1327-
* trying to write out, read_cache_page() will not deadlock. */
1325+
* folio is marked uptodate before allocating space. That means that if we
1326+
* end up here trying to GC the *same* folio that jffs2_write_begin() is
1327+
* trying to write out, read_cache_folio() will not deadlock. */
13281328
mutex_unlock(&f->sem);
1329-
page = read_cache_page(inode->i_mapping, start >> PAGE_SHIFT,
1329+
folio = read_cache_folio(inode->i_mapping, start >> PAGE_SHIFT,
13301330
__jffs2_read_folio, NULL);
1331-
if (IS_ERR(page)) {
1332-
pr_warn("read_cache_page() returned error: %ld\n",
1333-
PTR_ERR(page));
1331+
if (IS_ERR(folio)) {
1332+
pr_warn("read_cache_folio() returned error: %ld\n",
1333+
PTR_ERR(folio));
13341334
mutex_lock(&f->sem);
1335-
return PTR_ERR(page);
1335+
return PTR_ERR(folio);
13361336
}
13371337

1338-
pg_ptr = kmap(page);
1338+
pg_ptr = kmap_local_folio(folio, 0);
13391339
mutex_lock(&f->sem);
13401340

13411341
offset = start;
@@ -1400,7 +1400,6 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
14001400
}
14011401
}
14021402

1403-
kunmap(page);
1404-
put_page(page);
1403+
folio_release_kmap(folio, pg_ptr);
14051404
return ret;
14061405
}

0 commit comments

Comments
 (0)