Skip to contentSkip to conversation

f2fs: Make f2fs_readpages readable again

PATCH Superseded Matthew Wilcox 3 participants 7 messages Feb 1, 2020 – Feb 12, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: Make f2fs_readpages readable again

From: "Matthew Wilcox (Oracle)" <[email protected]>

Remove the horrendous ifdeffery by slipping an IS_ENABLED into f2fs_compressed_file().

---
 fs/f2fs/data.c | 6 ------
 fs/f2fs/f2fs.h | 3 ++-
 2 files changed, 2 insertions(+), 7 deletions(-)
fs/f2fs/data.c +0 -6
index 8bd9afa81c54..41156a8f60a7 100644
@@ -2203,7 +2203,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 				goto next_page;
 		}
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_compressed_file(inode)) {
 			/* there are remained comressed pages, submit them */
 			if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
@@ -2230,14 +2229,11 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 			goto next_page;
 		}
 read_single_page:
-#endif
 
 		ret = f2fs_read_single_page(inode, page, max_nr_pages, &map,
 					&bio, &last_block_in_bio, is_readahead);
 		if (ret) {
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 set_error_page:
-#endif
 			SetPageError(page);
 			zero_user_segment(page, 0, PAGE_SIZE);
 			unlock_page(page);
@@ -2246,7 +2242,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 		if (pages)
 			put_page(page);
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_compressed_file(inode)) {
 			/* last page */
 			if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
@@ -2257,7 +2252,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 				f2fs_destroy_compress_ctx(&cc);
 			}
 		}
-#endif
 	}
 	BUG_ON(pages && !list_empty(pages));
 	if (bio)
fs/f2fs/f2fs.h +2 -1
index 5355be6b6755..398d5a1f2867 100644
@@ -2706,7 +2706,8 @@ static inline int f2fs_has_inline_xattr(struct inode *inode)
 
 static inline int f2fs_compressed_file(struct inode *inode)
 {
-	return S_ISREG(inode->i_mode) &&
+	return IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) &&
+		S_ISREG(inode->i_mode) &&
 		is_inode_flag_set(inode, FI_COMPRESSED_FILE);
 }
 
Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/1 f2fs: Make f2fs_readpages readable again

Remove the horrendous ifdeffery by slipping an IS_ENABLED into f2fs_compressed_file().

---
v2: Fix compilation by adding more dummy functions

 fs/f2fs/data.c |  6 ------
 fs/f2fs/f2fs.h | 10 +++++++++-
 2 files changed, 9 insertions(+), 7 deletions(-)
fs/f2fs/data.c +0 -6
index 8bd9afa81c54..41156a8f60a7 100644
@@ -2203,7 +2203,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 				goto next_page;
 		}
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_compressed_file(inode)) {
 			/* there are remained comressed pages, submit them */
 			if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
@@ -2230,14 +2229,11 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 			goto next_page;
 		}
 read_single_page:
-#endif
 
 		ret = f2fs_read_single_page(inode, page, max_nr_pages, &map,
 					&bio, &last_block_in_bio, is_readahead);
 		if (ret) {
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 set_error_page:
-#endif
 			SetPageError(page);
 			zero_user_segment(page, 0, PAGE_SIZE);
 			unlock_page(page);
@@ -2246,7 +2242,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 		if (pages)
 			put_page(page);
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_compressed_file(inode)) {
 			/* last page */
 			if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
@@ -2257,7 +2252,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 				f2fs_destroy_compress_ctx(&cc);
 			}
 		}
-#endif
 	}
 	BUG_ON(pages && !list_empty(pages));
 	if (bio)
fs/f2fs/f2fs.h +9 -1
index 5355be6b6755..e90d2b3f1d2d 100644
@@ -2706,7 +2706,8 @@ static inline int f2fs_has_inline_xattr(struct inode *inode)
 
 static inline int f2fs_compressed_file(struct inode *inode)
 {
-	return S_ISREG(inode->i_mode) &&
+	return IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) &&
+		S_ISREG(inode->i_mode) &&
 		is_inode_flag_set(inode, FI_COMPRESSED_FILE);
 }
 
@@ -3797,6 +3798,13 @@ static inline struct page *f2fs_compress_control_page(struct page *page)
 	WARN_ON_ONCE(1);
 	return ERR_PTR(-EINVAL);
 }
+#define f2fs_cluster_can_merge_page(cc, index)	false
+#define f2fs_read_multi_pages(cc, bio, nr_pages, last, is_ra) 0
+#define f2fs_init_compress_ctx(cc) 0
+#define f2fs_destroy_compress_ctx(cc) (void)0
+#define f2fs_cluster_is_empty(cc) true
+#define f2fs_compress_ctx_add_page(cc, page) (void)0
+#define f2fs_is_compressed_cluster(cc, index) false
 #endif
 
 static inline void set_compress_context(struct inode *inode)
Signature · 1 line
2.24.1
#2 lore raw
Quoted 3 lines · Matthew Wilcox

Remove the horrendous ifdeffery by slipping an IS_ENABLED into f2fs_compressed_file().

I'd like to suggest to use

if (IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) && f2fs_compressed_file(inode))

here to clean up f2fs_readpages' codes.

Otherwise, f2fs module w/o compression support will not recognize compressed file in most other cases if we add IS_ENABLED() condition into f2fs_compressed_file().

Thanks,

Quoted 81 lines

---
v2: Fix compilation by adding more dummy functions

 fs/f2fs/data.c |  6 ------
 fs/f2fs/f2fs.h | 10 +++++++++-
 2 files changed, 9 insertions(+), 7 deletions(-)
fs/f2fs/data.c +0 -6
index 8bd9afa81c54..41156a8f60a7 100644
@@ -2203,7 +2203,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 				goto next_page;
 		}
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_compressed_file(inode)) {
 			/* there are remained comressed pages, submit them */
 			if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
@@ -2230,14 +2229,11 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 			goto next_page;
 		}
 read_single_page:
-#endif
 
 		ret = f2fs_read_single_page(inode, page, max_nr_pages, &map,
 					&bio, &last_block_in_bio, is_readahead);
 		if (ret) {
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 set_error_page:
-#endif
 			SetPageError(page);
 			zero_user_segment(page, 0, PAGE_SIZE);
 			unlock_page(page);
@@ -2246,7 +2242,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 		if (pages)
 			put_page(page);
 
-#ifdef CONFIG_F2FS_FS_COMPRESSION
 		if (f2fs_compressed_file(inode)) {
 			/* last page */
 			if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
@@ -2257,7 +2252,6 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 				f2fs_destroy_compress_ctx(&cc);
 			}
 		}
-#endif
 	}
 	BUG_ON(pages && !list_empty(pages));
 	if (bio)
fs/f2fs/f2fs.h +9 -1
index 5355be6b6755..e90d2b3f1d2d 100644
@@ -2706,7 +2706,8 @@ static inline int f2fs_has_inline_xattr(struct inode *inode)
 
 static inline int f2fs_compressed_file(struct inode *inode)
 {
-	return S_ISREG(inode->i_mode) &&
+	return IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) &&
+		S_ISREG(inode->i_mode) &&
 		is_inode_flag_set(inode, FI_COMPRESSED_FILE);
 }
 
@@ -3797,6 +3798,13 @@ static inline struct page *f2fs_compress_control_page(struct page *page)
 	WARN_ON_ONCE(1);
 	return ERR_PTR(-EINVAL);
 }
+#define f2fs_cluster_can_merge_page(cc, index)	false
+#define f2fs_read_multi_pages(cc, bio, nr_pages, last, is_ra) 0
+#define f2fs_init_compress_ctx(cc) 0
+#define f2fs_destroy_compress_ctx(cc) (void)0
+#define f2fs_cluster_is_empty(cc) true
+#define f2fs_compress_ctx_add_page(cc, page) (void)0
+#define f2fs_is_compressed_cluster(cc, index) false
 #endif
 
 static inline void set_compress_context(struct inode *inode)
#3 lore raw
Quoted 7 lines · Chao Yu
Quoted 3 lines · Matthew Wilcox

Remove the horrendous ifdeffery by slipping an IS_ENABLED into f2fs_compressed_file().

I'd like to suggest to use

Quoted 7 lines

if (IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) && f2fs_compressed_file(inode))

here to clean up f2fs_readpages' codes.

Otherwise, f2fs module w/o compression support will not recognize compressed file in most other cases if we add IS_ENABLED() condition into f2fs_compressed_file().

If we need to recognise them in order to deny access to them, then I suppose we need two predicates. Perhaps:

f2fs_unsupported_attributes(inode)
and
f2fs_compressed_file(inode)

where f2fs_unsupported_attributes can NACK any set flag (including those which don't exist yet), eg encrypted. That seems like a larger change than I should be making, since I'm not really familiar with f2fs code.

#4 lore raw
Quoted 10 lines · Matthew Wilcox
Quoted 9 lines · Chao Yu
Quoted 3 lines · Matthew Wilcox

Remove the horrendous ifdeffery by slipping an IS_ENABLED into f2fs_compressed_file().

I'd like to suggest to use

if (IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) && f2fs_compressed_file(inode))

Quoted 8 lines
Quoted 5 lines

here to clean up f2fs_readpages' codes.

Otherwise, f2fs module w/o compression support will not recognize compressed file in most other cases if we add IS_ENABLED() condition into f2fs_compressed_file().

If we need to recognise them in order to deny access to them, then I suppose we need two predicates. Perhaps:

Yup, for compression feature, now we use f2fs_is_compress_backend_ready() to check whether current kernel can support to handle compressed file.

For the purpose of cleanup, I guess below change should be enough...

Quoted 1 line
Quoted 1 line

if (IS_ENABLED(CONFIG_F2FS_FS_COMPRESSION) && f2fs_compressed_file(inode))

Thanks,

Quoted 10 lines

f2fs_unsupported_attributes(inode)
and
f2fs_compressed_file(inode)

where f2fs_unsupported_attributes can NACK any set flag (including those which don't exist yet), eg encrypted. That seems like a larger change than I should be making, since I'm not really familiar with f2fs code. .

#5 lore raw
In reply to Matthew Wilcox
Thank you for the patch! Yet something to improve:

Hi Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on f2fs/dev-test]
[cannot apply to v5.5]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Matthew-Wilcox/f2fs-Make-f2fs_readpages-readable-again/20200203-113612
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: mips-randconfig-a001-20200203 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 5.5.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=5.5.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

fs//f2fs/data.c: In function 'f2fs_mpage_readpages':
fs//f2fs/data.c:2208:9: error: implicit declaration of function 'f2fs_cluster_can_merge_page' [-Werror=implicit-function-declaration]

       if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
            ^
   fs//f2fs/data.c:2208:38: error: 'cc' undeclared (first use in this function)
       if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
                                         ^
   fs//f2fs/data.c:2208:38: note: each undeclared identifier is reported only once for each function it appears in
>> fs//f2fs/data.c:2209:11: error: implicit declaration of function 'f2fs_read_multi_pages' [-Werror=implicit-function-declaration]
        ret = f2fs_read_multi_pages(&cc, &bio,
              ^
>> fs//f2fs/data.c:2213:5: error: implicit declaration of function 'f2fs_destroy_compress_ctx' [-Werror=implicit-function-declaration]
        f2fs_destroy_compress_ctx(&cc);
        ^
>> fs//f2fs/data.c:2217:10: error: implicit declaration of function 'f2fs_is_compressed_cluster' [-Werror=implicit-function-declaration]
       ret = f2fs_is_compressed_cluster(inode, page->index);
             ^
>> fs//f2fs/data.c:2223:10: error: implicit declaration of function 'f2fs_init_compress_ctx' [-Werror=implicit-function-declaration]
       ret = f2fs_init_compress_ctx(&cc);
             ^
>> fs//f2fs/data.c:2227:4: error: implicit declaration of function 'f2fs_compress_ctx_add_page' [-Werror=implicit-function-declaration]
       f2fs_compress_ctx_add_page(&cc, page);
       ^
   fs//f2fs/data.c:2247:26: error: implicit declaration of function 'f2fs_cluster_is_empty' [-Werror=implicit-function-declaration]
       if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
                             ^

cc1: some warnings being treated as errors

vim +/f2fs_destroy_compress_ctx +2213 fs//f2fs/data.c

4c8ff7095bef64 Chao Yu            2019-11-01  2152  
2df0ab045784a1 Chao Yu            2019-03-25  2153  /*
2df0ab045784a1 Chao Yu            2019-03-25  2154   * This function was originally taken from fs/mpage.c, and customized for f2fs.
2df0ab045784a1 Chao Yu            2019-03-25  2155   * Major change was from block_size == page_size in f2fs by default.
2df0ab045784a1 Chao Yu            2019-03-25  2156   *
2df0ab045784a1 Chao Yu            2019-03-25  2157   * Note that the aops->readpages() function is ONLY used for read-ahead. If
2df0ab045784a1 Chao Yu            2019-03-25  2158   * this function ever deviates from doing just read-ahead, it should either
2df0ab045784a1 Chao Yu            2019-03-25  2159   * use ->readpage() or do the necessary surgery to decouple ->readpages()
2df0ab045784a1 Chao Yu            2019-03-25  2160   * from read-ahead.
2df0ab045784a1 Chao Yu            2019-03-25  2161   */
4c8ff7095bef64 Chao Yu            2019-11-01  2162  int f2fs_mpage_readpages(struct address_space *mapping,
2df0ab045784a1 Chao Yu            2019-03-25  2163  			struct list_head *pages, struct page *page,
2df0ab045784a1 Chao Yu            2019-03-25  2164  			unsigned nr_pages, bool is_readahead)
2df0ab045784a1 Chao Yu            2019-03-25  2165  {
2df0ab045784a1 Chao Yu            2019-03-25  2166  	struct bio *bio = NULL;
2df0ab045784a1 Chao Yu            2019-03-25  2167  	sector_t last_block_in_bio = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2168  	struct inode *inode = mapping->host;
2df0ab045784a1 Chao Yu            2019-03-25  2169  	struct f2fs_map_blocks map;
4c8ff7095bef64 Chao Yu            2019-11-01  2170  #ifdef CONFIG_F2FS_FS_COMPRESSION
4c8ff7095bef64 Chao Yu            2019-11-01  2171  	struct compress_ctx cc = {
4c8ff7095bef64 Chao Yu            2019-11-01  2172  		.inode = inode,
4c8ff7095bef64 Chao Yu            2019-11-01  2173  		.log_cluster_size = F2FS_I(inode)->i_log_cluster_size,
4c8ff7095bef64 Chao Yu            2019-11-01  2174  		.cluster_size = F2FS_I(inode)->i_cluster_size,
4c8ff7095bef64 Chao Yu            2019-11-01  2175  		.cluster_idx = NULL_CLUSTER,
4c8ff7095bef64 Chao Yu            2019-11-01  2176  		.rpages = NULL,
4c8ff7095bef64 Chao Yu            2019-11-01  2177  		.cpages = NULL,
4c8ff7095bef64 Chao Yu            2019-11-01  2178  		.nr_rpages = 0,
4c8ff7095bef64 Chao Yu            2019-11-01  2179  		.nr_cpages = 0,
4c8ff7095bef64 Chao Yu            2019-11-01  2180  	};
4c8ff7095bef64 Chao Yu            2019-11-01  2181  #endif
4c8ff7095bef64 Chao Yu            2019-11-01  2182  	unsigned max_nr_pages = nr_pages;
2df0ab045784a1 Chao Yu            2019-03-25  2183  	int ret = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2184  
2df0ab045784a1 Chao Yu            2019-03-25  2185  	map.m_pblk = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2186  	map.m_lblk = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2187  	map.m_len = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2188  	map.m_flags = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2189  	map.m_next_pgofs = NULL;
2df0ab045784a1 Chao Yu            2019-03-25  2190  	map.m_next_extent = NULL;
2df0ab045784a1 Chao Yu            2019-03-25  2191  	map.m_seg_type = NO_CHECK_TYPE;
2df0ab045784a1 Chao Yu            2019-03-25  2192  	map.m_may_create = false;
2df0ab045784a1 Chao Yu            2019-03-25  2193  
2df0ab045784a1 Chao Yu            2019-03-25  2194  	for (; nr_pages; nr_pages--) {
2df0ab045784a1 Chao Yu            2019-03-25  2195  		if (pages) {
2df0ab045784a1 Chao Yu            2019-03-25  2196  			page = list_last_entry(pages, struct page, lru);
2df0ab045784a1 Chao Yu            2019-03-25  2197  
2df0ab045784a1 Chao Yu            2019-03-25  2198  			prefetchw(&page->flags);
2df0ab045784a1 Chao Yu            2019-03-25  2199  			list_del(&page->lru);
2df0ab045784a1 Chao Yu            2019-03-25  2200  			if (add_to_page_cache_lru(page, mapping,
4969c06a0d83c9 Jaegeuk Kim        2019-07-01  2201  						  page_index(page),
2df0ab045784a1 Chao Yu            2019-03-25  2202  						  readahead_gfp_mask(mapping)))
2df0ab045784a1 Chao Yu            2019-03-25  2203  				goto next_page;
2df0ab045784a1 Chao Yu            2019-03-25  2204  		}
2df0ab045784a1 Chao Yu            2019-03-25  2205  
4c8ff7095bef64 Chao Yu            2019-11-01  2206  		if (f2fs_compressed_file(inode)) {
4c8ff7095bef64 Chao Yu            2019-11-01  2207  			/* there are remained comressed pages, submit them */
4c8ff7095bef64 Chao Yu            2019-11-01  2208  			if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
4c8ff7095bef64 Chao Yu            2019-11-01 @2209  				ret = f2fs_read_multi_pages(&cc, &bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2210  							max_nr_pages,
4c8ff7095bef64 Chao Yu            2019-11-01  2211  							&last_block_in_bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2212  							is_readahead);
4c8ff7095bef64 Chao Yu            2019-11-01 @2213  				f2fs_destroy_compress_ctx(&cc);
4c8ff7095bef64 Chao Yu            2019-11-01  2214  				if (ret)
4c8ff7095bef64 Chao Yu            2019-11-01  2215  					goto set_error_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2216  			}
4c8ff7095bef64 Chao Yu            2019-11-01 @2217  			ret = f2fs_is_compressed_cluster(inode, page->index);
4c8ff7095bef64 Chao Yu            2019-11-01  2218  			if (ret < 0)
4c8ff7095bef64 Chao Yu            2019-11-01  2219  				goto set_error_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2220  			else if (!ret)
4c8ff7095bef64 Chao Yu            2019-11-01  2221  				goto read_single_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2222  
4c8ff7095bef64 Chao Yu            2019-11-01 @2223  			ret = f2fs_init_compress_ctx(&cc);
4c8ff7095bef64 Chao Yu            2019-11-01  2224  			if (ret)
4c8ff7095bef64 Chao Yu            2019-11-01  2225  				goto set_error_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2226  
4c8ff7095bef64 Chao Yu            2019-11-01 @2227  			f2fs_compress_ctx_add_page(&cc, page);
4c8ff7095bef64 Chao Yu            2019-11-01  2228  
4c8ff7095bef64 Chao Yu            2019-11-01  2229  			goto next_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2230  		}
4c8ff7095bef64 Chao Yu            2019-11-01  2231  read_single_page:
4c8ff7095bef64 Chao Yu            2019-11-01  2232  
4c8ff7095bef64 Chao Yu            2019-11-01  2233  		ret = f2fs_read_single_page(inode, page, max_nr_pages, &map,
4c8ff7095bef64 Chao Yu            2019-11-01  2234  					&bio, &last_block_in_bio, is_readahead);
2df0ab045784a1 Chao Yu            2019-03-25  2235  		if (ret) {
4c8ff7095bef64 Chao Yu            2019-11-01  2236  set_error_page:
2df0ab045784a1 Chao Yu            2019-03-25  2237  			SetPageError(page);
2df0ab045784a1 Chao Yu            2019-03-25  2238  			zero_user_segment(page, 0, PAGE_SIZE);
2df0ab045784a1 Chao Yu            2019-03-25  2239  			unlock_page(page);
2df0ab045784a1 Chao Yu            2019-03-25  2240  		}
f1e8866016b53b Jaegeuk Kim        2015-04-09  2241  next_page:
f1e8866016b53b Jaegeuk Kim        2015-04-09  2242  		if (pages)
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2243  			put_page(page);
4c8ff7095bef64 Chao Yu            2019-11-01  2244  
4c8ff7095bef64 Chao Yu            2019-11-01  2245  		if (f2fs_compressed_file(inode)) {
4c8ff7095bef64 Chao Yu            2019-11-01  2246  			/* last page */
4c8ff7095bef64 Chao Yu            2019-11-01  2247  			if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
4c8ff7095bef64 Chao Yu            2019-11-01  2248  				ret = f2fs_read_multi_pages(&cc, &bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2249  							max_nr_pages,
4c8ff7095bef64 Chao Yu            2019-11-01  2250  							&last_block_in_bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2251  							is_readahead);
4c8ff7095bef64 Chao Yu            2019-11-01  2252  				f2fs_destroy_compress_ctx(&cc);
4c8ff7095bef64 Chao Yu            2019-11-01  2253  			}
4c8ff7095bef64 Chao Yu            2019-11-01  2254  		}
f1e8866016b53b Jaegeuk Kim        2015-04-09  2255  	}
f1e8866016b53b Jaegeuk Kim        2015-04-09  2256  	BUG_ON(pages && !list_empty(pages));
f1e8866016b53b Jaegeuk Kim        2015-04-09  2257  	if (bio)
4fc29c1aa37535 Linus Torvalds     2016-07-27  2258  		__submit_bio(F2FS_I_SB(inode), bio, DATA);
2df0ab045784a1 Chao Yu            2019-03-25  2259  	return pages ? 0 : ret;
f1e8866016b53b Jaegeuk Kim        2015-04-09  2260  }
f1e8866016b53b Jaegeuk Kim        2015-04-09  2261  

:::::: The code@line 2213 was first introduced by commit
:::::: 4c8ff7095bef64fc47e996a938f7d57f9e077da3 f2fs: support data compression

:::::: TO: Chao Yu <[email protected]>
:::::: CC: Jaegeuk Kim <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#6 lore raw
In reply to Matthew Wilcox
Thank you for the patch! Yet something to improve:

Hi Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on v5.6-rc1 next-20200211]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Matthew-Wilcox/f2fs-Make-f2fs_readpages-readable-again/20200203-113612
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-rhel-7.6 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-4) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

fs/f2fs/data.c: In function 'f2fs_mpage_readpages':

>> fs/f2fs/data.c:2208:9: error: implicit declaration of function 'f2fs_cluster_can_merge_page'; did you mean 'f2fs_register_inmem_page'? [-Werror=implicit-function-declaration]
       if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
            f2fs_register_inmem_page
>> fs/f2fs/data.c:2208:38: error: 'cc' undeclared (first use in this function)
       if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
                                         ^~
   fs/f2fs/data.c:2208:38: note: each undeclared identifier is reported only once for each function it appears in
>> fs/f2fs/data.c:2209:11: error: implicit declaration of function 'f2fs_read_multi_pages'; did you mean 'f2fs_ra_meta_pages'? [-Werror=implicit-function-declaration]
        ret = f2fs_read_multi_pages(&cc, &bio,
              ^~~~~~~~~~~~~~~~~~~~~
              f2fs_ra_meta_pages
>> fs/f2fs/data.c:2213:5: error: implicit declaration of function 'f2fs_destroy_compress_ctx'; did you mean 'f2fs_decompress_bio'? [-Werror=implicit-function-declaration]
        f2fs_destroy_compress_ctx(&cc);
        ^~~~~~~~~~~~~~~~~~~~~~~~~
        f2fs_decompress_bio
>> fs/f2fs/data.c:2217:10: error: implicit declaration of function 'f2fs_is_compressed_cluster'; did you mean 'f2fs_is_compressed_page'? [-Werror=implicit-function-declaration]
       ret = f2fs_is_compressed_cluster(inode, page->index);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
             f2fs_is_compressed_page
>> fs/f2fs/data.c:2223:10: error: implicit declaration of function 'f2fs_init_compress_ctx'; did you mean 'f2fs_decompress_bio'? [-Werror=implicit-function-declaration]
       ret = f2fs_init_compress_ctx(&cc);
             ^~~~~~~~~~~~~~~~~~~~~~
             f2fs_decompress_bio
>> fs/f2fs/data.c:2227:4: error: implicit declaration of function 'f2fs_compress_ctx_add_page'; did you mean 'f2fs_compress_control_page'? [-Werror=implicit-function-declaration]
       f2fs_compress_ctx_add_page(&cc, page);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~
       f2fs_compress_control_page
>> fs/f2fs/data.c:2247:26: error: implicit declaration of function 'f2fs_cluster_is_empty'; did you mean 'f2fs_register_inmem_page'? [-Werror=implicit-function-declaration]
       if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
                             ^~~~~~~~~~~~~~~~~~~~~
                             f2fs_register_inmem_page

cc1: some warnings being treated as errors

vim +2208 fs/f2fs/data.c

4c8ff7095bef64 Chao Yu            2019-11-01  2152  
2df0ab045784a1 Chao Yu            2019-03-25  2153  /*
2df0ab045784a1 Chao Yu            2019-03-25  2154   * This function was originally taken from fs/mpage.c, and customized for f2fs.
2df0ab045784a1 Chao Yu            2019-03-25  2155   * Major change was from block_size == page_size in f2fs by default.
2df0ab045784a1 Chao Yu            2019-03-25  2156   *
2df0ab045784a1 Chao Yu            2019-03-25  2157   * Note that the aops->readpages() function is ONLY used for read-ahead. If
2df0ab045784a1 Chao Yu            2019-03-25  2158   * this function ever deviates from doing just read-ahead, it should either
2df0ab045784a1 Chao Yu            2019-03-25  2159   * use ->readpage() or do the necessary surgery to decouple ->readpages()
2df0ab045784a1 Chao Yu            2019-03-25  2160   * from read-ahead.
2df0ab045784a1 Chao Yu            2019-03-25  2161   */
4c8ff7095bef64 Chao Yu            2019-11-01  2162  int f2fs_mpage_readpages(struct address_space *mapping,
2df0ab045784a1 Chao Yu            2019-03-25  2163  			struct list_head *pages, struct page *page,
2df0ab045784a1 Chao Yu            2019-03-25  2164  			unsigned nr_pages, bool is_readahead)
2df0ab045784a1 Chao Yu            2019-03-25  2165  {
2df0ab045784a1 Chao Yu            2019-03-25  2166  	struct bio *bio = NULL;
2df0ab045784a1 Chao Yu            2019-03-25  2167  	sector_t last_block_in_bio = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2168  	struct inode *inode = mapping->host;
2df0ab045784a1 Chao Yu            2019-03-25  2169  	struct f2fs_map_blocks map;
4c8ff7095bef64 Chao Yu            2019-11-01  2170  #ifdef CONFIG_F2FS_FS_COMPRESSION
4c8ff7095bef64 Chao Yu            2019-11-01  2171  	struct compress_ctx cc = {
4c8ff7095bef64 Chao Yu            2019-11-01  2172  		.inode = inode,
4c8ff7095bef64 Chao Yu            2019-11-01  2173  		.log_cluster_size = F2FS_I(inode)->i_log_cluster_size,
4c8ff7095bef64 Chao Yu            2019-11-01  2174  		.cluster_size = F2FS_I(inode)->i_cluster_size,
4c8ff7095bef64 Chao Yu            2019-11-01  2175  		.cluster_idx = NULL_CLUSTER,
4c8ff7095bef64 Chao Yu            2019-11-01  2176  		.rpages = NULL,
4c8ff7095bef64 Chao Yu            2019-11-01  2177  		.cpages = NULL,
4c8ff7095bef64 Chao Yu            2019-11-01  2178  		.nr_rpages = 0,
4c8ff7095bef64 Chao Yu            2019-11-01  2179  		.nr_cpages = 0,
4c8ff7095bef64 Chao Yu            2019-11-01  2180  	};
4c8ff7095bef64 Chao Yu            2019-11-01  2181  #endif
4c8ff7095bef64 Chao Yu            2019-11-01  2182  	unsigned max_nr_pages = nr_pages;
2df0ab045784a1 Chao Yu            2019-03-25  2183  	int ret = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2184  
2df0ab045784a1 Chao Yu            2019-03-25  2185  	map.m_pblk = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2186  	map.m_lblk = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2187  	map.m_len = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2188  	map.m_flags = 0;
2df0ab045784a1 Chao Yu            2019-03-25  2189  	map.m_next_pgofs = NULL;
2df0ab045784a1 Chao Yu            2019-03-25  2190  	map.m_next_extent = NULL;
2df0ab045784a1 Chao Yu            2019-03-25  2191  	map.m_seg_type = NO_CHECK_TYPE;
2df0ab045784a1 Chao Yu            2019-03-25  2192  	map.m_may_create = false;
2df0ab045784a1 Chao Yu            2019-03-25  2193  
2df0ab045784a1 Chao Yu            2019-03-25  2194  	for (; nr_pages; nr_pages--) {
2df0ab045784a1 Chao Yu            2019-03-25  2195  		if (pages) {
2df0ab045784a1 Chao Yu            2019-03-25  2196  			page = list_last_entry(pages, struct page, lru);
2df0ab045784a1 Chao Yu            2019-03-25  2197  
2df0ab045784a1 Chao Yu            2019-03-25  2198  			prefetchw(&page->flags);
2df0ab045784a1 Chao Yu            2019-03-25  2199  			list_del(&page->lru);
2df0ab045784a1 Chao Yu            2019-03-25  2200  			if (add_to_page_cache_lru(page, mapping,
4969c06a0d83c9 Jaegeuk Kim        2019-07-01  2201  						  page_index(page),
2df0ab045784a1 Chao Yu            2019-03-25  2202  						  readahead_gfp_mask(mapping)))
2df0ab045784a1 Chao Yu            2019-03-25  2203  				goto next_page;
2df0ab045784a1 Chao Yu            2019-03-25  2204  		}
2df0ab045784a1 Chao Yu            2019-03-25  2205  
4c8ff7095bef64 Chao Yu            2019-11-01  2206  		if (f2fs_compressed_file(inode)) {
4c8ff7095bef64 Chao Yu            2019-11-01  2207  			/* there are remained comressed pages, submit them */
4c8ff7095bef64 Chao Yu            2019-11-01 @2208  			if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
4c8ff7095bef64 Chao Yu            2019-11-01 @2209  				ret = f2fs_read_multi_pages(&cc, &bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2210  							max_nr_pages,
4c8ff7095bef64 Chao Yu            2019-11-01  2211  							&last_block_in_bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2212  							is_readahead);
4c8ff7095bef64 Chao Yu            2019-11-01 @2213  				f2fs_destroy_compress_ctx(&cc);
4c8ff7095bef64 Chao Yu            2019-11-01  2214  				if (ret)
4c8ff7095bef64 Chao Yu            2019-11-01  2215  					goto set_error_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2216  			}
4c8ff7095bef64 Chao Yu            2019-11-01 @2217  			ret = f2fs_is_compressed_cluster(inode, page->index);
4c8ff7095bef64 Chao Yu            2019-11-01  2218  			if (ret < 0)
4c8ff7095bef64 Chao Yu            2019-11-01  2219  				goto set_error_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2220  			else if (!ret)
4c8ff7095bef64 Chao Yu            2019-11-01  2221  				goto read_single_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2222  
4c8ff7095bef64 Chao Yu            2019-11-01 @2223  			ret = f2fs_init_compress_ctx(&cc);
4c8ff7095bef64 Chao Yu            2019-11-01  2224  			if (ret)
4c8ff7095bef64 Chao Yu            2019-11-01  2225  				goto set_error_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2226  
4c8ff7095bef64 Chao Yu            2019-11-01 @2227  			f2fs_compress_ctx_add_page(&cc, page);
4c8ff7095bef64 Chao Yu            2019-11-01  2228  
4c8ff7095bef64 Chao Yu            2019-11-01  2229  			goto next_page;
4c8ff7095bef64 Chao Yu            2019-11-01  2230  		}
4c8ff7095bef64 Chao Yu            2019-11-01  2231  read_single_page:
4c8ff7095bef64 Chao Yu            2019-11-01  2232  
4c8ff7095bef64 Chao Yu            2019-11-01  2233  		ret = f2fs_read_single_page(inode, page, max_nr_pages, &map,
4c8ff7095bef64 Chao Yu            2019-11-01  2234  					&bio, &last_block_in_bio, is_readahead);
2df0ab045784a1 Chao Yu            2019-03-25  2235  		if (ret) {
4c8ff7095bef64 Chao Yu            2019-11-01  2236  set_error_page:
2df0ab045784a1 Chao Yu            2019-03-25  2237  			SetPageError(page);
2df0ab045784a1 Chao Yu            2019-03-25  2238  			zero_user_segment(page, 0, PAGE_SIZE);
2df0ab045784a1 Chao Yu            2019-03-25  2239  			unlock_page(page);
2df0ab045784a1 Chao Yu            2019-03-25  2240  		}
f1e8866016b53b Jaegeuk Kim        2015-04-09  2241  next_page:
f1e8866016b53b Jaegeuk Kim        2015-04-09  2242  		if (pages)
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01  2243  			put_page(page);
4c8ff7095bef64 Chao Yu            2019-11-01  2244  
4c8ff7095bef64 Chao Yu            2019-11-01  2245  		if (f2fs_compressed_file(inode)) {
4c8ff7095bef64 Chao Yu            2019-11-01  2246  			/* last page */
4c8ff7095bef64 Chao Yu            2019-11-01 @2247  			if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
4c8ff7095bef64 Chao Yu            2019-11-01  2248  				ret = f2fs_read_multi_pages(&cc, &bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2249  							max_nr_pages,
4c8ff7095bef64 Chao Yu            2019-11-01  2250  							&last_block_in_bio,
4c8ff7095bef64 Chao Yu            2019-11-01  2251  							is_readahead);
4c8ff7095bef64 Chao Yu            2019-11-01  2252  				f2fs_destroy_compress_ctx(&cc);
4c8ff7095bef64 Chao Yu            2019-11-01  2253  			}
4c8ff7095bef64 Chao Yu            2019-11-01  2254  		}
f1e8866016b53b Jaegeuk Kim        2015-04-09  2255  	}
f1e8866016b53b Jaegeuk Kim        2015-04-09  2256  	BUG_ON(pages && !list_empty(pages));
f1e8866016b53b Jaegeuk Kim        2015-04-09  2257  	if (bio)
4fc29c1aa37535 Linus Torvalds     2016-07-27  2258  		__submit_bio(F2FS_I_SB(inode), bio, DATA);
2df0ab045784a1 Chao Yu            2019-03-25  2259  	return pages ? 0 : ret;
f1e8866016b53b Jaegeuk Kim        2015-04-09  2260  }
f1e8866016b53b Jaegeuk Kim        2015-04-09  2261  

:::::: The code@line 2208 was first introduced by commit
:::::: 4c8ff7095bef64fc47e996a938f7d57f9e077da3 f2fs: support data compression

:::::: TO: Chao Yu <[email protected]>
:::::: CC: Jaegeuk Kim <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org