Whamcloud - gitweb
LU-15406 sec: fix in-kernel fscrypt support
[fs/lustre-release.git] / lustre / lmv / lproc_lmv.c
index 6e0e7cc..b095aa2 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #define DEBUG_SUBSYSTEM S_CLASS
@@ -121,10 +120,21 @@ static ssize_t qos_prio_free_store(struct kobject *kobj,
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        struct lmv_obd *lmv = &obd->u.lmv;
+       char buf[6], *tmp;
        unsigned int val;
        int rc;
 
-       rc = kstrtouint(buffer, 0, &val);
+       /* "100%\n\0" should be largest string */
+       if (count >= sizeof(buf))
+               return -ERANGE;
+
+       strncpy(buf, buffer, sizeof(buf));
+       buf[sizeof(buf) - 1] = '\0';
+       tmp = strchr(buf, '%');
+       if (tmp)
+               *tmp = '\0';
+
+       rc = kstrtouint(buf, 0, &val);
        if (rc)
                return rc;
 
@@ -132,8 +142,8 @@ static ssize_t qos_prio_free_store(struct kobject *kobj,
                return -EINVAL;
 
        lmv->lmv_qos.lq_prio_free = (val << 8) / 100;
-       lmv->lmv_qos.lq_dirty = 1;
-       lmv->lmv_qos.lq_reset = 1;
+       set_bit(LQ_DIRTY, &lmv->lmv_qos.lq_flags);
+       set_bit(LQ_RESET, &lmv->lmv_qos.lq_flags);
 
        return count;
 }
@@ -158,10 +168,21 @@ static ssize_t qos_threshold_rr_store(struct kobject *kobj,
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        struct lmv_obd *lmv = &obd->u.lmv;
+       char buf[6], *tmp;
        unsigned int val;
        int rc;
 
-       rc = kstrtouint(buffer, 0, &val);
+       /* "100%\n\0" should be largest string */
+       if (count >= sizeof(buf))
+               return -ERANGE;
+
+       strncpy(buf, buffer, sizeof(buf));
+       buf[sizeof(buf) - 1] = '\0';
+       tmp = strchr(buf, '%');
+       if (tmp)
+               *tmp = '\0';
+
+       rc = kstrtouint(buf, 0, &val);
        if (rc)
                return rc;
 
@@ -169,7 +190,7 @@ static ssize_t qos_threshold_rr_store(struct kobject *kobj,
                return -EINVAL;
 
        lmv->lmv_qos.lq_threshold_rr = (val << 8) / 100;
-       lmv->lmv_qos.lq_dirty = 1;
+       set_bit(LQ_DIRTY, &lmv->lmv_qos.lq_flags);
 
        return count;
 }
@@ -249,12 +270,12 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-static const struct file_operations lmv_proc_target_fops = {
-        .owner                = THIS_MODULE,
-        .open                 = lmv_target_seq_open,
-        .read                 = seq_read,
-        .llseek               = seq_lseek,
-        .release              = seq_release,
+static const struct proc_ops lmv_proc_target_fops = {
+       PROC_OWNER(THIS_MODULE)
+       .proc_open      = lmv_target_seq_open,
+       .proc_read      = seq_read,
+       .proc_lseek     = seq_lseek,
+       .proc_release   = seq_release,
 };
 #endif /* CONFIG_PROC_FS */