diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-05-23 10:36:44 +0800 |
---|---|---|
committer | Joel Becker <jlbec@evilplan.org> | 2011-05-23 23:37:19 -0700 |
commit | 55e67872b67ebd30d1326067cdba53a622ab497d (patch) | |
tree | 6269c3ab8aebc81ee32997c3e23ca53c68db3482 /fs/ocfs2 | |
parent | e80de36d8dbff216a384e9204e54d59deeadf344 (diff) | |
download | op-kernel-dev-55e67872b67ebd30d1326067cdba53a622ab497d.zip op-kernel-dev-55e67872b67ebd30d1326067cdba53a622ab497d.tar.gz |
ocfs2: Add FITRIM ioctl.
Add the corresponding ioctl function for FITRIM.
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Joel Becker <jlbec@evilplan.org>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/ioctl.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index 8f13c59..312a28f 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -542,6 +542,29 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -EFAULT; return ocfs2_info_handle(inode, &info, 0); + case FITRIM: + { + struct super_block *sb = inode->i_sb; + struct fstrim_range range; + int ret = 0; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (copy_from_user(&range, (struct fstrim_range *)arg, + sizeof(range))) + return -EFAULT; + + ret = ocfs2_trim_fs(sb, &range); + if (ret < 0) + return ret; + + if (copy_to_user((struct fstrim_range *)arg, &range, + sizeof(range))) + return -EFAULT; + + return 0; + } default: return -ENOTTY; } @@ -569,6 +592,7 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) case OCFS2_IOC_GROUP_EXTEND: case OCFS2_IOC_GROUP_ADD: case OCFS2_IOC_GROUP_ADD64: + case FITRIM: break; case OCFS2_IOC_REFLINK: if (copy_from_user(&args, (struct reflink_arguments *)arg, |