Commit d61fbb6b authored by Gao Xiang's avatar Gao Xiang Committed by Greg Kroah-Hartman

staging: erofs: introduce erofs_page_is_managed()

1) In order to clean up unnecessary
   page->mapping == MNGD_MAPPING(sbi) wrapped by #ifdefs;

2) Needed by "staging: erofs: support IO read error injection".
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarGao Xiang <gaoxiang25@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 11152496
...@@ -268,8 +268,15 @@ int erofs_try_to_free_cached_page(struct address_space *mapping, ...@@ -268,8 +268,15 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
struct page *page); struct page *page);
#define MNGD_MAPPING(sbi) ((sbi)->managed_cache->i_mapping) #define MNGD_MAPPING(sbi) ((sbi)->managed_cache->i_mapping)
static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
struct page *page)
{
return page->mapping == MNGD_MAPPING(sbi);
}
#else #else
#define MNGD_MAPPING(sbi) (NULL) #define MNGD_MAPPING(sbi) (NULL)
static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
struct page *page) { return false; }
#endif #endif
#define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES 3 #define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES 3
......
...@@ -845,11 +845,9 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios) ...@@ -845,11 +845,9 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios)
static inline void z_erofs_vle_read_endio(struct bio *bio) static inline void z_erofs_vle_read_endio(struct bio *bio)
{ {
const blk_status_t err = bio->bi_status; const blk_status_t err = bio->bi_status;
struct erofs_sb_info *sbi = NULL;
unsigned int i; unsigned int i;
struct bio_vec *bvec; struct bio_vec *bvec;
#ifdef EROFS_FS_HAS_MANAGED_CACHE
struct address_space *mc = NULL;
#endif
struct bvec_iter_all iter_all; struct bvec_iter_all iter_all;
bio_for_each_segment_all(bvec, bio, i, iter_all) { bio_for_each_segment_all(bvec, bio, i, iter_all) {
...@@ -859,20 +857,12 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) ...@@ -859,20 +857,12 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
DBG_BUGON(PageUptodate(page)); DBG_BUGON(PageUptodate(page));
DBG_BUGON(!page->mapping); DBG_BUGON(!page->mapping);
#ifdef EROFS_FS_HAS_MANAGED_CACHE if (unlikely(!sbi && !z_erofs_is_stagingpage(page)))
if (unlikely(!mc && !z_erofs_is_stagingpage(page))) { sbi = EROFS_SB(page->mapping->host->i_sb);
struct inode *const inode = page->mapping->host;
struct super_block *const sb = inode->i_sb;
mc = MNGD_MAPPING(EROFS_SB(sb)); /* sbi should already be gotten if the page is managed */
} if (sbi)
cachemngd = erofs_page_is_managed(sbi, page);
/*
* If mc has not gotten, it equals NULL,
* however, page->mapping never be NULL if working properly.
*/
cachemngd = (page->mapping == mc);
#endif
if (unlikely(err)) if (unlikely(err))
SetPageError(page); SetPageError(page);
...@@ -984,13 +974,11 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -984,13 +974,11 @@ static int z_erofs_vle_unzip(struct super_block *sb,
DBG_BUGON(!page->mapping); DBG_BUGON(!page->mapping);
if (!z_erofs_is_stagingpage(page)) { if (!z_erofs_is_stagingpage(page)) {
#ifdef EROFS_FS_HAS_MANAGED_CACHE if (erofs_page_is_managed(sbi, page)) {
if (page->mapping == MNGD_MAPPING(sbi)) {
if (unlikely(!PageUptodate(page))) if (unlikely(!PageUptodate(page)))
err = -EIO; err = -EIO;
continue; continue;
} }
#endif
/* /*
* only if non-head page can be selected * only if non-head page can be selected
...@@ -1055,10 +1043,9 @@ static int z_erofs_vle_unzip(struct super_block *sb, ...@@ -1055,10 +1043,9 @@ static int z_erofs_vle_unzip(struct super_block *sb,
for (i = 0; i < clusterpages; ++i) { for (i = 0; i < clusterpages; ++i) {
page = compressed_pages[i]; page = compressed_pages[i];
#ifdef EROFS_FS_HAS_MANAGED_CACHE if (erofs_page_is_managed(sbi, page))
if (page->mapping == MNGD_MAPPING(sbi))
continue; continue;
#endif
/* recycle all individual staging pages */ /* recycle all individual staging pages */
(void)z_erofs_gather_if_stagingpage(page_pool, page); (void)z_erofs_gather_if_stagingpage(page_pool, page);
......
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