summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-03-21 20:14:38 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-07-26 00:17:49 -0800
commita5928421730c2e3d0099e323d8258395b95845ab (patch)
tree087f4db4a614c2ffcb7465e2969a0dd0eff2aa0c
parentb017bfe17b7811f9175a354c21a0abc45b2d9695 (diff)
bcache: printk cleanup
-rw-r--r--drivers/md/bcache/bcache.h12
-rw-r--r--drivers/md/bcache/btree_gc.c4
-rw-r--r--drivers/md/bcache/error.c9
-rw-r--r--drivers/md/bcache/error.h37
-rw-r--r--drivers/md/bcache/fs-gc.c12
-rw-r--r--drivers/md/bcache/fs.c2
-rw-r--r--drivers/md/bcache/journal.c8
-rw-r--r--drivers/md/bcache/super.c29
8 files changed, 58 insertions, 55 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 86bd9fc41a84..18d1e13b30c1 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -208,6 +208,16 @@
#define bch_meta_write_fault(name) \
dynamic_fault("bcache:meta:write:" name)
+#define bch_fmt(_c, fmt) \
+ "bcache (%s): " fmt "\n", ((_c)->name)
+
+#define bch_info(c, fmt, ...) \
+ printk(KERN_INFO bch_fmt(c, fmt), ##__VA_ARGS__)
+#define bch_notice(c, fmt, ...) \
+ printk(KERN_NOTICE bch_fmt(c, fmt), ##__VA_ARGS__)
+#define bch_err(c, fmt, ...) \
+ printk(KERN_ERR bch_fmt(c, fmt), ##__VA_ARGS__)
+
/* Parameters that are useful for debugging, but should always be compiled in: */
#define BCH_DEBUG_PARAMS_ALWAYS() \
BCH_DEBUG_PARAM(key_merging_disabled, \
@@ -510,7 +520,7 @@ struct cache_set {
int minor;
struct device *chardev;
struct super_block *vfs_sb;
- char uuid[40];
+ char name[40];
/* Counts outstanding writes, for clean transition to read-only */
struct percpu_ref writes;
diff --git a/drivers/md/bcache/btree_gc.c b/drivers/md/bcache/btree_gc.c
index c68d63c5d59d..3257c6221ddb 100644
--- a/drivers/md/bcache/btree_gc.c
+++ b/drivers/md/bcache/btree_gc.c
@@ -403,7 +403,7 @@ void bch_gc(struct cache_set *c)
: 0;
if (ret) {
- pr_err("btree gc failed with %d!", ret);
+ bch_err(c, "btree gc failed: %d", ret);
set_bit(CACHE_SET_GC_FAILURE, &c->flags);
up_write(&c->gc_lock);
return;
@@ -757,7 +757,7 @@ static void bch_coalesce(struct cache_set *c)
if (ret) {
if (ret != -ESHUTDOWN)
- pr_err("btree coalescing failed with %d!", ret);
+ bch_err(c, "btree coalescing failed: %d", ret);
set_bit(CACHE_SET_GC_FAILURE, &c->flags);
return;
}
diff --git a/drivers/md/bcache/error.c b/drivers/md/bcache/error.c
index c2a475be0ad7..00f797a340e6 100644
--- a/drivers/md/bcache/error.c
+++ b/drivers/md/bcache/error.c
@@ -17,11 +17,10 @@ void bch_inconsistent_error(struct cache_set *c)
}
if (bch_cache_set_emergency_read_only(c))
- __bch_cache_set_error(c, "emergency read only");
+ bch_err(c, "emergency read only");
break;
case BCH_ON_ERROR_PANIC:
- panic("bcache: (%s) panic after error\n",
- c->vfs_sb ? c->vfs_sb->s_id : c->uuid);
+ panic(bch_fmt(c, "panic after error"));
break;
}
}
@@ -29,7 +28,7 @@ void bch_inconsistent_error(struct cache_set *c)
void bch_fatal_error(struct cache_set *c)
{
if (bch_cache_set_emergency_read_only(c))
- __bch_cache_set_error(c, "emergency read only");
+ bch_err(c, "emergency read only");
}
/* Nonfatal IO errors, IO error/latency accounting: */
@@ -124,7 +123,7 @@ void bch_nonfatal_io_error_work(struct work_struct *work)
if (dev
? bch_cache_read_only(ca)
: bch_cache_set_emergency_read_only(c))
- __bch_cache_set_error(c,
+ bch_err(c,
"too many IO errors on %s, setting %s RO",
bdevname(ca->disk_sb.bdev, buf),
dev ? "device" : "filesystem");
diff --git a/drivers/md/bcache/error.h b/drivers/md/bcache/error.h
index be99a16f71d1..ef93eebc8f1f 100644
--- a/drivers/md/bcache/error.h
+++ b/drivers/md/bcache/error.h
@@ -14,21 +14,11 @@ struct bbio;
/* Error messages: */
-/* should clean this up */
-
-#define __bch_err_fmt(_c, fmt, ...) \
- KERN_ERR "bcache (%s): " fmt "\n", \
- ((_c)->vfs_sb ? (_c)->vfs_sb->s_id : (_c)->uuid), ##__VA_ARGS__
-
-#define __bch_cache_set_error(c, fmt, ...) \
- printk(__bch_err_fmt(c, fmt, ##__VA_ARGS__))
-
#define __bch_cache_error(ca, fmt, ...) \
do { \
char _buf[BDEVNAME_SIZE]; \
- __bch_cache_set_error((ca)->set, "%s: " fmt, \
- bdevname((ca)->disk_sb.bdev, _buf), \
- ##__VA_ARGS__); \
+ bch_err((ca)->set, "%s: " fmt, \
+ bdevname((ca)->disk_sb.bdev, _buf), ##__VA_ARGS__); \
} while (0)
/*
@@ -41,7 +31,7 @@ do { \
#define cache_set_bug(c, ...) \
do { \
- __bch_cache_set_error(c, __VA_ARGS__); \
+ bch_err(c, __VA_ARGS__); \
BUG(); \
} while (0)
@@ -66,7 +56,7 @@ void bch_inconsistent_error(struct cache_set *);
#define cache_set_inconsistent(c, ...) \
do { \
- __bch_cache_set_error(c, __VA_ARGS__); \
+ bch_err(c, __VA_ARGS__); \
bch_inconsistent_error(c); \
} while (0)
@@ -108,7 +98,7 @@ void bch_fatal_error(struct cache_set *);
#define cache_set_fatal_error(c, ...) \
do { \
- __bch_cache_set_error(c, __VA_ARGS__); \
+ bch_err(c, __VA_ARGS__); \
bch_fatal_error(c); \
} while (0)
@@ -131,9 +121,9 @@ do { \
do { \
char _buf[BDEVNAME_SIZE]; \
\
- printk_ratelimited(__bch_err_fmt((ca)->set, "fatal IO error on %s for " fmt,\
- bdevname((ca)->disk_sb.bdev, _buf),\
- ##__VA_ARGS__)); \
+ printk_ratelimited(KERN_ERR bch_fmt((ca)->set, \
+ "fatal IO error on %s for " fmt), \
+ bdevname((ca)->disk_sb.bdev, _buf), ##__VA_ARGS__); \
bch_fatal_error((ca)->set); \
} while (0)
@@ -163,7 +153,7 @@ void bch_nonfatal_io_error(struct cache *);
#if 0
#define cache_set_nonfatal_io_error(c, ...) \
do { \
- __bch_cache_set_error(c, __VA_ARGS__); \
+ bch_err(c, __VA_ARGS__); \
bch_nonfatal_io_error(c); \
} while (0)
#endif
@@ -173,9 +163,9 @@ do { \
do { \
char _buf[BDEVNAME_SIZE]; \
\
- printk_ratelimited(__bch_err_fmt((ca)->set, "IO error on %s for " fmt,\
- bdevname((ca)->disk_sb.bdev, _buf),\
- ##__VA_ARGS__)); \
+ printk_ratelimited(KERN_ERR bch_fmt((ca)->set, \
+ "IO error on %s for " fmt), \
+ bdevname((ca)->disk_sb.bdev, _buf), ##__VA_ARGS__); \
bch_nonfatal_io_error(ca); \
} while (0)
@@ -191,7 +181,8 @@ do { \
/* kill? */
#define __bcache_io_error(c, fmt, ...) \
- printk_ratelimited(__bch_err_fmt(c, "IO error: " fmt, ##__VA_ARGS__))
+ printk_ratelimited(KERN_ERR bch_fmt(c, \
+ "IO error: " fmt, ##__VA_ARGS__))
#define bcache_io_error(c, bio, fmt, ...) \
do { \
diff --git a/drivers/md/bcache/fs-gc.c b/drivers/md/bcache/fs-gc.c
index 264744850422..fa41959c8831 100644
--- a/drivers/md/bcache/fs-gc.c
+++ b/drivers/md/bcache/fs-gc.c
@@ -119,14 +119,14 @@ static int bch_gc_do_inode(struct cache_set *c, struct btree_iter *iter,
i_nlink, link.dir_count);
if (c->opts.verbose_recovery)
- pr_info("deleting inum %llu", inode.k->p.inode);
+ bch_info(c, "deleting inum %llu", inode.k->p.inode);
return bch_inode_rm(c, inode.k->p.inode);
}
if (i_flags & BCH_INODE_I_SIZE_DIRTY) {
if (c->opts.verbose_recovery)
- pr_info("truncating inode %llu", inode.k->p.inode);
+ bch_info(c, "truncating inode %llu", inode.k->p.inode);
/*
* XXX: need to truncate partial blocks too here - or ideally
@@ -148,7 +148,7 @@ static int bch_gc_do_inode(struct cache_set *c, struct btree_iter *iter,
if (i_flags & BCH_INODE_I_SECTORS_DIRTY) {
if (c->opts.verbose_recovery)
- pr_info("recounting sectors for inode %llu", inode.k->p.inode);
+ bch_info(c, "recounting sectors for inode %llu", inode.k->p.inode);
i_sectors = bch_count_inode_sectors(c, inode.k->p.inode);
if (i_sectors < 0)
@@ -160,9 +160,9 @@ static int bch_gc_do_inode(struct cache_set *c, struct btree_iter *iter,
i_flags & BCH_INODE_I_SIZE_DIRTY) {
if (c->opts.verbose_recovery &&
i_nlink != link.count + link.dir_count)
- pr_info("setting inum %llu nlinks from %u to %u",
- inode.k->p.inode, i_nlink,
- link.count + link.dir_count);
+ bch_info(c, "setting inum %llu nlinks from %u to %u",
+ inode.k->p.inode, i_nlink,
+ link.count + link.dir_count);
bkey_reassemble(&update.k_i, inode.s_c);
update.v.i_nlink = cpu_to_le32(link.count + link.dir_count);
diff --git a/drivers/md/bcache/fs.c b/drivers/md/bcache/fs.c
index 7a3b267597e0..ef980abc2c39 100644
--- a/drivers/md/bcache/fs.c
+++ b/drivers/md/bcache/fs.c
@@ -1297,7 +1297,7 @@ static int bch_remount(struct super_block *sb, int *flags, char *data)
} else {
err = bch_cache_set_read_write(c);
if (err) {
- pr_info("error going rw");
+ bch_err(c, "error going rw: %s", err);
ret = -EINVAL;
goto unlock;
}
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 707af9f5d58f..82575d2f29c8 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -1012,13 +1012,13 @@ int bch_journal_replay(struct cache_set *c, struct list_head *list)
entries++;
}
- pr_info("journal replay done, %i keys in %i entries, seq %llu",
- keys, entries, j->seq);
+ bch_info(c, "journal replay done, %i keys in %i entries, seq %llu",
+ keys, entries, j->seq);
bch_journal_set_replay_done(&c->journal);
err:
if (ret)
- pr_err("journal replay error: %d", ret);
+ bch_err(c, "journal replay error: %d", ret);
journal_entries_free(j, list);
@@ -1540,7 +1540,7 @@ static void journal_write_locked(struct closure *cl)
if (!ca) {
/* XXX: fix this */
- pr_err("missing journal write\n");
+ bch_err(c, "missing device for journal write\n");
continue;
}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index fe749a2462d4..aa092893456a 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -943,7 +943,7 @@ void bch_cache_set_release(struct kobject *kobj)
complete(c->stop_completion);
bch_notify_cache_set_stopped(c);
- pr_info("Cache set %pU unregistered", c->disk_sb.set_uuid.b);
+ bch_info(c, "stopped");
cache_set_free(c);
}
@@ -1139,7 +1139,7 @@ static struct cache_set *bch_cache_set_alloc(struct cache_sb *sb,
if (cache_sb_to_cache_set(c, sb))
goto err;
- scnprintf(c->uuid, sizeof(c->uuid), "%pU", &c->disk_sb.user_uuid);
+ scnprintf(c->name, sizeof(c->name), "%pU", &c->disk_sb.user_uuid);
c->opts = cache_superblock_opts(sb);
cache_set_opts_apply(&c->opts, opts);
@@ -1365,7 +1365,7 @@ static const char *run_cache_set(struct cache_set *c)
closure_init_stack(&cl);
- pr_notice("invalidating existing data");
+ bch_notice(c, "initializing new filesystem");
err = "unable to allocate journal buckets";
for_each_cache(ca, c, i)
@@ -1541,8 +1541,7 @@ bool bch_cache_read_only(struct cache *ca)
return false;
if (!bch_cache_may_remove(ca)) {
- printk(__bch_err_fmt(c, "required member %s going RO, forcing fs RO",
- buf));
+ bch_err(c, "required member %s going RO, forcing fs RO", buf);
bch_cache_set_read_only_sync(c);
}
@@ -1551,7 +1550,7 @@ bool bch_cache_read_only(struct cache *ca)
*/
__bch_cache_read_only(ca);
- pr_notice("%s read only", bdevname(ca->disk_sb.bdev, buf));
+ bch_notice(c, "%s read only", bdevname(ca->disk_sb.bdev, buf));
bch_notify_cache_read_only(ca);
SET_CACHE_STATE(&c->disk_mi[ca->sb.nr_this_dev], CACHE_RO);
@@ -1755,7 +1754,8 @@ static void bch_cache_remove_work(struct work_struct *work)
bcache_write_super(c);
} else {
- pr_err("Remove of %s failed, unable to migrate data off", name);
+ bch_err(c, "Remove of %s failed, unable to migrate data off",
+ name);
clear_bit(CACHE_DEV_REMOVING, &ca->flags);
return;
}
@@ -1770,8 +1770,8 @@ static void bch_cache_remove_work(struct work_struct *work)
bcache_write_super(c);
} else {
- pr_err("Remove of %s failed, unable to migrate metadata off",
- name);
+ bch_err(c, "Remove of %s failed, unable to migrate metadata off",
+ name);
clear_bit(CACHE_DEV_REMOVING, &ca->flags);
return;
}
@@ -1820,8 +1820,8 @@ bool bch_cache_remove(struct cache *ca, bool force)
return false;
if (!bch_cache_may_remove(ca)) {
- pr_err("Can't remove last device in tier %u of %pU.",
- ca->mi.tier, ca->set->disk_sb.set_uuid.b);
+ bch_err(ca->set, "Can't remove last device in tier %u",
+ ca->mi.tier);
bch_notify_cache_remove_failed(ca);
return false;
}
@@ -1870,6 +1870,9 @@ static const char *cache_alloc(struct bcache_superblock *sb,
const char *err = "cannot allocate memory";
struct cache *ca;
+ if (c->sb.nr_in_set == 1)
+ bdevname(sb->bdev, c->name);
+
if (cache_set_init_fault("cache_alloc"))
return err;
@@ -2039,7 +2042,7 @@ static const char *register_cache(struct bcache_superblock *sb,
goto err_stop;
out:
- pr_info("registered cache device %s", name);
+ bch_info(c, "started");
return NULL;
err_stop:
bch_cache_set_stop(c);
@@ -2159,7 +2162,7 @@ err_unlock:
mutex_unlock(&bch_register_lock);
free_super(&sb);
- pr_err("Unable to add device: %s", err);
+ bch_err(c, "Unable to add device: %s", err);
return ret ?: -EINVAL;
}