Whamcloud - gitweb
LU-11963 osd: Add nonrotational flag to statfs
[fs/lustre-release.git] / lustre / osd-zfs / osd_lproc.c
index b3360ad..e84ed46 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)
 {
@@ -373,6 +410,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,