diff options
| author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2016-05-20 19:59:59 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 20:58:30 -0400 |
| commit | 43209ea2d17aae1540d4e28274e36404f72702f2 (patch) | |
| tree | be21fbbabf6fabeb3e1dd4ca2c0684f238458c55 /drivers/block/zram | |
| parent | d34f615720d17c49b6779f6fcd5cb7eb82231a38 (diff) | |
zram: remove max_comp_streams internals
Remove the internal part of max_comp_streams interface, since we
switched to per-cpu streams. We will keep RW max_comp_streams attr
around, because:
a) we may (silently) switch back to idle compression streams list and
don't want to disturb user space
b) max_comp_streams attr must wait for the next 'lay off cycle'; we
give user space 2 years to adjust before we remove/downgrade the attr,
and there are already several attrs scheduled for removal in 4.11, so
it's too late for max_comp_streams.
This slightly change a user visible behaviour:
- First, reading from max_comp_stream file now will always return the
number of online CPUs.
- Second, writing to max_comp_stream will not take any effect.
Link: http://lkml.kernel.org/r/20160503165546.25201-1-sergey.senozhatsky@gmail.com
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram')
| -rw-r--r-- | drivers/block/zram/zcomp.c | 5 | ||||
| -rw-r--r-- | drivers/block/zram/zram_drv.c | 45 | ||||
| -rw-r--r-- | drivers/block/zram/zram_drv.h | 1 |
3 files changed, 11 insertions, 40 deletions
diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index bc98d5ed5477..b51a816d766b 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c | |||
| @@ -95,11 +95,6 @@ bool zcomp_available_algorithm(const char *comp) | |||
| 95 | return find_backend(comp) != NULL; | 95 | return find_backend(comp) != NULL; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | bool zcomp_set_max_streams(struct zcomp *comp, int num_strm) | ||
| 99 | { | ||
| 100 | return true; | ||
| 101 | } | ||
| 102 | |||
| 103 | struct zcomp_strm *zcomp_strm_find(struct zcomp *comp) | 98 | struct zcomp_strm *zcomp_strm_find(struct zcomp *comp) |
| 104 | { | 99 | { |
| 105 | return *get_cpu_ptr(comp->stream); | 100 | return *get_cpu_ptr(comp->stream); |
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index f92965c4229b..8fcfbebe79cd 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
| @@ -304,46 +304,25 @@ static ssize_t mem_used_max_store(struct device *dev, | |||
| 304 | return len; | 304 | return len; |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | /* | ||
| 308 | * We switched to per-cpu streams and this attr is not needed anymore. | ||
| 309 | * However, we will keep it around for some time, because: | ||
| 310 | * a) we may revert per-cpu streams in the future | ||
| 311 | * b) it's visible to user space and we need to follow our 2 years | ||
| 312 | * retirement rule; but we already have a number of 'soon to be | ||
| 313 | * altered' attrs, so max_comp_streams need to wait for the next | ||
| 314 | * layoff cycle. | ||
| 315 | */ | ||
| 307 | static ssize_t max_comp_streams_show(struct device *dev, | 316 | static ssize_t max_comp_streams_show(struct device *dev, |
| 308 | struct device_attribute *attr, char *buf) | 317 | struct device_attribute *attr, char *buf) |
| 309 | { | 318 | { |
| 310 | int val; | 319 | return scnprintf(buf, PAGE_SIZE, "%d\n", num_online_cpus()); |
| 311 | struct zram *zram = dev_to_zram(dev); | ||
| 312 | |||
| 313 | down_read(&zram->init_lock); | ||
| 314 | val = zram->max_comp_streams; | ||
| 315 | up_read(&zram->init_lock); | ||
| 316 | |||
| 317 | return scnprintf(buf, PAGE_SIZE, "%d\n", val); | ||
| 318 | } | 320 | } |
| 319 | 321 | ||
| 320 | static ssize_t max_comp_streams_store(struct device *dev, | 322 | static ssize_t max_comp_streams_store(struct device *dev, |
| 321 | struct device_attribute *attr, const char *buf, size_t len) | 323 | struct device_attribute *attr, const char *buf, size_t len) |
| 322 | { | 324 | { |
| 323 | int num; | 325 | return len; |
| 324 | struct zram *zram = dev_to_zram(dev); | ||
| 325 | int ret; | ||
| 326 | |||
| 327 | ret = kstrtoint(buf, 0, &num); | ||
| 328 | if (ret < 0) | ||
| 329 | return ret; | ||
| 330 | if (num < 1) | ||
| 331 | return -EINVAL; | ||
| 332 | |||
| 333 | down_write(&zram->init_lock); | ||
| 334 | if (init_done(zram)) { | ||
| 335 | if (!zcomp_set_max_streams(zram->comp, num)) { | ||
| 336 | pr_info("Cannot change max compression streams\n"); | ||
| 337 | ret = -EINVAL; | ||
| 338 | goto out; | ||
| 339 | } | ||
| 340 | } | ||
| 341 | |||
| 342 | zram->max_comp_streams = num; | ||
| 343 | ret = len; | ||
| 344 | out: | ||
| 345 | up_write(&zram->init_lock); | ||
| 346 | return ret; | ||
| 347 | } | 326 | } |
| 348 | 327 | ||
| 349 | static ssize_t comp_algorithm_show(struct device *dev, | 328 | static ssize_t comp_algorithm_show(struct device *dev, |
| @@ -1035,7 +1014,6 @@ static void zram_reset_device(struct zram *zram) | |||
| 1035 | /* Reset stats */ | 1014 | /* Reset stats */ |
| 1036 | memset(&zram->stats, 0, sizeof(zram->stats)); | 1015 | memset(&zram->stats, 0, sizeof(zram->stats)); |
| 1037 | zram->disksize = 0; | 1016 | zram->disksize = 0; |
| 1038 | zram->max_comp_streams = 1; | ||
| 1039 | 1017 | ||
| 1040 | set_capacity(zram->disk, 0); | 1018 | set_capacity(zram->disk, 0); |
| 1041 | part_stat_set_all(&zram->disk->part0, 0); | 1019 | part_stat_set_all(&zram->disk->part0, 0); |
| @@ -1299,7 +1277,6 @@ static int zram_add(void) | |||
| 1299 | } | 1277 | } |
| 1300 | strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); | 1278 | strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); |
| 1301 | zram->meta = NULL; | 1279 | zram->meta = NULL; |
| 1302 | zram->max_comp_streams = 1; | ||
| 1303 | 1280 | ||
| 1304 | pr_info("Added device: %s\n", zram->disk->disk_name); | 1281 | pr_info("Added device: %s\n", zram->disk->disk_name); |
| 1305 | return device_id; | 1282 | return device_id; |
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index 8e92339686d7..06b1636f4722 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h | |||
| @@ -102,7 +102,6 @@ struct zram { | |||
| 102 | * the number of pages zram can consume for storing compressed data | 102 | * the number of pages zram can consume for storing compressed data |
| 103 | */ | 103 | */ |
| 104 | unsigned long limit_pages; | 104 | unsigned long limit_pages; |
| 105 | int max_comp_streams; | ||
| 106 | 105 | ||
| 107 | struct zram_stats stats; | 106 | struct zram_stats stats; |
| 108 | atomic_t refcount; /* refcount for zram_meta */ | 107 | atomic_t refcount; /* refcount for zram_meta */ |
