Linux-f2fs-devel Archive on lore.kernel.org
 help / color / Atom feed
* [f2fs-dev] [PATCH] f2fs: Make f2fs_readpages readable again
@ 2020-02-01 15:08 Matthew Wilcox
  2020-02-03  3:39 ` [f2fs-dev] [PATCH v2] " Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2020-02-01 15:08 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, linux-f2fs-devel, linux-fsdevel
  Cc: Matthew Wilcox \(Oracle\)

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

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

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c | 6 ------
 fs/f2fs/f2fs.h | 3 ++-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8bd9afa81c54..41156a8f60a7 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5355be6b6755..398d5a1f2867 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -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);
 }
 
-- 
2.24.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [f2fs-dev] [PATCH v2] f2fs: Make f2fs_readpages readable again
  2020-02-01 15:08 [f2fs-dev] [PATCH] f2fs: Make f2fs_readpages readable again Matthew Wilcox
@ 2020-02-03  3:39 ` " Matthew Wilcox
  2020-02-05  1:58   ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2020-02-03  3:39 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, linux-f2fs-devel, linux-fsdevel


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

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
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(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8bd9afa81c54..41156a8f60a7 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5355be6b6755..e90d2b3f1d2d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -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)
-- 
2.24.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: Make f2fs_readpages readable again
  2020-02-03  3:39 ` [f2fs-dev] [PATCH v2] " Matthew Wilcox
@ 2020-02-05  1:58   ` Chao Yu
  2020-02-05  3:08     ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2020-02-05  1:58 UTC (permalink / raw)
  To: Matthew Wilcox, Jaegeuk Kim, Chao Yu, linux-f2fs-devel, linux-fsdevel

On 2020/2/3 11:39, Matthew Wilcox wrote:
> 
> 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,

> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> 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(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 8bd9afa81c54..41156a8f60a7 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -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)
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 5355be6b6755..e90d2b3f1d2d 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -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)
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: Make f2fs_readpages readable again
  2020-02-05  1:58   ` Chao Yu
@ 2020-02-05  3:08     ` Matthew Wilcox
  2020-02-06  6:29       ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2020-02-05  3:08 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-fsdevel, Jaegeuk Kim, linux-f2fs-devel

On Wed, Feb 05, 2020 at 09:58:29AM +0800, Chao Yu wrote:
> On 2020/2/3 11:39, Matthew Wilcox wrote:
> > 
> > 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().

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.


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: Make f2fs_readpages readable again
  2020-02-05  3:08     ` Matthew Wilcox
@ 2020-02-06  6:29       ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2020-02-06  6:29 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-fsdevel, Jaegeuk Kim, linux-f2fs-devel

On 2020/2/5 11:08, Matthew Wilcox wrote:
> On Wed, Feb 05, 2020 at 09:58:29AM +0800, Chao Yu wrote:
>> On 2020/2/3 11:39, Matthew Wilcox wrote:
>>>
>>> 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().
> 
> 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...

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

Thanks,

> 
> 	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.
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-01 15:08 [f2fs-dev] [PATCH] f2fs: Make f2fs_readpages readable again Matthew Wilcox
2020-02-03  3:39 ` [f2fs-dev] [PATCH v2] " Matthew Wilcox
2020-02-05  1:58   ` Chao Yu
2020-02-05  3:08     ` Matthew Wilcox
2020-02-06  6:29       ` Chao Yu

Linux-f2fs-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-f2fs-devel/0 linux-f2fs-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-f2fs-devel linux-f2fs-devel/ https://lore.kernel.org/linux-f2fs-devel \
		linux-f2fs-devel@lists.sourceforge.net
	public-inbox-index linux-f2fs-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/net.sourceforge.lists.linux-f2fs-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git