Skip to content

Commit

Permalink
f2fs: Clean-up Xiaomi changes
Browse files Browse the repository at this point in the history
Background gc boost isn't proving itself to be effective. Also, setting xattr
on dirs is not noticeable that frequently. Moreover, fsync() should persist all
data changes to a given file/dir, otherwise breaks fsync's logics. So, abort
Xiaomi's changes here all together.

This reverts the following commits:
"f2fs: Speed up gc when free segment is insufficient"
"f2fs: enable fstrim to issue discard while using discard option"
"f2fs: add trim stop mechanism"
"f2fs: avoid needless checkpoint during fsync"

Link: Atom-X-Devs/scarlet_xiaomi_sdm660@5e868da
Change-Id: e0f07efb601d1cf4d04d4ff6d88bf4d13311e990
Suggested-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Signed-off-by: TogoFire <togofire@mailfence.com>
  • Loading branch information
Tashar02 authored and TogoFire committed Apr 22, 2023
1 parent 10ca69c commit 44db470
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 108 deletions.
6 changes: 0 additions & 6 deletions fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,12 +1581,6 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)

trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops");

/*
* checkpoint will maintain the xattr consistency of dirs,
* so we can remove them from tracking list when do_checkpoint
*/
f2fs_clear_xattr_set_ilist(sbi);

err = block_operations(sbi);
if (err)
goto out;
Expand Down
12 changes: 0 additions & 12 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ struct f2fs_inode_info {
struct task_struct *inmem_task; /* store inmemory task */
struct mutex inmem_lock; /* lock for inmemory pages */
struct extent_tree *extent_tree; /* cached extent_tree entry */
struct list_head xattr_dirty_list; /* list for xattr changed inodes */

/* avoid racing between foreground op and gc */
struct rw_semaphore i_gc_rwsem[2];
Expand Down Expand Up @@ -1061,7 +1060,6 @@ enum cp_reason_type {
CP_FASTBOOT_MODE,
CP_SPEC_LOG_NUM,
CP_RECOVER_DIR,
CP_PARENT_XATTR_SET,
};

enum iostat_type {
Expand Down Expand Up @@ -1258,8 +1256,6 @@ struct f2fs_sb_info {
struct list_head fsync_node_list; /* node list head */
unsigned int fsync_seg_id; /* sequence id */
unsigned int fsync_node_num; /* number of node entries */
spinlock_t xattr_set_dir_ilist_lock; /* lock for dir inode list*/
struct list_head xattr_set_dir_ilist; /* xattr changed dir inode list */

/* for orphan inode, use 0'th array */
unsigned int max_orphans; /* max orphan inodes */
Expand Down Expand Up @@ -3507,14 +3503,6 @@ int f2fs_inline_data_fiemap(struct inode *inode,
struct fiemap_extent_info *fieinfo,
__u64 start, __u64 len);

/*
* xattr.c
*/
void f2fs_inode_xattr_set(struct inode *inode);
void f2fs_remove_xattr_set_inode(struct inode *inode);
void f2fs_clear_xattr_set_ilist(struct f2fs_sb_info *sbi);
int f2fs_parent_inode_xattr_set(struct inode *inode);

/*
* shrinker.c
*/
Expand Down
2 changes: 0 additions & 2 deletions fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ static inline enum cp_reason_type need_do_checkpoint(struct inode *inode)
cp_reason = CP_HARDLINK;
else if (is_sbi_flag_set(sbi, SBI_NEED_CP))
cp_reason = CP_SB_NEED_CP;
else if (f2fs_parent_inode_xattr_set(inode))
cp_reason = CP_PARENT_XATTR_SET;
else if (file_wrong_pino(inode))
cp_reason = CP_WRONG_PINO;
else if (!f2fs_space_for_roll_forward(sbi))
Expand Down
2 changes: 0 additions & 2 deletions fs/f2fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,6 @@ void f2fs_evict_inode(struct inode *inode)

f2fs_destroy_extent_tree(inode);

f2fs_remove_xattr_set_inode(inode);

if (inode->i_nlink || is_bad_inode(inode))
goto no_delete;

Expand Down
18 changes: 9 additions & 9 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -2817,15 +2817,6 @@ static unsigned int __issue_discard_cmd_range(struct f2fs_sb_info *sbi,

if (fatal_signal_pending(current))
break;

/*
* If the trim thread is running and we receive the SCREEN_ON
* event, we will send SIGUSR1 singnal to teriminate the trim
* thread. So if there is a SIGUSR1 signal pending in current
* thread, we need stop issuing discard commands and return.
*/
if (signal_pending(current) && sigismember(&current->pending.signal, SIGUSR1))
break;
}

blk_finish_plug(&plug);
Expand Down Expand Up @@ -2880,6 +2871,15 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
if (err)
goto out;

/*
* We filed discard candidates, but actually we don't need to wait for
* all of them, since they'll be issued in idle time along with runtime
* discard option. User configuration looks like using runtime discard
* or periodic fstrim instead of it.
*/
if (f2fs_realtime_discard_enable(sbi))
goto out;

start_block = START_BLOCK(sbi, start_segno);
end_block = START_BLOCK(sbi, end_segno + 1);

Expand Down
4 changes: 0 additions & 4 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,6 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
init_rwsem(&fi->i_gc_rwsem[WRITE]);
init_rwsem(&fi->i_mmap_sem);
init_rwsem(&fi->i_xattr_sem);
INIT_LIST_HEAD(&fi->xattr_dirty_list);

/* Will be used by directory only */
fi->i_dir_level = F2FS_SB(sb)->dir_level;
Expand Down Expand Up @@ -3340,9 +3339,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
}
mutex_init(&sbi->flush_lock);

INIT_LIST_HEAD(&sbi->xattr_set_dir_ilist);
spin_lock_init(&sbi->xattr_set_dir_ilist_lock);

f2fs_init_extent_cache_info(sbi);

f2fs_init_ino_entry_info(sbi);
Expand Down
72 changes: 1 addition & 71 deletions fs/f2fs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,6 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
return 0;
}

static struct inode *get_parent_inode(struct inode *inode)
{
struct inode *dir = NULL;
struct dentry *dentry, *parent;

dentry = d_find_alias(inode);
if (!dentry)
goto out;

parent = dget_parent(dentry);
if (!parent)
goto out_dput;

dir = igrab(d_inode(parent));
dput(parent);

out_dput:
dput(dentry);
out:
return dir;
}

#ifdef CONFIG_F2FS_FS_SECURITY
static int f2fs_initxattrs(struct inode *inode, const struct xattr *xattr_array,
void *page)
Expand Down Expand Up @@ -751,7 +729,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
f2fs_set_encrypted_inode(inode);
f2fs_mark_inode_dirty_sync(inode, true);
if (!error && S_ISDIR(inode->i_mode))
f2fs_inode_xattr_set(inode);
set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP);
exit:
kvfree(base_addr);
return error;
Expand Down Expand Up @@ -791,51 +769,3 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
f2fs_update_time(sbi, REQ_TIME);
return err;
}

void f2fs_inode_xattr_set(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode);

spin_lock(&sbi->xattr_set_dir_ilist_lock);
if (list_empty(&fi->xattr_dirty_list))
list_add_tail(&fi->xattr_dirty_list, &sbi->xattr_set_dir_ilist);
spin_unlock(&sbi->xattr_set_dir_ilist_lock);
}

void f2fs_remove_xattr_set_inode(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode);

spin_lock(&sbi->xattr_set_dir_ilist_lock);
if (!list_empty(&fi->xattr_dirty_list))
list_del_init(&fi->xattr_dirty_list);
spin_unlock(&sbi->xattr_set_dir_ilist_lock);
}

void f2fs_clear_xattr_set_ilist(struct f2fs_sb_info *sbi)
{
struct list_head *pos, *n;

spin_lock(&sbi->xattr_set_dir_ilist_lock);
list_for_each_safe(pos, n, &sbi->xattr_set_dir_ilist)
list_del_init(pos);
spin_unlock(&sbi->xattr_set_dir_ilist_lock);
}

int f2fs_parent_inode_xattr_set(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct inode *dir = get_parent_inode(inode);
int ret = 0;

if (dir) {
spin_lock(&sbi->xattr_set_dir_ilist_lock);
ret = !list_empty(&F2FS_I(dir)->xattr_dirty_list);
spin_unlock(&sbi->xattr_set_dir_ilist_lock);
iput(dir);
}

return ret;
}
3 changes: 1 addition & 2 deletions include/trace/events/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ TRACE_DEFINE_ENUM(CP_PAUSE);
{ CP_NODE_NEED_CP, "node needs cp" }, \
{ CP_FASTBOOT_MODE, "fastboot mode" }, \
{ CP_SPEC_LOG_NUM, "log type is 2" }, \
{ CP_RECOVER_DIR, "dir needs recovery" }, \
{ CP_PARENT_XATTR_SET, "parent xattr is set" })
{ CP_RECOVER_DIR, "dir needs recovery" })

#define show_shutdown_mode(type) \
__print_symbolic(type, \
Expand Down

0 comments on commit 44db470

Please sign in to comment.