diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-05-22 22:36:44 -0400 |
---|---|---|
committer | Joel Becker <jlbec@evilplan.org> | 2011-05-24 02:37:19 -0400 |
commit | 55e67872b67ebd30d1326067cdba53a622ab497d (patch) | |
tree | 6269c3ab8aebc81ee32997c3e23ca53c68db3482 /fs/ocfs2 | |
parent | e80de36d8dbff216a384e9204e54d59deeadf344 (diff) |
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 8f13c5989eae..312a28f433a4 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) | |||
542 | return -EFAULT; | 542 | return -EFAULT; |
543 | 543 | ||
544 | return ocfs2_info_handle(inode, &info, 0); | 544 | return ocfs2_info_handle(inode, &info, 0); |
545 | case FITRIM: | ||
546 | { | ||
547 | struct super_block *sb = inode->i_sb; | ||
548 | struct fstrim_range range; | ||
549 | int ret = 0; | ||
550 | |||
551 | if (!capable(CAP_SYS_ADMIN)) | ||
552 | return -EPERM; | ||
553 | |||
554 | if (copy_from_user(&range, (struct fstrim_range *)arg, | ||
555 | sizeof(range))) | ||
556 | return -EFAULT; | ||
557 | |||
558 | ret = ocfs2_trim_fs(sb, &range); | ||
559 | if (ret < 0) | ||
560 | return ret; | ||
561 | |||
562 | if (copy_to_user((struct fstrim_range *)arg, &range, | ||
563 | sizeof(range))) | ||
564 | return -EFAULT; | ||
565 | |||
566 | return 0; | ||
567 | } | ||
545 | default: | 568 | default: |
546 | return -ENOTTY; | 569 | return -ENOTTY; |
547 | } | 570 | } |
@@ -569,6 +592,7 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
569 | case OCFS2_IOC_GROUP_EXTEND: | 592 | case OCFS2_IOC_GROUP_EXTEND: |
570 | case OCFS2_IOC_GROUP_ADD: | 593 | case OCFS2_IOC_GROUP_ADD: |
571 | case OCFS2_IOC_GROUP_ADD64: | 594 | case OCFS2_IOC_GROUP_ADD64: |
595 | case FITRIM: | ||
572 | break; | 596 | break; |
573 | case OCFS2_IOC_REFLINK: | 597 | case OCFS2_IOC_REFLINK: |
574 | if (copy_from_user(&args, (struct reflink_arguments *)arg, | 598 | if (copy_from_user(&args, (struct reflink_arguments *)arg, |