static struct kobject *llite_kobj;
static struct dentry *llite_root;
+static void llite_kobj_release(struct kobject *kobj)
+{
+ if (!IS_ERR_OR_NULL(llite_root)) {
+ debugfs_remove(llite_root);
+ llite_root = NULL;
+ }
+
+ kfree(kobj);
+}
+
+static struct kobj_type llite_kobj_ktype = {
+ .release = llite_kobj_release,
+ .sysfs_ops = &lustre_sysfs_ops,
+};
+
int llite_tunables_register(void)
{
- int rc = 0;
+ int rc;
- llite_kobj = class_setup_tunables("llite");
- if (IS_ERR(llite_kobj))
- return PTR_ERR(llite_kobj);
+ llite_kobj = kzalloc(sizeof(*llite_kobj), GFP_KERNEL);
+ if (!llite_kobj)
+ return -ENOMEM;
+
+ llite_kobj->kset = lustre_kset;
+ rc = kobject_init_and_add(llite_kobj, &llite_kobj_ktype,
+ &lustre_kset->kobj, "%s", "llite");
+ if (rc)
+ goto free_kobj;
llite_root = debugfs_create_dir("llite", debugfs_lustre_root);
if (IS_ERR_OR_NULL(llite_root)) {
rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM;
llite_root = NULL;
+free_kobj:
kobject_put(llite_kobj);
llite_kobj = NULL;
}
void llite_tunables_unregister(void)
{
- if (llite_kobj) {
- kobject_put(llite_kobj);
- llite_kobj = NULL;
- }
-
- if (!IS_ERR_OR_NULL(llite_root)) {
- debugfs_remove(llite_root);
- llite_root = NULL;
- }
+ kobject_put(llite_kobj);
+ llite_kobj = NULL;
}
/* <debugfs>/lustre/llite mount point registration */
if (pages_number < 0 || pages_number > totalram_pages / 2) {
/* 1/2 of RAM */
CERROR("%s: can't set max_readahead_mb=%lu > %luMB\n",
- ll_get_fsname(sb, NULL, 0),
+ sbi->ll_fsname,
(unsigned long)pages_number >> (20 - PAGE_SHIFT),
totalram_pages >> (20 - PAGE_SHIFT + 1));
return -ERANGE;
if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages) {
CERROR("%s: can't set max_readahead_per_file_mb=%lu > "
- "max_read_ahead_mb=%lu\n", ll_get_fsname(sb, NULL, 0),
+ "max_read_ahead_mb=%lu\n", sbi->ll_fsname,
(unsigned long)pages_number >> (20 - PAGE_SHIFT),
sbi->ll_ra_info.ra_max_pages >> (20 - PAGE_SHIFT));
return -ERANGE;
int pages_shift = 20 - PAGE_SHIFT;
CERROR("%s: can't set max_read_ahead_whole_mb=%lu > "
"max_read_ahead_per_file_mb=%lu\n",
- ll_get_fsname(sb, NULL, 0),
+ sbi->ll_fsname,
(unsigned long)pages_number >> pages_shift,
sbi->ll_ra_info.ra_max_pages_per_file >> pages_shift);
return -ERANGE;
if (pages_number < 0 || pages_number > totalram_pages) {
CERROR("%s: can't set max cache more than %lu MB\n",
- ll_get_fsname(sb, NULL, 0),
+ sbi->ll_fsname,
totalram_pages >> (20 - PAGE_SHIFT));
RETURN(-ERANGE);
}
while (flags != 0) {
if (ARRAY_SIZE(str) <= i) {
CERROR("%s: Revise array LL_SBI_FLAGS to match sbi "
- "flags please.\n", ll_get_fsname(sb, NULL, 0));
+ "flags please.\n", ll_s2sbi(sb)->ll_fsname);
return -EINVAL;
}
}
LUSTRE_RW_ATTR(fast_read);
-static ssize_t pio_show(struct kobject *kobj,
- struct attribute *attr,
- char *buf)
+static ssize_t file_heat_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
ll_kset.kobj);
- return sprintf(buf, "%u\n", !!(sbi->ll_flags & LL_SBI_PIO));
+ return snprintf(buf, PAGE_SIZE, "%u\n",
+ !!(sbi->ll_flags & LL_SBI_FILE_HEAT));
}
-static ssize_t pio_store(struct kobject *kobj,
- struct attribute *attr,
- const char *buffer,
- size_t count)
+static ssize_t file_heat_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
ll_kset.kobj);
spin_lock(&sbi->ll_lock);
if (val)
- sbi->ll_flags |= LL_SBI_PIO;
+ sbi->ll_flags |= LL_SBI_FILE_HEAT;
else
- sbi->ll_flags &= ~LL_SBI_PIO;
+ sbi->ll_flags &= ~LL_SBI_FILE_HEAT;
spin_unlock(&sbi->ll_lock);
return count;
}
-LUSTRE_RW_ATTR(pio);
+LUSTRE_RW_ATTR(file_heat);
+
+static ssize_t heat_decay_percentage_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kset.kobj);
+
+ return snprintf(buf, PAGE_SIZE, "%u\n",
+ (sbi->ll_heat_decay_weight * 100 + 128) / 256);
+}
+
+static ssize_t heat_decay_percentage_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
+{
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kset.kobj);
+ unsigned long val;
+ int rc;
+
+ rc = kstrtoul(buffer, 10, &val);
+ if (rc)
+ return rc;
+
+ if (val < 0 || val > 100)
+ return -ERANGE;
+
+ sbi->ll_heat_decay_weight = (val * 256 + 50) / 100;
+
+ return count;
+}
+LUSTRE_RW_ATTR(heat_decay_percentage);
+
+static ssize_t heat_period_second_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kset.kobj);
+
+ return snprintf(buf, PAGE_SIZE, "%u\n", sbi->ll_heat_period_second);
+}
+
+static ssize_t heat_period_second_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
+{
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kset.kobj);
+ unsigned long val;
+ int rc;
+
+ rc = kstrtoul(buffer, 10, &val);
+ if (rc)
+ return rc;
+
+ if (val <= 0)
+ return -ERANGE;
+
+ sbi->ll_heat_period_second = val;
+
+ return count;
+}
+LUSTRE_RW_ATTR(heat_period_second);
static int ll_unstable_stats_seq_show(struct seq_file *m, void *v)
{
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct root_squash_info *squash = &sbi->ll_squash;
- return lprocfs_wr_root_squash(buffer, count, squash,
- ll_get_fsname(sb, NULL, 0));
+ return lprocfs_wr_root_squash(buffer, count, squash, sbi->ll_fsname);
}
LDEBUGFS_SEQ_FOPS(ll_root_squash);
struct root_squash_info *squash = &sbi->ll_squash;
int rc;
- rc = lprocfs_wr_nosquash_nids(buffer, count, squash,
- ll_get_fsname(sb, NULL, 0));
+ rc = lprocfs_wr_nosquash_nids(buffer, count, squash, sbi->ll_fsname);
if (rc < 0)
return rc;
&lustre_attr_default_easize.attr,
&lustre_attr_xattr_cache.attr,
&lustre_attr_fast_read.attr,
- &lustre_attr_pio.attr,
&lustre_attr_tiny_write.attr,
+ &lustre_attr_file_heat.attr,
+ &lustre_attr_heat_decay_percentage.attr,
+ &lustre_attr_heat_period_second.attr,
NULL,
};
-static void llite_kobj_release(struct kobject *kobj)
+static void sbi_kobj_release(struct kobject *kobj)
{
struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
ll_kset.kobj);
complete(&sbi->ll_kobj_unregister);
}
-static struct kobj_type llite_ktype = {
+static struct kobj_type sbi_ktype = {
.default_attrs = llite_attrs,
.sysfs_ops = &lustre_sysfs_ops,
- .release = llite_kobj_release,
+ .release = sbi_kobj_release,
};
static const struct llite_file_opcode {
out_ll_kset:
/* Yes we also register sysfs mount kset here as well */
sbi->ll_kset.kobj.parent = llite_kobj;
- sbi->ll_kset.kobj.ktype = &llite_ktype;
+ sbi->ll_kset.kobj.ktype = &sbi_ktype;
init_completion(&sbi->ll_kobj_unregister);
err = kobject_set_name(&sbi->ll_kset.kobj, "%s", name);
if (err)