|
@@ -304,46 +304,25 @@ static ssize_t mem_used_max_store(struct device *dev,
|
|
return len;
|
|
return len;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * We switched to per-cpu streams and this attr is not needed anymore.
|
|
|
|
+ * However, we will keep it around for some time, because:
|
|
|
|
+ * a) we may revert per-cpu streams in the future
|
|
|
|
+ * b) it's visible to user space and we need to follow our 2 years
|
|
|
|
+ * retirement rule; but we already have a number of 'soon to be
|
|
|
|
+ * altered' attrs, so max_comp_streams need to wait for the next
|
|
|
|
+ * layoff cycle.
|
|
|
|
+ */
|
|
static ssize_t max_comp_streams_show(struct device *dev,
|
|
static ssize_t max_comp_streams_show(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
{
|
|
- int val;
|
|
|
|
- struct zram *zram = dev_to_zram(dev);
|
|
|
|
-
|
|
|
|
- down_read(&zram->init_lock);
|
|
|
|
- val = zram->max_comp_streams;
|
|
|
|
- up_read(&zram->init_lock);
|
|
|
|
-
|
|
|
|
- return scnprintf(buf, PAGE_SIZE, "%d\n", val);
|
|
|
|
|
|
+ return scnprintf(buf, PAGE_SIZE, "%d\n", num_online_cpus());
|
|
}
|
|
}
|
|
|
|
|
|
static ssize_t max_comp_streams_store(struct device *dev,
|
|
static ssize_t max_comp_streams_store(struct device *dev,
|
|
struct device_attribute *attr, const char *buf, size_t len)
|
|
struct device_attribute *attr, const char *buf, size_t len)
|
|
{
|
|
{
|
|
- int num;
|
|
|
|
- struct zram *zram = dev_to_zram(dev);
|
|
|
|
- int ret;
|
|
|
|
-
|
|
|
|
- ret = kstrtoint(buf, 0, &num);
|
|
|
|
- if (ret < 0)
|
|
|
|
- return ret;
|
|
|
|
- if (num < 1)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- down_write(&zram->init_lock);
|
|
|
|
- if (init_done(zram)) {
|
|
|
|
- if (!zcomp_set_max_streams(zram->comp, num)) {
|
|
|
|
- pr_info("Cannot change max compression streams\n");
|
|
|
|
- ret = -EINVAL;
|
|
|
|
- goto out;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- zram->max_comp_streams = num;
|
|
|
|
- ret = len;
|
|
|
|
-out:
|
|
|
|
- up_write(&zram->init_lock);
|
|
|
|
- return ret;
|
|
|
|
|
|
+ return len;
|
|
}
|
|
}
|
|
|
|
|
|
static ssize_t comp_algorithm_show(struct device *dev,
|
|
static ssize_t comp_algorithm_show(struct device *dev,
|
|
@@ -1035,7 +1014,6 @@ static void zram_reset_device(struct zram *zram)
|
|
/* Reset stats */
|
|
/* Reset stats */
|
|
memset(&zram->stats, 0, sizeof(zram->stats));
|
|
memset(&zram->stats, 0, sizeof(zram->stats));
|
|
zram->disksize = 0;
|
|
zram->disksize = 0;
|
|
- zram->max_comp_streams = 1;
|
|
|
|
|
|
|
|
set_capacity(zram->disk, 0);
|
|
set_capacity(zram->disk, 0);
|
|
part_stat_set_all(&zram->disk->part0, 0);
|
|
part_stat_set_all(&zram->disk->part0, 0);
|
|
@@ -1299,7 +1277,6 @@ static int zram_add(void)
|
|
}
|
|
}
|
|
strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
|
|
strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
|
|
zram->meta = NULL;
|
|
zram->meta = NULL;
|
|
- zram->max_comp_streams = 1;
|
|
|
|
|
|
|
|
pr_info("Added device: %s\n", zram->disk->disk_name);
|
|
pr_info("Added device: %s\n", zram->disk->disk_name);
|
|
return device_id;
|
|
return device_id;
|