diff options
author | Chao Yu <chao2.yu@samsung.com> | 2015-10-05 22:22:44 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-10-09 16:20:56 -0700 |
commit | d530d4d8e237f4d12c93bb76df40b69b8b8a1dcd (patch) | |
tree | a4496eb0dd00eef9caa6b190790502d91f847ff0 /fs/f2fs/file.c | |
parent | 3342bb303bf48dd8bb5ac94c3356489ff53e4d04 (diff) | |
download | op-kernel-dev-d530d4d8e237f4d12c93bb76df40b69b8b8a1dcd.zip op-kernel-dev-d530d4d8e237f4d12c93bb76df40b69b8b8a1dcd.tar.gz |
f2fs: support synchronous gc in ioctl
This patch drops in batches gc triggered through ioctl, since user
can easily control the gc by designing the loop around the ->ioctl.
We support synchronous gc by forcing using FG_GC in f2fs_gc, so with
it, user can make sure that in this round all blocks gced were
persistent in the device until ioctl returned.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r-- | fs/f2fs/file.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a350c2a..c269966 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1618,29 +1618,25 @@ static int f2fs_ioc_gc(struct file *filp, unsigned long arg) { struct inode *inode = file_inode(filp); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - __u32 i, count; + __u32 sync; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - if (get_user(count, (__u32 __user *)arg)) + if (get_user(sync, (__u32 __user *)arg)) return -EFAULT; - if (!count || count > F2FS_BATCH_GC_MAX_NUM) - return -EINVAL; + if (f2fs_readonly(sbi->sb)) + return -EROFS; - for (i = 0; i < count; i++) { + if (!sync) { if (!mutex_trylock(&sbi->gc_mutex)) - break; - - if (f2fs_gc(sbi)) - break; + return -EBUSY; + } else { + mutex_lock(&sbi->gc_mutex); } - if (put_user(i, (__u32 __user *)arg)) - return -EFAULT; - - return 0; + return f2fs_gc(sbi, sync); } long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |