Commit 7309871c authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: clean up F2FS_I()

Use temporary variable instead of F2FS_I() for cleanup.
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent f18d0076
...@@ -4403,22 +4403,18 @@ static inline int set_compress_context(struct inode *inode) ...@@ -4403,22 +4403,18 @@ static inline int set_compress_context(struct inode *inode)
{ {
#ifdef CONFIG_F2FS_FS_COMPRESSION #ifdef CONFIG_F2FS_FS_COMPRESSION
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode);
F2FS_I(inode)->i_compress_algorithm = fi->i_compress_algorithm = F2FS_OPTION(sbi).compress_algorithm;
F2FS_OPTION(sbi).compress_algorithm; fi->i_log_cluster_size = F2FS_OPTION(sbi).compress_log_size;
F2FS_I(inode)->i_log_cluster_size = fi->i_compress_flag = F2FS_OPTION(sbi).compress_chksum ?
F2FS_OPTION(sbi).compress_log_size; BIT(COMPRESS_CHKSUM) : 0;
F2FS_I(inode)->i_compress_flag = fi->i_cluster_size = BIT(fi->i_log_cluster_size);
F2FS_OPTION(sbi).compress_chksum ? if ((fi->i_compress_algorithm == COMPRESS_LZ4 ||
BIT(COMPRESS_CHKSUM) : 0; fi->i_compress_algorithm == COMPRESS_ZSTD) &&
F2FS_I(inode)->i_cluster_size =
BIT(F2FS_I(inode)->i_log_cluster_size);
if ((F2FS_I(inode)->i_compress_algorithm == COMPRESS_LZ4 ||
F2FS_I(inode)->i_compress_algorithm == COMPRESS_ZSTD) &&
F2FS_OPTION(sbi).compress_level) F2FS_OPTION(sbi).compress_level)
F2FS_I(inode)->i_compress_level = fi->i_compress_level = F2FS_OPTION(sbi).compress_level;
F2FS_OPTION(sbi).compress_level; fi->i_flags |= F2FS_COMPR_FL;
F2FS_I(inode)->i_flags |= F2FS_COMPR_FL;
set_inode_flag(inode, FI_COMPRESSED_FILE); set_inode_flag(inode, FI_COMPRESSED_FILE);
stat_inc_compr_inode(inode); stat_inc_compr_inode(inode);
inc_compr_inode_stat(inode); inc_compr_inode_stat(inode);
...@@ -4433,15 +4429,15 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode) ...@@ -4433,15 +4429,15 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode)
{ {
struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode);
f2fs_down_write(&F2FS_I(inode)->i_sem); f2fs_down_write(&fi->i_sem);
if (!f2fs_compressed_file(inode)) { if (!f2fs_compressed_file(inode)) {
f2fs_up_write(&F2FS_I(inode)->i_sem); f2fs_up_write(&fi->i_sem);
return true; return true;
} }
if (f2fs_is_mmap_file(inode) || if (f2fs_is_mmap_file(inode) ||
(S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))) { (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))) {
f2fs_up_write(&F2FS_I(inode)->i_sem); f2fs_up_write(&fi->i_sem);
return false; return false;
} }
...@@ -4450,7 +4446,7 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode) ...@@ -4450,7 +4446,7 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode)
clear_inode_flag(inode, FI_COMPRESSED_FILE); clear_inode_flag(inode, FI_COMPRESSED_FILE);
f2fs_mark_inode_dirty_sync(inode, true); f2fs_mark_inode_dirty_sync(inode, true);
f2fs_up_write(&F2FS_I(inode)->i_sem); f2fs_up_write(&fi->i_sem);
return true; return true;
} }
......
...@@ -981,6 +981,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ...@@ -981,6 +981,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr) struct iattr *attr)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct f2fs_inode_info *fi = F2FS_I(inode);
int err; int err;
if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
...@@ -999,7 +1000,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ...@@ -999,7 +1000,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) && if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) &&
!IS_ALIGNED(attr->ia_size, !IS_ALIGNED(attr->ia_size,
F2FS_BLK_TO_BYTES(F2FS_I(inode)->i_cluster_size))) F2FS_BLK_TO_BYTES(fi->i_cluster_size)))
return -EINVAL; return -EINVAL;
} }
...@@ -1053,7 +1054,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ...@@ -1053,7 +1054,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return err; return err;
} }
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(inode->i_mapping); filemap_invalidate_lock(inode->i_mapping);
truncate_setsize(inode, attr->ia_size); truncate_setsize(inode, attr->ia_size);
...@@ -1065,14 +1066,14 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ...@@ -1065,14 +1066,14 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
* larger than i_size. * larger than i_size.
*/ */
filemap_invalidate_unlock(inode->i_mapping); filemap_invalidate_unlock(inode->i_mapping);
f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
if (err) if (err)
return err; return err;
spin_lock(&F2FS_I(inode)->i_size_lock); spin_lock(&fi->i_size_lock);
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
F2FS_I(inode)->last_disk_size = i_size_read(inode); fi->last_disk_size = i_size_read(inode);
spin_unlock(&F2FS_I(inode)->i_size_lock); spin_unlock(&fi->i_size_lock);
} }
__setattr_copy(idmap, inode, attr); __setattr_copy(idmap, inode, attr);
...@@ -1082,7 +1083,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ...@@ -1082,7 +1083,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
if (is_inode_flag_set(inode, FI_ACL_MODE)) { if (is_inode_flag_set(inode, FI_ACL_MODE)) {
if (!err) if (!err)
inode->i_mode = F2FS_I(inode)->i_acl_mode; inode->i_mode = fi->i_acl_mode;
clear_inode_flag(inode, FI_ACL_MODE); clear_inode_flag(inode, FI_ACL_MODE);
} }
} }
...@@ -1990,15 +1991,15 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) ...@@ -1990,15 +1991,15 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
if (err) if (err)
return err; return err;
f2fs_down_write(&F2FS_I(inode)->i_sem); f2fs_down_write(&fi->i_sem);
if (!f2fs_may_compress(inode) || if (!f2fs_may_compress(inode) ||
(S_ISREG(inode->i_mode) && (S_ISREG(inode->i_mode) &&
F2FS_HAS_BLOCKS(inode))) { F2FS_HAS_BLOCKS(inode))) {
f2fs_up_write(&F2FS_I(inode)->i_sem); f2fs_up_write(&fi->i_sem);
return -EINVAL; return -EINVAL;
} }
err = set_compress_context(inode); err = set_compress_context(inode);
f2fs_up_write(&F2FS_I(inode)->i_sem); f2fs_up_write(&fi->i_sem);
if (err) if (err)
return err; return err;
...@@ -3588,6 +3589,7 @@ static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count) ...@@ -3588,6 +3589,7 @@ static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
pgoff_t page_idx = 0, last_idx; pgoff_t page_idx = 0, last_idx;
unsigned int released_blocks = 0; unsigned int released_blocks = 0;
...@@ -3625,7 +3627,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3625,7 +3627,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
if (ret) if (ret)
goto out; goto out;
if (!atomic_read(&F2FS_I(inode)->i_compr_blocks)) { if (!atomic_read(&fi->i_compr_blocks)) {
ret = -EPERM; ret = -EPERM;
goto out; goto out;
} }
...@@ -3634,7 +3636,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3634,7 +3636,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
inode_set_ctime_current(inode); inode_set_ctime_current(inode);
f2fs_mark_inode_dirty_sync(inode, true); f2fs_mark_inode_dirty_sync(inode, true);
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(inode->i_mapping); filemap_invalidate_lock(inode->i_mapping);
last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
...@@ -3660,7 +3662,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3660,7 +3662,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
end_offset = ADDRS_PER_PAGE(dn.node_page, inode); end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
count = min(end_offset - dn.ofs_in_node, last_idx - page_idx); count = min(end_offset - dn.ofs_in_node, last_idx - page_idx);
count = round_up(count, F2FS_I(inode)->i_cluster_size); count = round_up(count, fi->i_cluster_size);
ret = release_compress_blocks(&dn, count); ret = release_compress_blocks(&dn, count);
...@@ -3676,7 +3678,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3676,7 +3678,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
} }
filemap_invalidate_unlock(inode->i_mapping); filemap_invalidate_unlock(inode->i_mapping);
f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
out: out:
if (released_blocks) if (released_blocks)
f2fs_update_time(sbi, REQ_TIME); f2fs_update_time(sbi, REQ_TIME);
...@@ -3687,14 +3689,14 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3687,14 +3689,14 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
if (ret >= 0) { if (ret >= 0) {
ret = put_user(released_blocks, (u64 __user *)arg); ret = put_user(released_blocks, (u64 __user *)arg);
} else if (released_blocks && } else if (released_blocks &&
atomic_read(&F2FS_I(inode)->i_compr_blocks)) { atomic_read(&fi->i_compr_blocks)) {
set_sbi_flag(sbi, SBI_NEED_FSCK); set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_warn(sbi, "%s: partial blocks were released i_ino=%lx " f2fs_warn(sbi, "%s: partial blocks were released i_ino=%lx "
"iblocks=%llu, released=%u, compr_blocks=%u, " "iblocks=%llu, released=%u, compr_blocks=%u, "
"run fsck to fix.", "run fsck to fix.",
__func__, inode->i_ino, inode->i_blocks, __func__, inode->i_ino, inode->i_blocks,
released_blocks, released_blocks,
atomic_read(&F2FS_I(inode)->i_compr_blocks)); atomic_read(&fi->i_compr_blocks));
} }
return ret; return ret;
...@@ -3783,6 +3785,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count, ...@@ -3783,6 +3785,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count,
static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
pgoff_t page_idx = 0, last_idx; pgoff_t page_idx = 0, last_idx;
unsigned int reserved_blocks = 0; unsigned int reserved_blocks = 0;
...@@ -3808,10 +3811,10 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3808,10 +3811,10 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
goto unlock_inode; goto unlock_inode;
} }
if (atomic_read(&F2FS_I(inode)->i_compr_blocks)) if (atomic_read(&fi->i_compr_blocks))
goto unlock_inode; goto unlock_inode;
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(inode->i_mapping); filemap_invalidate_lock(inode->i_mapping);
last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
...@@ -3837,7 +3840,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3837,7 +3840,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
end_offset = ADDRS_PER_PAGE(dn.node_page, inode); end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
count = min(end_offset - dn.ofs_in_node, last_idx - page_idx); count = min(end_offset - dn.ofs_in_node, last_idx - page_idx);
count = round_up(count, F2FS_I(inode)->i_cluster_size); count = round_up(count, fi->i_cluster_size);
ret = reserve_compress_blocks(&dn, count, &reserved_blocks); ret = reserve_compress_blocks(&dn, count, &reserved_blocks);
...@@ -3852,7 +3855,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3852,7 +3855,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
} }
filemap_invalidate_unlock(inode->i_mapping); filemap_invalidate_unlock(inode->i_mapping);
f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
if (!ret) { if (!ret) {
clear_inode_flag(inode, FI_COMPRESS_RELEASED); clear_inode_flag(inode, FI_COMPRESS_RELEASED);
...@@ -3868,14 +3871,14 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) ...@@ -3868,14 +3871,14 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
if (!ret) { if (!ret) {
ret = put_user(reserved_blocks, (u64 __user *)arg); ret = put_user(reserved_blocks, (u64 __user *)arg);
} else if (reserved_blocks && } else if (reserved_blocks &&
atomic_read(&F2FS_I(inode)->i_compr_blocks)) { atomic_read(&fi->i_compr_blocks)) {
set_sbi_flag(sbi, SBI_NEED_FSCK); set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_warn(sbi, "%s: partial blocks were reserved i_ino=%lx " f2fs_warn(sbi, "%s: partial blocks were reserved i_ino=%lx "
"iblocks=%llu, reserved=%u, compr_blocks=%u, " "iblocks=%llu, reserved=%u, compr_blocks=%u, "
"run fsck to fix.", "run fsck to fix.",
__func__, inode->i_ino, inode->i_blocks, __func__, inode->i_ino, inode->i_blocks,
reserved_blocks, reserved_blocks,
atomic_read(&F2FS_I(inode)->i_compr_blocks)); atomic_read(&fi->i_compr_blocks));
} }
return ret; return ret;
...@@ -4101,6 +4104,7 @@ static int f2fs_ioc_get_compress_option(struct file *filp, unsigned long arg) ...@@ -4101,6 +4104,7 @@ static int f2fs_ioc_get_compress_option(struct file *filp, unsigned long arg)
static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_comp_option option; struct f2fs_comp_option option;
int ret = 0; int ret = 0;
...@@ -4141,25 +4145,25 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) ...@@ -4141,25 +4145,25 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
goto out; goto out;
} }
F2FS_I(inode)->i_compress_algorithm = option.algorithm; fi->i_compress_algorithm = option.algorithm;
F2FS_I(inode)->i_log_cluster_size = option.log_cluster_size; fi->i_log_cluster_size = option.log_cluster_size;
F2FS_I(inode)->i_cluster_size = BIT(option.log_cluster_size); fi->i_cluster_size = BIT(option.log_cluster_size);
/* Set default level */ /* Set default level */
if (F2FS_I(inode)->i_compress_algorithm == COMPRESS_ZSTD) if (fi->i_compress_algorithm == COMPRESS_ZSTD)
F2FS_I(inode)->i_compress_level = F2FS_ZSTD_DEFAULT_CLEVEL; fi->i_compress_level = F2FS_ZSTD_DEFAULT_CLEVEL;
else else
F2FS_I(inode)->i_compress_level = 0; fi->i_compress_level = 0;
/* Adjust mount option level */ /* Adjust mount option level */
if (option.algorithm == F2FS_OPTION(sbi).compress_algorithm && if (option.algorithm == F2FS_OPTION(sbi).compress_algorithm &&
F2FS_OPTION(sbi).compress_level) F2FS_OPTION(sbi).compress_level)
F2FS_I(inode)->i_compress_level = F2FS_OPTION(sbi).compress_level; fi->i_compress_level = F2FS_OPTION(sbi).compress_level;
f2fs_mark_inode_dirty_sync(inode, true); f2fs_mark_inode_dirty_sync(inode, true);
if (!f2fs_is_compress_backend_ready(inode)) if (!f2fs_is_compress_backend_ready(inode))
f2fs_warn(sbi, "compression algorithm is successfully set, " f2fs_warn(sbi, "compression algorithm is successfully set, "
"but current kernel doesn't support this algorithm."); "but current kernel doesn't support this algorithm.");
out: out:
f2fs_up_write(&F2FS_I(inode)->i_sem); f2fs_up_write(&fi->i_sem);
inode_unlock(inode); inode_unlock(inode);
mnt_drop_write_file(filp); mnt_drop_write_file(filp);
......
...@@ -636,8 +636,9 @@ struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino) ...@@ -636,8 +636,9 @@ struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino)
void f2fs_update_inode(struct inode *inode, struct page *node_page) void f2fs_update_inode(struct inode *inode, struct page *node_page)
{ {
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_inode *ri; struct f2fs_inode *ri;
struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ]; struct extent_tree *et = fi->extent_tree[EX_READ];
f2fs_wait_on_page_writeback(node_page, NODE, true, true); f2fs_wait_on_page_writeback(node_page, NODE, true, true);
set_page_dirty(node_page); set_page_dirty(node_page);
...@@ -647,7 +648,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) ...@@ -647,7 +648,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
ri = F2FS_INODE(node_page); ri = F2FS_INODE(node_page);
ri->i_mode = cpu_to_le16(inode->i_mode); ri->i_mode = cpu_to_le16(inode->i_mode);
ri->i_advise = F2FS_I(inode)->i_advise; ri->i_advise = fi->i_advise;
ri->i_uid = cpu_to_le32(i_uid_read(inode)); ri->i_uid = cpu_to_le32(i_uid_read(inode));
ri->i_gid = cpu_to_le32(i_gid_read(inode)); ri->i_gid = cpu_to_le32(i_gid_read(inode));
ri->i_links = cpu_to_le32(inode->i_nlink); ri->i_links = cpu_to_le32(inode->i_nlink);
...@@ -673,58 +674,49 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) ...@@ -673,58 +674,49 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
ri->i_ctime_nsec = cpu_to_le32(inode_get_ctime_nsec(inode)); ri->i_ctime_nsec = cpu_to_le32(inode_get_ctime_nsec(inode));
ri->i_mtime_nsec = cpu_to_le32(inode_get_mtime_nsec(inode)); ri->i_mtime_nsec = cpu_to_le32(inode_get_mtime_nsec(inode));
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
ri->i_current_depth = ri->i_current_depth = cpu_to_le32(fi->i_current_depth);
cpu_to_le32(F2FS_I(inode)->i_current_depth);
else if (S_ISREG(inode->i_mode)) else if (S_ISREG(inode->i_mode))
ri->i_gc_failures = cpu_to_le16(F2FS_I(inode)->i_gc_failures); ri->i_gc_failures = cpu_to_le16(fi->i_gc_failures);
ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid); ri->i_xattr_nid = cpu_to_le32(fi->i_xattr_nid);
ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags); ri->i_flags = cpu_to_le32(fi->i_flags);
ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino); ri->i_pino = cpu_to_le32(fi->i_pino);
ri->i_generation = cpu_to_le32(inode->i_generation); ri->i_generation = cpu_to_le32(inode->i_generation);
ri->i_dir_level = F2FS_I(inode)->i_dir_level; ri->i_dir_level = fi->i_dir_level;
if (f2fs_has_extra_attr(inode)) { if (f2fs_has_extra_attr(inode)) {
ri->i_extra_isize = cpu_to_le16(F2FS_I(inode)->i_extra_isize); ri->i_extra_isize = cpu_to_le16(fi->i_extra_isize);
if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode))) if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode)))
ri->i_inline_xattr_size = ri->i_inline_xattr_size =
cpu_to_le16(F2FS_I(inode)->i_inline_xattr_size); cpu_to_le16(fi->i_inline_xattr_size);
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) && if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_projid)) {
i_projid)) {
projid_t i_projid; projid_t i_projid;
i_projid = from_kprojid(&init_user_ns, i_projid = from_kprojid(&init_user_ns, fi->i_projid);
F2FS_I(inode)->i_projid);
ri->i_projid = cpu_to_le32(i_projid); ri->i_projid = cpu_to_le32(i_projid);
} }
if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) && if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
i_crtime)) { ri->i_crtime = cpu_to_le64(fi->i_crtime.tv_sec);
ri->i_crtime = ri->i_crtime_nsec = cpu_to_le32(fi->i_crtime.tv_nsec);
cpu_to_le64(F2FS_I(inode)->i_crtime.tv_sec);
ri->i_crtime_nsec =
cpu_to_le32(F2FS_I(inode)->i_crtime.tv_nsec);
} }
if (f2fs_sb_has_compression(F2FS_I_SB(inode)) && if (f2fs_sb_has_compression(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
i_compress_flag)) { i_compress_flag)) {
unsigned short compress_flag; unsigned short compress_flag;
ri->i_compr_blocks = ri->i_compr_blocks = cpu_to_le64(
cpu_to_le64(atomic_read( atomic_read(&fi->i_compr_blocks));
&F2FS_I(inode)->i_compr_blocks)); ri->i_compress_algorithm = fi->i_compress_algorithm;
ri->i_compress_algorithm = compress_flag = fi->i_compress_flag |
F2FS_I(inode)->i_compress_algorithm; fi->i_compress_level <<
compress_flag = F2FS_I(inode)->i_compress_flag |
F2FS_I(inode)->i_compress_level <<
COMPRESS_LEVEL_OFFSET; COMPRESS_LEVEL_OFFSET;
ri->i_compress_flag = cpu_to_le16(compress_flag); ri->i_compress_flag = cpu_to_le16(compress_flag);
ri->i_log_cluster_size = ri->i_log_cluster_size = fi->i_log_cluster_size;
F2FS_I(inode)->i_log_cluster_size;
} }
} }
......
...@@ -221,6 +221,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, ...@@ -221,6 +221,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
const char *name) const char *name)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(dir); struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
struct f2fs_inode_info *fi;
nid_t ino; nid_t ino;
struct inode *inode; struct inode *inode;
bool nid_free = false; bool nid_free = false;
...@@ -241,14 +242,15 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, ...@@ -241,14 +242,15 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
inode_init_owner(idmap, inode, dir, mode); inode_init_owner(idmap, inode, dir, mode);
fi = F2FS_I(inode);
inode->i_ino = ino; inode->i_ino = ino;
inode->i_blocks = 0; inode->i_blocks = 0;
simple_inode_init_ts(inode); simple_inode_init_ts(inode);
F2FS_I(inode)->i_crtime = inode_get_mtime(inode); fi->i_crtime = inode_get_mtime(inode);
inode->i_generation = get_random_u32(); inode->i_generation = get_random_u32();
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
F2FS_I(inode)->i_current_depth = 1; fi->i_current_depth = 1;
err = insert_inode_locked(inode); err = insert_inode_locked(inode);
if (err) { if (err) {
...@@ -258,9 +260,9 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, ...@@ -258,9 +260,9 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
if (f2fs_sb_has_project_quota(sbi) && if (f2fs_sb_has_project_quota(sbi) &&
(F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL)) (F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL))
F2FS_I(inode)->i_projid = F2FS_I(dir)->i_projid; fi->i_projid = F2FS_I(dir)->i_projid;
else else
F2FS_I(inode)->i_projid = make_kprojid(&init_user_ns, fi->i_projid = make_kprojid(&init_user_ns,
F2FS_DEF_PROJID); F2FS_DEF_PROJID);
err = fscrypt_prepare_new_inode(dir, inode, &encrypt); err = fscrypt_prepare_new_inode(dir, inode, &encrypt);
...@@ -278,7 +280,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, ...@@ -278,7 +280,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
if (f2fs_sb_has_extra_attr(sbi)) { if (f2fs_sb_has_extra_attr(sbi)) {
set_inode_flag(inode, FI_EXTRA_ATTR); set_inode_flag(inode, FI_EXTRA_ATTR);
F2FS_I(inode)->i_extra_isize = F2FS_TOTAL_EXTRA_ATTR_SIZE; fi->i_extra_isize = F2FS_TOTAL_EXTRA_ATTR_SIZE;
} }
if (test_opt(sbi, INLINE_XATTR)) if (test_opt(sbi, INLINE_XATTR))
...@@ -296,15 +298,15 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, ...@@ -296,15 +298,15 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
f2fs_has_inline_dentry(inode)) { f2fs_has_inline_dentry(inode)) {
xattr_size = DEFAULT_INLINE_XATTR_ADDRS; xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
} }
F2FS_I(inode)->i_inline_xattr_size = xattr_size; fi->i_inline_xattr_size = xattr_size;
F2FS_I(inode)->i_flags = fi->i_flags =
f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED); f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED);
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
F2FS_I(inode)->i_flags |= F2FS_INDEX_FL; fi->i_flags |= F2FS_INDEX_FL;
if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL) if (fi->i_flags & F2FS_PROJINHERIT_FL)
set_inode_flag(inode, FI_PROJ_INHERIT); set_inode_flag(inode, FI_PROJ_INHERIT);
/* Check compression first. */ /* Check compression first. */
......
...@@ -287,6 +287,7 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri) ...@@ -287,6 +287,7 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri)
static int recover_inode(struct inode *inode, struct page *page) static int recover_inode(struct inode *inode, struct page *page)
{ {
struct f2fs_inode *raw = F2FS_INODE(page); struct f2fs_inode *raw = F2FS_INODE(page);
struct f2fs_inode_info *fi = F2FS_I(inode);
char *name; char *name;
int err; int err;
...@@ -309,12 +310,12 @@ static int recover_inode(struct inode *inode, struct page *page) ...@@ -309,12 +310,12 @@ static int recover_inode(struct inode *inode, struct page *page)
i_projid = (projid_t)le32_to_cpu(raw->i_projid); i_projid = (projid_t)le32_to_cpu(raw->i_projid);
kprojid = make_kprojid(&init_user_ns, i_projid); kprojid = make_kprojid(&init_user_ns, i_projid);
if (!projid_eq(kprojid, F2FS_I(inode)->i_projid)) { if (!projid_eq(kprojid, fi->i_projid)) {
err = f2fs_transfer_project_quota(inode, err = f2fs_transfer_project_quota(inode,
kprojid); kprojid);
if (err) if (err)
return err; return err;
F2FS_I(inode)->i_projid = kprojid; fi->i_projid = kprojid;
} }
} }
} }
...@@ -327,10 +328,10 @@ static int recover_inode(struct inode *inode, struct page *page) ...@@ -327,10 +328,10 @@ static int recover_inode(struct inode *inode, struct page *page)
inode_set_mtime(inode, le64_to_cpu(raw->i_mtime), inode_set_mtime(inode, le64_to_cpu(raw->i_mtime),
le32_to_cpu(raw->i_mtime_nsec)); le32_to_cpu(raw->i_mtime_nsec));
F2FS_I(inode)->i_advise = raw->i_advise; fi->i_advise = raw->i_advise;
F2FS_I(inode)->i_flags = le32_to_cpu(raw->i_flags); fi->i_flags = le32_to_cpu(raw->i_flags);
f2fs_set_inode_flags(inode); f2fs_set_inode_flags(inode);
F2FS_I(inode)->i_gc_failures = le16_to_cpu(raw->i_gc_failures); fi->i_gc_failures = le16_to_cpu(raw->i_gc_failures);
recover_inline_flags(inode, raw); recover_inline_flags(inode, raw);
......
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