diff options
author | Gao Xiang <gaoxiang25@huawei.com> | 2019-03-25 11:40:08 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-26 05:51:17 +0900 |
commit | d61fbb6b163494219335a25812dab9acb291c4b6 (patch) | |
tree | ed28a0ccd5da4dc389ee6ab3ebb8c2a379421b17 | |
parent | 11152496021ea872dac150e0fdad610f6e63773d (diff) |
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: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/erofs/internal.h | 7 | ||||
-rw-r--r-- | drivers/staging/erofs/unzip_vle.c | 31 |
2 files changed, 16 insertions, 22 deletions
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 1286b98ffd0a..a66c7d495c35 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -268,8 +268,15 @@ int erofs_try_to_free_cached_page(struct address_space *mapping, struct page *page); #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 #define MNGD_MAPPING(sbi) (NULL) +static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi, + struct page *page) { return false; } #endif #define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES 3 diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 45541be12972..8e720bb882c7 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -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) { const blk_status_t err = bio->bi_status; + struct erofs_sb_info *sbi = NULL; unsigned int i; struct bio_vec *bvec; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *mc = NULL; -#endif struct bvec_iter_all 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) DBG_BUGON(PageUptodate(page)); DBG_BUGON(!page->mapping); -#ifdef EROFS_FS_HAS_MANAGED_CACHE - if (unlikely(!mc && !z_erofs_is_stagingpage(page))) { - struct inode *const inode = page->mapping->host; - struct super_block *const sb = inode->i_sb; + if (unlikely(!sbi && !z_erofs_is_stagingpage(page))) + sbi = EROFS_SB(page->mapping->host->i_sb); - mc = MNGD_MAPPING(EROFS_SB(sb)); - } - - /* - * If mc has not gotten, it equals NULL, - * however, page->mapping never be NULL if working properly. - */ - cachemngd = (page->mapping == mc); -#endif + /* sbi should already be gotten if the page is managed */ + if (sbi) + cachemngd = erofs_page_is_managed(sbi, page); if (unlikely(err)) SetPageError(page); @@ -984,13 +974,11 @@ repeat: DBG_BUGON(!page->mapping); if (!z_erofs_is_stagingpage(page)) { -#ifdef EROFS_FS_HAS_MANAGED_CACHE - if (page->mapping == MNGD_MAPPING(sbi)) { + if (erofs_page_is_managed(sbi, page)) { if (unlikely(!PageUptodate(page))) err = -EIO; continue; } -#endif /* * only if non-head page can be selected @@ -1055,10 +1043,9 @@ out: for (i = 0; i < clusterpages; ++i) { page = compressed_pages[i]; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - if (page->mapping == MNGD_MAPPING(sbi)) + if (erofs_page_is_managed(sbi, page)) continue; -#endif + /* recycle all individual staging pages */ (void)z_erofs_gather_if_stagingpage(page_pool, page); |