Skip to content

Commit 99ebbd3

Browse files
akpm00torvalds
authored andcommitted
revert "zram: move compact_store() to sysfs functions area"
Revert commit c72c616 It was intended to be a cosmetic change that w/o any functional change and was part of a bigger change: http://lkml.iu.edu/hypermail/linux/kernel/1503.1/01818.html Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d9cee5d commit 99ebbd3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/block/zram/zram_drv.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,27 @@ static inline struct zram *dev_to_zram(struct device *dev)
7474
return (struct zram *)dev_to_disk(dev)->private_data;
7575
}
7676

77+
static ssize_t compact_store(struct device *dev,
78+
struct device_attribute *attr, const char *buf, size_t len)
79+
{
80+
unsigned long nr_migrated;
81+
struct zram *zram = dev_to_zram(dev);
82+
struct zram_meta *meta;
83+
84+
down_read(&zram->init_lock);
85+
if (!init_done(zram)) {
86+
up_read(&zram->init_lock);
87+
return -EINVAL;
88+
}
89+
90+
meta = zram->meta;
91+
nr_migrated = zs_compact(meta->mem_pool);
92+
atomic64_add(nr_migrated, &zram->stats.num_migrated);
93+
up_read(&zram->init_lock);
94+
95+
return len;
96+
}
97+
7798
static ssize_t disksize_show(struct device *dev,
7899
struct device_attribute *attr, char *buf)
79100
{
@@ -1038,6 +1059,7 @@ static const struct block_device_operations zram_devops = {
10381059
.owner = THIS_MODULE
10391060
};
10401061

1062+
static DEVICE_ATTR_WO(compact);
10411063
static DEVICE_ATTR_RW(disksize);
10421064
static DEVICE_ATTR_RO(initstate);
10431065
static DEVICE_ATTR_WO(reset);
@@ -1114,6 +1136,7 @@ static struct attribute *zram_disk_attrs[] = {
11141136
&dev_attr_num_writes.attr,
11151137
&dev_attr_failed_reads.attr,
11161138
&dev_attr_failed_writes.attr,
1139+
&dev_attr_compact.attr,
11171140
&dev_attr_invalid_io.attr,
11181141
&dev_attr_notify_free.attr,
11191142
&dev_attr_zero_pages.attr,

0 commit comments

Comments
 (0)