aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jfs/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jfs/ioctl.c')
-rw-r--r--fs/jfs/ioctl.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index f19d1e04a374..bc555ff417e9 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -11,13 +11,17 @@
11#include <linux/mount.h> 11#include <linux/mount.h>
12#include <linux/time.h> 12#include <linux/time.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/blkdev.h>
14#include <asm/current.h> 15#include <asm/current.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16 17
18#include "jfs_filsys.h"
19#include "jfs_debug.h"
17#include "jfs_incore.h" 20#include "jfs_incore.h"
18#include "jfs_dinode.h" 21#include "jfs_dinode.h"
19#include "jfs_inode.h" 22#include "jfs_inode.h"
20 23#include "jfs_dmap.h"
24#include "jfs_discard.h"
21 25
22static struct { 26static struct {
23 long jfs_flag; 27 long jfs_flag;
@@ -123,6 +127,40 @@ setflags_out:
123 mnt_drop_write_file(filp); 127 mnt_drop_write_file(filp);
124 return err; 128 return err;
125 } 129 }
130
131 case FITRIM:
132 {
133 struct super_block *sb = inode->i_sb;
134 struct request_queue *q = bdev_get_queue(sb->s_bdev);
135 struct fstrim_range range;
136 s64 ret = 0;
137
138 if (!capable(CAP_SYS_ADMIN))
139 return -EPERM;
140
141 if (!blk_queue_discard(q)) {
142 jfs_warn("FITRIM not supported on device");
143 return -EOPNOTSUPP;
144 }
145
146 if (copy_from_user(&range, (struct fstrim_range __user *)arg,
147 sizeof(range)))
148 return -EFAULT;
149
150 range.minlen = max_t(unsigned int, range.minlen,
151 q->limits.discard_granularity);
152
153 ret = jfs_ioc_trim(inode, &range);
154 if (ret < 0)
155 return ret;
156
157 if (copy_to_user((struct fstrim_range __user *)arg, &range,
158 sizeof(range)))
159 return -EFAULT;
160
161 return 0;
162 }
163
126 default: 164 default:
127 return -ENOTTY; 165 return -ENOTTY;
128 } 166 }
@@ -142,6 +180,9 @@ long jfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
142 case JFS_IOC_SETFLAGS32: 180 case JFS_IOC_SETFLAGS32:
143 cmd = JFS_IOC_SETFLAGS; 181 cmd = JFS_IOC_SETFLAGS;
144 break; 182 break;
183 case FITRIM:
184 cmd = FITRIM;
185 break;
145 } 186 }
146 return jfs_ioctl(filp, cmd, arg); 187 return jfs_ioctl(filp, cmd, arg);
147} 188}