Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 6e297fc3 authored by Gao Xiang's avatar Gao Xiang Committed by Michael Bestas
Browse files

UPSTREAM: erofs: insert to managed cache after adding to pcl

Previously, it could be some concern to call add_to_page_cache_lru()
with page->mapping == Z_EROFS_MAPPING_STAGING (!= NULL).

In contrast, page->private is used instead now, so partially revert
commit 5ddcee1f3a1c ("erofs: get rid of __stagingpage_alloc helper")
with some adaption for simplicity.

Link: https://lore.kernel.org/r/20201208095834.3133565-2-hsiangkao@redhat.com


Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarGao Xiang <hsiangkao@redhat.com>
Signed-off-by: default avatarHuang Jianan <huangjianan@oppo.com>

Bug: 190585249
Change-Id: Ia67c77a85f1e22bce2b1c0f238639fbb615d613a
(cherry picked from commit bf225074ff211f219cff2166cea17b158a0d06a9)
Signed-off-by: default avatarHuang Jianan <huangjianan@oppo.com>
parent ae779c41
Loading
Loading
Loading
Loading
+9 −17
Original line number Diff line number Diff line
@@ -1065,29 +1065,21 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl,
	put_page(page);
out_allocpage:
	page = erofs_allocpage(pagepool, gfp | __GFP_NOFAIL);
	if (!tocache || add_to_page_cache_lru(page, mc, index + nr, gfp)) {
		/* turn into temporary page if fails */
		set_page_private(page, Z_EROFS_SHORTLIVED_PAGE);
		tocache = false;
	}

	if (oldpage != cmpxchg(&pcl->compressed_pages[nr], oldpage, page)) {
		if (tocache) {
			/* since it added to managed cache successfully */
			unlock_page(page);
			put_page(page);
		} else {
		list_add(&page->lru, pagepool);
		}
		cond_resched();
		goto repeat;
	}

	if (tocache) {
	if (!tocache || add_to_page_cache_lru(page, mc, index + nr, gfp)) {
		/* turn into temporary page if fails (1 ref) */
		set_page_private(page, Z_EROFS_SHORTLIVED_PAGE);
		goto out;
	}
	attach_page_private(page, pcl);
		/* drop a ref added by allocpage (then we have 2 refs here) */
	/* drop a refcount added by allocpage (then we have 2 refs here) */
	put_page(page);
	}

out:	/* the only exit (for tracing and debugging) */
	return page;
}