Skip to content

Commit ba4c369

Browse files
sergey-senozhatskyakpm00
authored andcommitted
zram: rename writeback_compressed device attr
Rename writeback_compressed attr to compressed_writeback to avoid possible confusion and have more natural naming. writeback_compressed may look like an alternative version of writeback while in fact writeback_compressed only sets a writeback property. Make this distinction more clear with a new compressed_writeback name. This updates a feature which is new in 7.0-rcX. Link: https://lkml.kernel.org/r/20260226025429.1042083-1-senozhatsky@chromium.org Fixes: 4c1d613 ("zram: introduce writeback_compressed device attribute") Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Suggested-by: Minchan Kim <minchan@kernel.org> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Brian Geffon <bgeffon@google.com> Cc: Richard Chang <richardycc@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Lars Ellenberg <lars.ellenberg@linbit.com> Cc: Philipp Reisner <philipp.reisner@linbit.com> Cc: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 5548dd7 commit ba4c369

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

Documentation/ABI/testing/sysfs-block-zram

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ Description:
151151
The algorithm_params file is write-only and is used to setup
152152
compression algorithm parameters.
153153

154-
What: /sys/block/zram<id>/writeback_compressed
154+
What: /sys/block/zram<id>/compressed_writeback
155155
Date: Decemeber 2025
156156
Contact: Richard Chang <richardycc@google.com>
157157
Description:
158-
The writeback_compressed device atrribute toggles compressed
158+
The compressed_writeback device atrribute toggles compressed
159159
writeback feature.
160160

161161
What: /sys/block/zram<id>/writeback_batch_size

Documentation/admin-guide/blockdev/zram.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ writeback_limit WO specifies the maximum amount of write IO zram
216216
writeback_limit_enable RW show and set writeback_limit feature
217217
writeback_batch_size RW show and set maximum number of in-flight
218218
writeback operations
219-
writeback_compressed RW show and set compressed writeback feature
219+
compressed_writeback RW show and set compressed writeback feature
220220
comp_algorithm RW show and change the compression algorithm
221221
algorithm_params WO setup compression algorithm parameters
222222
compact WO trigger memory compaction
@@ -439,11 +439,11 @@ budget in next setting is user's job.
439439
By default zram stores written back pages in decompressed (raw) form, which
440440
means that writeback operation involves decompression of the page before
441441
writing it to the backing device. This behavior can be changed by enabling
442-
`writeback_compressed` feature, which causes zram to write compressed pages
442+
`compressed_writeback` feature, which causes zram to write compressed pages
443443
to the backing device, thus avoiding decompression overhead. To enable
444444
this feature, execute::
445445

446-
$ echo yes > /sys/block/zramX/writeback_compressed
446+
$ echo yes > /sys/block/zramX/compressed_writeback
447447

448448
Note that this feature should be configured before the `zramX` device is
449449
initialized.

drivers/block/zram/zram_drv.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static ssize_t bd_stat_show(struct device *dev, struct device_attribute *attr,
549549
return ret;
550550
}
551551

552-
static ssize_t writeback_compressed_store(struct device *dev,
552+
static ssize_t compressed_writeback_store(struct device *dev,
553553
struct device_attribute *attr,
554554
const char *buf, size_t len)
555555
{
@@ -564,20 +564,20 @@ static ssize_t writeback_compressed_store(struct device *dev,
564564
return -EBUSY;
565565
}
566566

567-
zram->wb_compressed = val;
567+
zram->compressed_wb = val;
568568

569569
return len;
570570
}
571571

572-
static ssize_t writeback_compressed_show(struct device *dev,
572+
static ssize_t compressed_writeback_show(struct device *dev,
573573
struct device_attribute *attr,
574574
char *buf)
575575
{
576576
bool val;
577577
struct zram *zram = dev_to_zram(dev);
578578

579579
guard(rwsem_read)(&zram->dev_lock);
580-
val = zram->wb_compressed;
580+
val = zram->compressed_wb;
581581

582582
return sysfs_emit(buf, "%d\n", val);
583583
}
@@ -946,7 +946,7 @@ static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
946946
goto out;
947947
}
948948

949-
if (zram->wb_compressed) {
949+
if (zram->compressed_wb) {
950950
/*
951951
* ZRAM_WB slots get freed, we need to preserve data required
952952
* for read decompression.
@@ -960,7 +960,7 @@ static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
960960
set_slot_flag(zram, index, ZRAM_WB);
961961
set_slot_handle(zram, index, req->blk_idx);
962962

963-
if (zram->wb_compressed) {
963+
if (zram->compressed_wb) {
964964
if (huge)
965965
set_slot_flag(zram, index, ZRAM_HUGE);
966966
set_slot_size(zram, index, size);
@@ -1100,7 +1100,7 @@ static int zram_writeback_slots(struct zram *zram,
11001100
*/
11011101
if (!test_slot_flag(zram, index, ZRAM_PP_SLOT))
11021102
goto next;
1103-
if (zram->wb_compressed)
1103+
if (zram->compressed_wb)
11041104
err = read_from_zspool_raw(zram, req->page, index);
11051105
else
11061106
err = read_from_zspool(zram, req->page, index);
@@ -1429,7 +1429,7 @@ static void zram_async_read_endio(struct bio *bio)
14291429
*
14301430
* Keep the existing behavior for now.
14311431
*/
1432-
if (zram->wb_compressed == false) {
1432+
if (zram->compressed_wb == false) {
14331433
/* No decompression needed, complete the parent IO */
14341434
bio_endio(req->parent);
14351435
bio_put(bio);
@@ -1508,7 +1508,7 @@ static int read_from_bdev_sync(struct zram *zram, struct page *page, u32 index,
15081508
flush_work(&req.work);
15091509
destroy_work_on_stack(&req.work);
15101510

1511-
if (req.error || zram->wb_compressed == false)
1511+
if (req.error || zram->compressed_wb == false)
15121512
return req.error;
15131513

15141514
return decompress_bdev_page(zram, page, index);
@@ -3007,7 +3007,7 @@ static DEVICE_ATTR_WO(writeback);
30073007
static DEVICE_ATTR_RW(writeback_limit);
30083008
static DEVICE_ATTR_RW(writeback_limit_enable);
30093009
static DEVICE_ATTR_RW(writeback_batch_size);
3010-
static DEVICE_ATTR_RW(writeback_compressed);
3010+
static DEVICE_ATTR_RW(compressed_writeback);
30113011
#endif
30123012
#ifdef CONFIG_ZRAM_MULTI_COMP
30133013
static DEVICE_ATTR_RW(recomp_algorithm);
@@ -3031,7 +3031,7 @@ static struct attribute *zram_disk_attrs[] = {
30313031
&dev_attr_writeback_limit.attr,
30323032
&dev_attr_writeback_limit_enable.attr,
30333033
&dev_attr_writeback_batch_size.attr,
3034-
&dev_attr_writeback_compressed.attr,
3034+
&dev_attr_compressed_writeback.attr,
30353035
#endif
30363036
&dev_attr_io_stat.attr,
30373037
&dev_attr_mm_stat.attr,
@@ -3091,7 +3091,7 @@ static int zram_add(void)
30913091
init_rwsem(&zram->dev_lock);
30923092
#ifdef CONFIG_ZRAM_WRITEBACK
30933093
zram->wb_batch_size = 32;
3094-
zram->wb_compressed = false;
3094+
zram->compressed_wb = false;
30953095
#endif
30963096

30973097
/* gendisk structure */

drivers/block/zram/zram_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct zram {
133133
#ifdef CONFIG_ZRAM_WRITEBACK
134134
struct file *backing_dev;
135135
bool wb_limit_enable;
136-
bool wb_compressed;
136+
bool compressed_wb;
137137
u32 wb_batch_size;
138138
u64 bd_wb_limit;
139139
struct block_device *bdev;

0 commit comments

Comments
 (0)