#define PRINT_MASK (D_SUPER | D_CONFIG)
#include <linux/types.h>
+#ifdef HAVE_LINUX_SELINUX_IS_ENABLED
#include <linux/selinux.h>
+#endif
#include <linux/statfs.h>
#include <linux/version.h>
-#ifdef HAVE_KERNEL_LOCKED
-#include <linux/smp_lock.h>
-#endif
#include <llog_swab.h>
#include <lustre_disk.h>
/* The connection with MGS is not established.
* Try again after 2 seconds. Interruptable. */
set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(
- msecs_to_jiffies(MSEC_PER_SEC) * 2);
+ schedule_timeout(cfs_time_seconds(2));
set_current_state(TASK_RUNNING);
if (!signal_pending(current))
goto again;
return -EOPNOTSUPP;
}
+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;
+}
+
static const struct inode_operations server_inode_operations = {
#ifdef HAVE_IOP_XATTR
.setxattr = lustre_setxattr,
.listxattr = lustre_listxattr,
};
+static const struct file_operations server_file_operations = {
+ .unlocked_ioctl = server_ioctl,
+};
+
#define log2(n) ffz(~(n))
#define LUSTRE_SUPER_MAGIC 0x0BD00BD1
sb->s_blocksize_bits = log2(sb->s_blocksize);
sb->s_magic = LUSTRE_SUPER_MAGIC;
sb->s_maxbytes = 0; /* we don't allow file IO on server mountpoints */
- sb->s_flags |= MS_RDONLY;
+ sb->s_flags |= SB_RDONLY;
sb->s_op = &server_ops;
root = new_inode(sb);
/* apparently we need to be a directory for the mount to finish */
root->i_mode = S_IFDIR;
root->i_op = &server_inode_operations;
+ root->i_fop = &server_file_operations;
sb->s_root = d_make_root(root);
if (!sb->s_root) {
CERROR("%s: can't make root dentry\n", sb->s_id);