Whamcloud - gitweb
LU-13246 osd: unlock os_lock if it was locked
[fs/lustre-release.git] / lustre / osd-zfs / osd_lproc.c
index b3360ad..7e742fd 100644 (file)
@@ -295,6 +295,43 @@ ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_WO_ATTR(force_sync);
 
+static ssize_t nonrotational_show(struct kobject *kobj, struct attribute *attr,
+                                 char *buf)
+{
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *osd = osd_dt_dev(dt);
+
+       LASSERT(osd);
+       if (!osd->od_os)
+               return -EINPROGRESS;
+
+       return sprintf(buf, "%u\n", osd->od_nonrotational);
+}
+
+static ssize_t nonrotational_store(struct kobject *kobj,
+                                  struct attribute *attr, const char *buffer,
+                                  size_t count)
+{
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *osd = osd_dt_dev(dt);
+       bool val;
+       int rc;
+
+       LASSERT(osd);
+       if (!osd->od_os)
+               return -EINPROGRESS;
+
+       rc = kstrtobool(buffer, &val);
+       if (rc)
+               return rc;
+
+       osd->od_nonrotational = val;
+       return count;
+}
+LUSTRE_RW_ATTR(nonrotational);
+
 static ssize_t index_backup_show(struct kobject *kobj, struct attribute *attr,
                                 char *buf)
 {
@@ -350,18 +387,24 @@ zfs_osd_readcache_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *osd = osd_dt_dev(dt);
-       s64 val;
+       char kernbuf[22] = "";
+       u64 val;
        int rc;
 
        LASSERT(osd != NULL);
        if (unlikely(osd->od_os == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
-       if (rc)
+       if (count >= sizeof(kernbuf))
+               return -EINVAL;
+
+       if (copy_from_user(kernbuf, buffer, count))
+               return -EFAULT;
+       kernbuf[count] = 0;
+
+       rc = sysfs_memparse(kernbuf, count, &val, "B");
+       if (rc < 0)
                return rc;
-       if (val < 0)
-               return -ERANGE;
 
        osd->od_readcache_max_filesize = val > OSD_MAX_CACHE_SIZE ?
                                         OSD_MAX_CACHE_SIZE : val;
@@ -373,6 +416,7 @@ static struct attribute *zfs_attrs[] = {
        &lustre_attr_fstype.attr,
        &lustre_attr_mntdev.attr,
        &lustre_attr_force_sync.attr,
+       &lustre_attr_nonrotational.attr,
        &lustre_attr_index_backup.attr,
        &lustre_attr_auto_scrub.attr,
        NULL,
@@ -401,6 +445,9 @@ int osd_procfs_init(struct osd_device *osd, const char *name)
        LASSERT(type);
        LASSERT(name);
 
+       /* put reference taken by class_search_type */
+       kobject_put(&type->typ_kobj);
+
        osd->od_dt_dev.dd_ktype.default_attrs = zfs_attrs;
        rc = dt_tunables_init(&osd->od_dt_dev, type, name,
                              lprocfs_osd_obd_vars);