dm-thin: Change couple of DMWARN() to pr_debug()
PATCH 1/1 dm-thin: Change couple of DMWARN() to pr_debug()
Right now we use DMWARN to output a message on console if thin/snap device creation fails. It has two problems.
- First of all this is not a warning and an error. In case of error, just returning code to user space should be good enough. If we need some debug info out, then a better choice will be pr_debug() which can be enabled when the need be.
- dm-thin expects users to keep track of already used device id. If an application tries to reuse the id, then -EEXIST is returned but this message is also displayed on console.
[17991.140135] device-mapper: thin: Creation of new snapshot 33 of device 3 failed
Docker does not keep track of already used device ids. Instead it starts from 0 and keeps on incrementing this id and retrying till it succeeds. And that leads to flooding console with above messages.
I think it is better to just return error code to user space and not give any warning. Instead convert this into pr_debug() so that if need be one can enable it dynamically using debugfs and get some debug data out on a running system.
One can enable all pr_debug() in dm-thin.c file using following.
echo 'file dm-thin.c +p' > /sys/kernel/debug/dynamic_debug/control
--- drivers/md/dm-thin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-thin.c +4 -2
@@ -4,6 +4,8 @@* This file is released under the GPL. */ +#define pr_fmt (fmt) "device-mapper: thin: " fmt +#include "dm-thin-metadata.h" #include "dm-bio-prison.h" #include "dm.h"
@@ -2819,7 +2821,7 @@ static int process_create_thin_mesg(unsi r =dm_pool_create_thin (pool->pmd, dev_id);if (r) { -DMWARN ("Creation of new thinly-provisioned device with id %s failed." , +pr_debug ("Creation of new thinly-provisioned device with id %s failed." , argv[1 ]);return r; }
@@ -2847,7 +2849,7 @@ static int process_create_snap_mesg(unsi r =dm_pool_create_snap (pool->pmd, dev_id, origin_dev_id);if (r) { -DMWARN ("Creation of new snapshot %s of device %s failed." , +pr_debug ("Creation of new snapshot %s of device %s failed." , argv[1 ], argv[2 ]);return r; }