Commit a27c0858 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'erofs-for-5.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs

Pull erofs fixes from Gao Xiang:

 - fix unsafe pagevec reuse which could cause unexpected behaviors

 - get rid of the unused DELAYEDALLOC strategy that has been replaced by
   TRYALLOC

* tag 'erofs-for-5.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: remove useless cache strategy of DELAYEDALLOC
  erofs: fix unsafe pagevec reuse of hooked pclusters
parents 5664896b 4c7e4255
...@@ -96,16 +96,9 @@ static void z_erofs_free_pcluster(struct z_erofs_pcluster *pcl) ...@@ -96,16 +96,9 @@ static void z_erofs_free_pcluster(struct z_erofs_pcluster *pcl)
DBG_BUGON(1); DBG_BUGON(1);
} }
/*
* a compressed_pages[] placeholder in order to avoid
* being filled with file pages for in-place decompression.
*/
#define PAGE_UNALLOCATED ((void *)0x5F0E4B1D)
/* how to allocate cached pages for a pcluster */ /* how to allocate cached pages for a pcluster */
enum z_erofs_cache_alloctype { enum z_erofs_cache_alloctype {
DONTALLOC, /* don't allocate any cached pages */ DONTALLOC, /* don't allocate any cached pages */
DELAYEDALLOC, /* delayed allocation (at the time of submitting io) */
/* /*
* try to use cached I/O if page allocation succeeds or fallback * try to use cached I/O if page allocation succeeds or fallback
* to in-place I/O instead to avoid any direct reclaim. * to in-place I/O instead to avoid any direct reclaim.
...@@ -267,10 +260,6 @@ static void preload_compressed_pages(struct z_erofs_collector *clt, ...@@ -267,10 +260,6 @@ static void preload_compressed_pages(struct z_erofs_collector *clt,
/* I/O is needed, no possible to decompress directly */ /* I/O is needed, no possible to decompress directly */
standalone = false; standalone = false;
switch (type) { switch (type) {
case DELAYEDALLOC:
t = tagptr_init(compressed_page_t,
PAGE_UNALLOCATED);
break;
case TRYALLOC: case TRYALLOC:
newpage = erofs_allocpage(pagepool, gfp); newpage = erofs_allocpage(pagepool, gfp);
if (!newpage) if (!newpage)
...@@ -371,8 +360,8 @@ static bool z_erofs_try_inplace_io(struct z_erofs_collector *clt, ...@@ -371,8 +360,8 @@ static bool z_erofs_try_inplace_io(struct z_erofs_collector *clt,
/* callers must be with collection lock held */ /* callers must be with collection lock held */
static int z_erofs_attach_page(struct z_erofs_collector *clt, static int z_erofs_attach_page(struct z_erofs_collector *clt,
struct page *page, struct page *page, enum z_erofs_page_type type,
enum z_erofs_page_type type) bool pvec_safereuse)
{ {
int ret; int ret;
...@@ -382,9 +371,9 @@ static int z_erofs_attach_page(struct z_erofs_collector *clt, ...@@ -382,9 +371,9 @@ static int z_erofs_attach_page(struct z_erofs_collector *clt,
z_erofs_try_inplace_io(clt, page)) z_erofs_try_inplace_io(clt, page))
return 0; return 0;
ret = z_erofs_pagevec_enqueue(&clt->vector, page, type); ret = z_erofs_pagevec_enqueue(&clt->vector, page, type,
pvec_safereuse);
clt->cl->vcnt += (unsigned int)ret; clt->cl->vcnt += (unsigned int)ret;
return ret ? 0 : -EAGAIN; return ret ? 0 : -EAGAIN;
} }
...@@ -727,7 +716,8 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, ...@@ -727,7 +716,8 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
tight &= (clt->mode >= COLLECT_PRIMARY_FOLLOWED); tight &= (clt->mode >= COLLECT_PRIMARY_FOLLOWED);
retry: retry:
err = z_erofs_attach_page(clt, page, page_type); err = z_erofs_attach_page(clt, page, page_type,
clt->mode >= COLLECT_PRIMARY_FOLLOWED);
/* should allocate an additional short-lived page for pagevec */ /* should allocate an additional short-lived page for pagevec */
if (err == -EAGAIN) { if (err == -EAGAIN) {
struct page *const newpage = struct page *const newpage =
...@@ -735,7 +725,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, ...@@ -735,7 +725,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
set_page_private(newpage, Z_EROFS_SHORTLIVED_PAGE); set_page_private(newpage, Z_EROFS_SHORTLIVED_PAGE);
err = z_erofs_attach_page(clt, newpage, err = z_erofs_attach_page(clt, newpage,
Z_EROFS_PAGE_TYPE_EXCLUSIVE); Z_EROFS_PAGE_TYPE_EXCLUSIVE, true);
if (!err) if (!err)
goto retry; goto retry;
} }
...@@ -1089,15 +1079,6 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl, ...@@ -1089,15 +1079,6 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl,
if (!page) if (!page)
goto out_allocpage; goto out_allocpage;
/*
* the cached page has not been allocated and
* an placeholder is out there, prepare it now.
*/
if (page == PAGE_UNALLOCATED) {
tocache = true;
goto out_allocpage;
}
/* process the target tagged pointer */ /* process the target tagged pointer */
t = tagptr_init(compressed_page_t, page); t = tagptr_init(compressed_page_t, page);
justfound = tagptr_unfold_tags(t); justfound = tagptr_unfold_tags(t);
......
...@@ -179,4 +179,3 @@ static inline void z_erofs_onlinepage_endio(struct page *page) ...@@ -179,4 +179,3 @@ static inline void z_erofs_onlinepage_endio(struct page *page)
#define Z_EROFS_VMAP_GLOBAL_PAGES 2048 #define Z_EROFS_VMAP_GLOBAL_PAGES 2048
#endif #endif
...@@ -106,11 +106,18 @@ static inline void z_erofs_pagevec_ctor_init(struct z_erofs_pagevec_ctor *ctor, ...@@ -106,11 +106,18 @@ static inline void z_erofs_pagevec_ctor_init(struct z_erofs_pagevec_ctor *ctor,
static inline bool z_erofs_pagevec_enqueue(struct z_erofs_pagevec_ctor *ctor, static inline bool z_erofs_pagevec_enqueue(struct z_erofs_pagevec_ctor *ctor,
struct page *page, struct page *page,
enum z_erofs_page_type type) enum z_erofs_page_type type,
bool pvec_safereuse)
{ {
if (!ctor->next && type) if (!ctor->next) {
if (ctor->index + 1 == ctor->nr) /* some pages cannot be reused as pvec safely without I/O */
if (type == Z_EROFS_PAGE_TYPE_EXCLUSIVE && !pvec_safereuse)
type = Z_EROFS_VLE_PAGE_TYPE_TAIL_SHARED;
if (type != Z_EROFS_PAGE_TYPE_EXCLUSIVE &&
ctor->index + 1 == ctor->nr)
return false; return false;
}
if (ctor->index >= ctor->nr) if (ctor->index >= ctor->nr)
z_erofs_pagevec_ctor_pagedown(ctor, false); z_erofs_pagevec_ctor_pagedown(ctor, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment