+static bool is_cmd_supported(unsigned int command)
+{
+ switch (command) {
+ case FITRIM:
+ return true;
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+static long server_ioctl(struct file *filp, unsigned int command,
+ unsigned long arg)
+{
+ struct file active_filp;
+ struct inode *inode = file_inode(filp);
+ struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
+ struct super_block *dd_sb = dt_mnt_sb_get(lsi->lsi_dt_dev);
+ struct inode *active_inode;
+ int err = -EOPNOTSUPP;
+
+ if (IS_ERR(dd_sb) || !is_cmd_supported(command))
+ return err;
+
+ active_inode = igrab(dd_sb->s_root->d_inode);
+ if (!active_inode)
+ return -EACCES;
+
+ active_filp.f_inode = active_inode;
+ if (active_inode->i_fop && active_inode->i_fop->unlocked_ioctl)
+ err = active_inode->i_fop->unlocked_ioctl(&active_filp,
+ command, arg);
+ iput(active_inode);
+ return err;
+}
+