f2fs: introduce f2fs_encrypted_file for clean-up

This patch replaces (f2fs_encrypted_inode() && S_ISREG()) with
f2fs_encrypted_file(), which gives no functional change.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

+14 -10
+5 -5
fs/f2fs/data.c
··· 581 .encrypted_page = NULL, 582 }; 583 584 - if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) 585 return read_mapping_page(mapping, index, NULL); 586 587 page = f2fs_grab_cache_page(mapping, index, for_write); ··· 786 787 static inline bool __force_buffered_io(struct inode *inode, int rw) 788 { 789 - return ((f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) || 790 (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS)) || 791 F2FS_I_SB(inode)->s_ndevs); 792 } ··· 1157 struct fscrypt_ctx *ctx = NULL; 1158 struct bio *bio; 1159 1160 - if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) { 1161 ctx = fscrypt_get_ctx(inode, GFP_NOFS); 1162 if (IS_ERR(ctx)) 1163 return ERR_CAST(ctx); ··· 1345 struct inode *inode = fio->page->mapping->host; 1346 gfp_t gfp_flags = GFP_NOFS; 1347 1348 - if (!f2fs_encrypted_inode(inode) || !S_ISREG(inode->i_mode)) 1349 return 0; 1350 1351 /* wait for GCed encrypted page writeback */ ··· 1974 f2fs_wait_on_page_writeback(page, DATA, false); 1975 1976 /* wait for GCed encrypted page writeback */ 1977 - if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) 1978 f2fs_wait_on_encrypted_page_writeback(sbi, blkaddr); 1979 1980 if (len == PAGE_SIZE || PageUptodate(page))
··· 581 .encrypted_page = NULL, 582 }; 583 584 + if (f2fs_encrypted_file(inode)) 585 return read_mapping_page(mapping, index, NULL); 586 587 page = f2fs_grab_cache_page(mapping, index, for_write); ··· 786 787 static inline bool __force_buffered_io(struct inode *inode, int rw) 788 { 789 + return (f2fs_encrypted_file(inode) || 790 (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS)) || 791 F2FS_I_SB(inode)->s_ndevs); 792 } ··· 1157 struct fscrypt_ctx *ctx = NULL; 1158 struct bio *bio; 1159 1160 + if (f2fs_encrypted_file(inode)) { 1161 ctx = fscrypt_get_ctx(inode, GFP_NOFS); 1162 if (IS_ERR(ctx)) 1163 return ERR_CAST(ctx); ··· 1345 struct inode *inode = fio->page->mapping->host; 1346 gfp_t gfp_flags = GFP_NOFS; 1347 1348 + if (!f2fs_encrypted_file(inode)) 1349 return 0; 1350 1351 /* wait for GCed encrypted page writeback */ ··· 1974 f2fs_wait_on_page_writeback(page, DATA, false); 1975 1976 /* wait for GCed encrypted page writeback */ 1977 + if (f2fs_encrypted_file(inode)) 1978 f2fs_wait_on_encrypted_page_writeback(sbi, blkaddr); 1979 1980 if (len == PAGE_SIZE || PageUptodate(page))
+5
fs/f2fs/f2fs.h
··· 2939 return file_is_encrypt(inode); 2940 } 2941 2942 static inline void f2fs_set_encrypted_inode(struct inode *inode) 2943 { 2944 #ifdef CONFIG_F2FS_FS_ENCRYPTION
··· 2939 return file_is_encrypt(inode); 2940 } 2941 2942 + static inline bool f2fs_encrypted_file(struct inode *inode) 2943 + { 2944 + return f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode); 2945 + } 2946 + 2947 static inline void f2fs_set_encrypted_inode(struct inode *inode) 2948 { 2949 #ifdef CONFIG_F2FS_FS_ENCRYPTION
+1 -1
fs/f2fs/file.c
··· 106 f2fs_wait_on_page_writeback(page, DATA, false); 107 108 /* wait for GCed encrypted page writeback */ 109 - if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) 110 f2fs_wait_on_encrypted_page_writeback(sbi, dn.data_blkaddr); 111 112 out_sem:
··· 106 f2fs_wait_on_page_writeback(page, DATA, false); 107 108 /* wait for GCed encrypted page writeback */ 109 + if (f2fs_encrypted_file(inode)) 110 f2fs_wait_on_encrypted_page_writeback(sbi, dn.data_blkaddr); 111 112 out_sem:
+2 -3
fs/f2fs/gc.c
··· 831 continue; 832 833 /* if encrypted inode, let's go phase 3 */ 834 - if (f2fs_encrypted_inode(inode) && 835 - S_ISREG(inode->i_mode)) { 836 add_gc_inode(gc_list, inode); 837 continue; 838 } ··· 872 873 start_bidx = start_bidx_of_node(nofs, inode) 874 + ofs_in_node; 875 - if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) 876 move_encrypted_block(inode, start_bidx, segno, off); 877 else 878 move_data_page(inode, start_bidx, gc_type, segno, off);
··· 831 continue; 832 833 /* if encrypted inode, let's go phase 3 */ 834 + if (f2fs_encrypted_file(inode)) { 835 add_gc_inode(gc_list, inode); 836 continue; 837 } ··· 873 874 start_bidx = start_bidx_of_node(nofs, inode) 875 + ofs_in_node; 876 + if (f2fs_encrypted_file(inode)) 877 move_encrypted_block(inode, start_bidx, segno, off); 878 else 879 move_data_page(inode, start_bidx, gc_type, segno, off);
+1 -1
fs/f2fs/inline.c
··· 25 if (i_size_read(inode) > MAX_INLINE_DATA(inode)) 26 return false; 27 28 - if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) 29 return false; 30 31 return true;
··· 25 if (i_size_read(inode) > MAX_INLINE_DATA(inode)) 26 return false; 27 28 + if (f2fs_encrypted_file(inode)) 29 return false; 30 31 return true;