Commit 1958593e authored by Jaegeuk Kim's avatar Jaegeuk Kim

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: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 2afce76a
...@@ -581,7 +581,7 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index, ...@@ -581,7 +581,7 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index,
.encrypted_page = NULL, .encrypted_page = NULL,
}; };
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) if (f2fs_encrypted_file(inode))
return read_mapping_page(mapping, index, NULL); return read_mapping_page(mapping, index, NULL);
page = f2fs_grab_cache_page(mapping, index, for_write); page = f2fs_grab_cache_page(mapping, index, for_write);
...@@ -786,7 +786,7 @@ static int __allocate_data_block(struct dnode_of_data *dn) ...@@ -786,7 +786,7 @@ static int __allocate_data_block(struct dnode_of_data *dn)
static inline bool __force_buffered_io(struct inode *inode, int rw) static inline bool __force_buffered_io(struct inode *inode, int rw)
{ {
return ((f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) || return (f2fs_encrypted_file(inode) ||
(rw == WRITE && test_opt(F2FS_I_SB(inode), LFS)) || (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS)) ||
F2FS_I_SB(inode)->s_ndevs); F2FS_I_SB(inode)->s_ndevs);
} }
...@@ -1157,7 +1157,7 @@ static struct bio *f2fs_grab_bio(struct inode *inode, block_t blkaddr, ...@@ -1157,7 +1157,7 @@ static struct bio *f2fs_grab_bio(struct inode *inode, block_t blkaddr,
struct fscrypt_ctx *ctx = NULL; struct fscrypt_ctx *ctx = NULL;
struct bio *bio; struct bio *bio;
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) { if (f2fs_encrypted_file(inode)) {
ctx = fscrypt_get_ctx(inode, GFP_NOFS); ctx = fscrypt_get_ctx(inode, GFP_NOFS);
if (IS_ERR(ctx)) if (IS_ERR(ctx))
return ERR_CAST(ctx); return ERR_CAST(ctx);
...@@ -1345,7 +1345,7 @@ static int encrypt_one_page(struct f2fs_io_info *fio) ...@@ -1345,7 +1345,7 @@ static int encrypt_one_page(struct f2fs_io_info *fio)
struct inode *inode = fio->page->mapping->host; struct inode *inode = fio->page->mapping->host;
gfp_t gfp_flags = GFP_NOFS; gfp_t gfp_flags = GFP_NOFS;
if (!f2fs_encrypted_inode(inode) || !S_ISREG(inode->i_mode)) if (!f2fs_encrypted_file(inode))
return 0; return 0;
/* wait for GCed encrypted page writeback */ /* wait for GCed encrypted page writeback */
...@@ -1974,7 +1974,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1974,7 +1974,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
f2fs_wait_on_page_writeback(page, DATA, false); f2fs_wait_on_page_writeback(page, DATA, false);
/* wait for GCed encrypted page writeback */ /* wait for GCed encrypted page writeback */
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) if (f2fs_encrypted_file(inode))
f2fs_wait_on_encrypted_page_writeback(sbi, blkaddr); f2fs_wait_on_encrypted_page_writeback(sbi, blkaddr);
if (len == PAGE_SIZE || PageUptodate(page)) if (len == PAGE_SIZE || PageUptodate(page))
......
...@@ -2939,6 +2939,11 @@ static inline bool f2fs_encrypted_inode(struct inode *inode) ...@@ -2939,6 +2939,11 @@ static inline bool f2fs_encrypted_inode(struct inode *inode)
return file_is_encrypt(inode); return file_is_encrypt(inode);
} }
static inline bool f2fs_encrypted_file(struct inode *inode)
{
return f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode);
}
static inline void f2fs_set_encrypted_inode(struct inode *inode) static inline void f2fs_set_encrypted_inode(struct inode *inode)
{ {
#ifdef CONFIG_F2FS_FS_ENCRYPTION #ifdef CONFIG_F2FS_FS_ENCRYPTION
......
...@@ -106,7 +106,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf) ...@@ -106,7 +106,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
f2fs_wait_on_page_writeback(page, DATA, false); f2fs_wait_on_page_writeback(page, DATA, false);
/* wait for GCed encrypted page writeback */ /* wait for GCed encrypted page writeback */
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) if (f2fs_encrypted_file(inode))
f2fs_wait_on_encrypted_page_writeback(sbi, dn.data_blkaddr); f2fs_wait_on_encrypted_page_writeback(sbi, dn.data_blkaddr);
out_sem: out_sem:
......
...@@ -831,8 +831,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, ...@@ -831,8 +831,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
continue; continue;
/* if encrypted inode, let's go phase 3 */ /* if encrypted inode, let's go phase 3 */
if (f2fs_encrypted_inode(inode) && if (f2fs_encrypted_file(inode)) {
S_ISREG(inode->i_mode)) {
add_gc_inode(gc_list, inode); add_gc_inode(gc_list, inode);
continue; continue;
} }
...@@ -873,7 +872,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, ...@@ -873,7 +872,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
start_bidx = start_bidx_of_node(nofs, inode) start_bidx = start_bidx_of_node(nofs, inode)
+ ofs_in_node; + ofs_in_node;
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) if (f2fs_encrypted_file(inode))
move_encrypted_block(inode, start_bidx, segno, off); move_encrypted_block(inode, start_bidx, segno, off);
else else
move_data_page(inode, start_bidx, gc_type, segno, off); move_data_page(inode, start_bidx, gc_type, segno, off);
......
...@@ -25,7 +25,7 @@ bool f2fs_may_inline_data(struct inode *inode) ...@@ -25,7 +25,7 @@ bool f2fs_may_inline_data(struct inode *inode)
if (i_size_read(inode) > MAX_INLINE_DATA(inode)) if (i_size_read(inode) > MAX_INLINE_DATA(inode))
return false; return false;
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) if (f2fs_encrypted_file(inode))
return false; return false;
return true; return true;
......
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