Skip to content

Commit 2da4c51

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
jffs2: Use a folio in jffs2_garbage_collect_dnode()
Call read_cache_folio() instead of read_cache_page() to get the folio containing the page. No attempt is made here to support large folios as I assume that will never be interesting for jffs2. Includes a switch from kmap to kmap_local which looks safe. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://lore.kernel.org/r/20240814195915.249871-3-willy@infradead.org Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent bcc7d11 commit 2da4c51

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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)