|
@@ -94,34 +94,6 @@ static int page_zero_filled(void *ptr)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
|
|
|
-{
|
|
|
- if (!zram->disksize) {
|
|
|
- pr_info(
|
|
|
- "disk size not provided. You can use disksize_kb module "
|
|
|
- "param to specify size.\nUsing default: (%u%% of RAM).\n",
|
|
|
- default_disksize_perc_ram
|
|
|
- );
|
|
|
- zram->disksize = default_disksize_perc_ram *
|
|
|
- (totalram_bytes / 100);
|
|
|
- }
|
|
|
-
|
|
|
- if (zram->disksize > 2 * (totalram_bytes)) {
|
|
|
- pr_info(
|
|
|
- "There is little point creating a zram of greater than "
|
|
|
- "twice the size of memory since we expect a 2:1 compression "
|
|
|
- "ratio. Note that zram uses about 0.1%% of the size of "
|
|
|
- "the disk when not in use so a huge zram is "
|
|
|
- "wasteful.\n"
|
|
|
- "\tMemory Size: %zu kB\n"
|
|
|
- "\tSize you selected: %llu kB\n"
|
|
|
- "Continuing anyway ...\n",
|
|
|
- totalram_bytes >> 10, zram->disksize >> 10);
|
|
|
- }
|
|
|
-
|
|
|
- zram->disksize &= PAGE_MASK;
|
|
|
-}
|
|
|
-
|
|
|
static void zram_free_page(struct zram *zram, size_t index)
|
|
|
{
|
|
|
unsigned long handle = zram->table[index].handle;
|
|
@@ -497,6 +469,9 @@ void __zram_reset_device(struct zram *zram)
|
|
|
{
|
|
|
size_t index;
|
|
|
|
|
|
+ if (!zram->init_done)
|
|
|
+ return;
|
|
|
+
|
|
|
zram->init_done = 0;
|
|
|
|
|
|
/* Free various per-device buffers */
|
|
@@ -525,6 +500,7 @@ void __zram_reset_device(struct zram *zram)
|
|
|
memset(&zram->stats, 0, sizeof(zram->stats));
|
|
|
|
|
|
zram->disksize = 0;
|
|
|
+ set_capacity(zram->disk, 0);
|
|
|
}
|
|
|
|
|
|
void zram_reset_device(struct zram *zram)
|
|
@@ -546,7 +522,19 @@ int zram_init_device(struct zram *zram)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- zram_set_disksize(zram, totalram_pages << PAGE_SHIFT);
|
|
|
+ if (zram->disksize > 2 * (totalram_pages << PAGE_SHIFT)) {
|
|
|
+ pr_info(
|
|
|
+ "There is little point creating a zram of greater than "
|
|
|
+ "twice the size of memory since we expect a 2:1 compression "
|
|
|
+ "ratio. Note that zram uses about 0.1%% of the size of "
|
|
|
+ "the disk when not in use so a huge zram is "
|
|
|
+ "wasteful.\n"
|
|
|
+ "\tMemory Size: %zu kB\n"
|
|
|
+ "\tSize you selected: %llu kB\n"
|
|
|
+ "Continuing anyway ...\n",
|
|
|
+ (totalram_pages << PAGE_SHIFT) >> 10, zram->disksize >> 10
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
zram->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
|
|
|
if (!zram->compress_workmem) {
|
|
@@ -571,8 +559,6 @@ int zram_init_device(struct zram *zram)
|
|
|
goto fail_no_table;
|
|
|
}
|
|
|
|
|
|
- set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
|
|
|
-
|
|
|
/* zram devices sort of resembles non-rotational disks */
|
|
|
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue);
|
|
|
|
|
@@ -751,8 +737,7 @@ static void __exit zram_exit(void)
|
|
|
zram = &zram_devices[i];
|
|
|
|
|
|
destroy_device(zram);
|
|
|
- if (zram->init_done)
|
|
|
- zram_reset_device(zram);
|
|
|
+ zram_reset_device(zram);
|
|
|
}
|
|
|
|
|
|
unregister_blkdev(zram_major, "zram");
|