Skip to content

Commit

Permalink
zram: report every added and removed device
Browse files Browse the repository at this point in the history
With dynamic device creation/removal (which will be introduced later in
the series) printing num_devices in zram_init() will not make a lot of
sense, as well as printing the number of destroyed devices in
destroy_devices().  Print per-device action (added/removed) in zram_add()
and zram_remove() instead.

Example:

[ 3645.259652] zram: Added device: zram5
[ 3646.152074] zram: Added device: zram6
[ 3650.585012] zram: Removed device: zram5
[ 3655.845584] zram: Added device: zram8
[ 3660.975223] zram: Removed device: zram6

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Sergey Senozhatsky authored and Linus Torvalds committed Jun 26, 2015
1 parent c3cdb40 commit d12b63c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/block/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,8 @@ static int zram_add(int device_id)
strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
zram->meta = NULL;
zram->max_comp_streams = 1;

pr_info("Added device: %s\n", zram->disk->disk_name);
return 0;

out_free_disk:
Expand All @@ -1254,6 +1256,7 @@ static int zram_add(int device_id)

static void zram_remove(struct zram *zram)
{
pr_info("Removed device: %s\n", zram->disk->disk_name);
/*
* Remove sysfs first, so no one will perform a disksize
* store while we destroy the devices
Expand All @@ -1280,7 +1283,6 @@ static void destroy_devices(void)
idr_for_each(&zram_index_idr, &zram_remove_cb, NULL);
idr_destroy(&zram_index_idr);
unregister_blkdev(zram_major, "zram");
pr_info("Destroyed device(s)\n");
}

static int __init zram_init(void)
Expand All @@ -1299,7 +1301,6 @@ static int __init zram_init(void)
goto out_error;
}

pr_info("Created %u device(s)\n", num_devices);
return 0;

out_error:
Expand Down

0 comments on commit d12b63c

Please sign in to comment.