if (rc)
return rc;
- osd->od_read_cache = val;
+ osd->od_read_cache = !!val;
return count;
}
LUSTRE_RW_ATTR(read_cache_enable);
if (rc)
return rc;
- osd->od_writethrough_cache = val;
+ osd->od_writethrough_cache = !!val;
return count;
}
LUSTRE_RW_ATTR(writethrough_cache_enable);
+static ssize_t fallocate_zero_blocks_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 (unlikely(!osd->od_mnt))
+ return -EINPROGRESS;
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n", osd->od_fallocate_zero_blocks);
+}
+
+/*
+ * Set how fallocate() interacts with the backing filesystem:
+ * -1: fallocate is disabled and returns -EOPNOTSUPP
+ * 0: fallocate allocates unwritten extents (like ext4)
+ * 1: fallocate zeroes allocated extents on disk
+ */
+static ssize_t fallocate_zero_blocks_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);
+ long val;
+ int rc;
+
+ LASSERT(osd);
+ if (unlikely(!osd->od_mnt))
+ return -EINPROGRESS;
+
+ rc = kstrtol(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val < -1 || val > 1)
+ return -EINVAL;
+
+ osd->od_fallocate_zero_blocks = val;
+ return count;
+}
+LUSTRE_RW_ATTR(fallocate_zero_blocks);
+
ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
const char *buffer, size_t count)
{
struct seq_file *m = file->private_data;
struct dt_device *dt = m->private;
struct osd_device *osd = osd_dt_dev(dt);
+ char kernbuf[22] = "";
u64 val;
int rc;
if (unlikely(osd->od_mnt == NULL))
return -EINPROGRESS;
- rc = lprocfs_str_with_units_to_u64(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;
osd->od_readcache_max_filesize = val > OSD_MAX_CACHE_SIZE ?
LDEBUGFS_SEQ_FOPS(ldiskfs_osd_readcache);
+static int ldiskfs_osd_readcache_max_io_seq_show(struct seq_file *m, void *data)
+{
+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
+
+ LASSERT(osd != NULL);
+ if (unlikely(osd->od_mnt == NULL))
+ return -EINPROGRESS;
+
+ seq_printf(m, "%lu\n", osd->od_readcache_max_iosize >> 20);
+ return 0;
+}
+
+static ssize_t
+ldiskfs_osd_readcache_max_io_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
+{
+ struct seq_file *m = file->private_data;
+ struct dt_device *dt = m->private;
+ struct osd_device *osd = osd_dt_dev(dt);
+ char kernbuf[22] = "";
+ u64 val;
+ int rc;
+
+ LASSERT(osd != NULL);
+ if (unlikely(osd->od_mnt == NULL))
+ return -EINPROGRESS;
+
+ if (count >= sizeof(kernbuf))
+ return -EINVAL;
+
+ if (copy_from_user(kernbuf, buffer, count))
+ return -EFAULT;
+ kernbuf[count] = 0;
+
+ rc = sysfs_memparse(kernbuf, count, &val, "MiB");
+ if (rc < 0)
+ return rc;
+
+ if (val > PTLRPC_MAX_BRW_SIZE)
+ return -ERANGE;
+ osd->od_readcache_max_iosize = val;
+ return count;
+}
+
+LDEBUGFS_SEQ_FOPS(ldiskfs_osd_readcache_max_io);
+
+static int ldiskfs_osd_writethrough_max_io_seq_show(struct seq_file *m,
+ void *data)
+{
+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
+
+ LASSERT(osd != NULL);
+ if (unlikely(osd->od_mnt == NULL))
+ return -EINPROGRESS;
+
+ seq_printf(m, "%lu\n", osd->od_writethrough_max_iosize >> 20);
+ return 0;
+}
+
+static ssize_t
+ldiskfs_osd_writethrough_max_io_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
+{
+ struct seq_file *m = file->private_data;
+ struct dt_device *dt = m->private;
+ struct osd_device *osd = osd_dt_dev(dt);
+ char kernbuf[22] = "";
+ u64 val;
+ int rc;
+
+ LASSERT(osd != NULL);
+ if (unlikely(osd->od_mnt == NULL))
+ return -EINPROGRESS;
+
+ if (count >= sizeof(kernbuf))
+ return -EINVAL;
+
+ if (copy_from_user(kernbuf, buffer, count))
+ return -EFAULT;
+ kernbuf[count] = 0;
+
+ rc = sysfs_memparse(kernbuf, count, &val, "MiB");
+ if (rc < 0)
+ return rc;
+
+ if (val > PTLRPC_MAX_BRW_SIZE)
+ return -ERANGE;
+ osd->od_writethrough_max_iosize = val;
+ return count;
+}
+
+LDEBUGFS_SEQ_FOPS(ldiskfs_osd_writethrough_max_io);
+
#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 52, 0)
static ssize_t index_in_idif_show(struct kobject *kobj, struct attribute *attr,
char *buf)
}
LUSTRE_RW_ATTR(index_backup);
-struct lprocfs_vars lprocfs_osd_obd_vars[] = {
+struct ldebugfs_vars ldebugfs_osd_obd_vars[] = {
{ .name = "oi_scrub",
.fops = &ldiskfs_osd_oi_scrub_fops },
{ .name = "readcache_max_filesize",
.fops = &ldiskfs_osd_readcache_fops },
+ { .name = "readcache_max_io_mb",
+ .fops = &ldiskfs_osd_readcache_max_io_fops },
+ { .name = "writethrough_max_io_mb",
+ .fops = &ldiskfs_osd_writethrough_max_io_fops },
{ NULL }
};
&lustre_attr_writethrough_cache_enable.attr,
&lustre_attr_fstype.attr,
&lustre_attr_mntdev.attr,
+ &lustre_attr_fallocate_zero_blocks.attr,
&lustre_attr_force_sync.attr,
&lustre_attr_nonrotational.attr,
&lustre_attr_index_backup.attr,
LASSERT(name);
LASSERT(type);
- LCONSOLE_INFO("osd-ldiskfs create tunables for %s\n", name);
+ CDEBUG(D_CONFIG, "%s: register osd-ldiskfs tunable parameters\n", name);
+
+ /* put reference taken by class_search_type */
+ kobject_put(&type->typ_kobj);
osd->od_dt_dev.dd_ktype.default_attrs = ldiskfs_attrs;
rc = dt_tunables_init(&osd->od_dt_dev, type, name,
- lprocfs_osd_obd_vars);
+ ldebugfs_osd_obd_vars);
if (rc) {
CERROR("%s: cannot setup sysfs / debugfs entry: %d\n",
name, rc);