Skip to contentSkip to conversation

md: bcache: Add missing newlines to logging messages, & misc neatening

PATCH New Joe Perches 1 participant 1 message Oct 20, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md: bcache: Add missing newlines to logging messages, & misc neatening

Logging messages require terminating newlines to avoid possible interleaving by other messages. Add them.

Convert bch_cache_set_error printk/vprintk/printk sequence to use vsprintf extension %pV to eliminate any possible interleaving.

Convert some variadic macro uses of ... to fmt, ... to make clear the message use of the macro.

---
 drivers/md/bcache/bcache.h   | 20 ++++++-------
 drivers/md/bcache/bset.c     |  5 ++--
 drivers/md/bcache/btree.c    |  8 ++---
 drivers/md/bcache/io.c       |  2 +-
 drivers/md/bcache/journal.c  | 14 ++++-----
 drivers/md/bcache/movinggc.c |  2 +-
 drivers/md/bcache/request.c  |  4 +--
 drivers/md/bcache/super.c    | 71 +++++++++++++++++++++++---------------------
 drivers/md/bcache/sysfs.c    |  2 +-
 9 files changed, 66 insertions(+), 62 deletions(-)
drivers/md/bcache/bcache.h +10 -10
index 4beb55a..c10cfaa 100644
@@ -801,34 +801,34 @@ static inline void bkey_init(struct bkey *k)
 
 /* Error handling macros */
 
-#define btree_bug(b, ...)						\
+#define btree_bug(b, fmt, ...)						\
 do {									\
-	if (bch_cache_set_error((b)->c, __VA_ARGS__))			\
+	if (bch_cache_set_error((b)->c, fmt, ##__VA_ARGS__))		\
 		dump_stack();						\
 } while (0)
 
-#define cache_bug(c, ...)						\
+#define cache_bug(c, fmt, ...)						\
 do {									\
-	if (bch_cache_set_error(c, __VA_ARGS__))			\
+	if (bch_cache_set_error(c, fmt, ##__VA_ARGS__))			\
 		dump_stack();						\
 } while (0)
 
-#define btree_bug_on(cond, b, ...)					\
+#define btree_bug_on(cond, b, fmt, ...)					\
 do {									\
 	if (cond)							\
-		btree_bug(b, __VA_ARGS__);				\
+		btree_bug(b, fmt, ##__VA_ARGS__);			\
 } while (0)
 
-#define cache_bug_on(cond, c, ...)					\
+#define cache_bug_on(cond, c, fmt, ...)					\
 do {									\
 	if (cond)							\
-		cache_bug(c, __VA_ARGS__);				\
+		cache_bug(c, fmt, ##__VA_ARGS__);			\
 } while (0)
 
-#define cache_set_err_on(cond, c, ...)					\
+#define cache_set_err_on(cond, c, fmt, ...)				\
 do {									\
 	if (cond)							\
-		bch_cache_set_error(c, __VA_ARGS__);			\
+		bch_cache_set_error(c, fmt, ##__VA_ARGS__);		\
 } while (0)
 
 /* Looping macros */
drivers/md/bcache/bset.c +3 -2
index 7d388b8..7c6a681 100644
@@ -401,8 +401,9 @@ void inorder_test(void)
 		unsigned i = 1, j = rounddown_pow_of_two(size - 1);
 
 		if (!(size % 4096))
-			printk(KERN_NOTICE "loop %u, %llu per us\n", size,
-			       done / ktime_us_delta(ktime_get(), start));
+			pr_notice("loop %u, %llu per us\n",
+				  size,
+				  done / ktime_us_delta(ktime_get(), start));
 
 		while (1) {
 			if (__inorder_to_tree(i, size, extra) != j)
drivers/md/bcache/btree.c +4 -4
index 1ccb702..ca132e5 100644
@@ -1612,7 +1612,7 @@ static void bch_btree_gc(struct cache_set *c)
 		closure_sync(&writes);
 
 		if (ret && ret != -EAGAIN)
-			pr_warn("gc failed!");
+			pr_warn("gc failed!\n");
 	} while (ret);
 
 	available = bch_btree_gc_finish(c);
@@ -2134,7 +2134,7 @@ err:
 	    n1 == ERR_PTR(-EAGAIN))
 		return -EAGAIN;
 
-	pr_warn("couldn't split");
+	pr_warn("couldn't split\n");
 	return -ENOMEM;
 }
 
@@ -2251,7 +2251,7 @@ int bch_btree_insert(struct cache_set *c, struct keylist *keys,
 	if (ret) {
 		struct bkey *k;
 
-		pr_err("error %i", ret);
+		pr_err("error %i\n", ret);
 
 		while ((k = bch_keylist_pop(keys)))
 			bkey_put(c, k);
@@ -2535,7 +2535,7 @@ struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
 			break;
 
 		if (bkey_cmp(&buf->last_scanned, end) >= 0) {
-			pr_debug("scan finished");
+			pr_debug("scan finished\n");
 			break;
 		}
 
drivers/md/bcache/io.c +1 -1
index 9056632..2e5b388 100644
@@ -332,7 +332,7 @@ void bch_count_io_errors(struct cache *ca, int error, const char *m)
 		errors >>= IO_ERROR_SHIFT;
 
 		if (errors < ca->set->error_limit)
-			pr_err("%s: IO error on %s, recovering",
+			pr_err("%s: IO error on %s, recovering\n",
 			       bdevname(ca->bdev, buf), m);
 		else
 			bch_cache_set_error(ca->set,
drivers/md/bcache/journal.c +7 -7
index 41d0b6a..9f7614f 100644
@@ -44,7 +44,7 @@ static int journal_read_bucket(struct cache *ca, struct list_head *list,
 
 	closure_init_stack(&cl);
 
-	pr_debug("reading %llu", (uint64_t) bucket);
+	pr_debug("reading %llu\n", (uint64_t) bucket);
 
 	while (offset < ca->sb.bucket_size) {
 reread:		left = ca->sb.bucket_size - offset;
@@ -152,7 +152,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
 		uint64_t seq;
 
 		bitmap_zero(bitmap, SB_JOURNAL_BUCKETS);
-		pr_debug("%u journal buckets", ca->sb.njournal_buckets);
+		pr_debug("%u journal buckets\n", ca->sb.njournal_buckets);
 
 		/*
 		 * Read journal buckets ordered by golden ratio hash to quickly
@@ -172,7 +172,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
 		 * If that fails, check all the buckets we haven't checked
 		 * already
 		 */
-		pr_debug("falling back to linear search");
+		pr_debug("falling back to linear search\n");
 
 		for (l = find_first_zero_bit(bitmap, ca->sb.njournal_buckets);
 		     l < ca->sb.njournal_buckets;
@@ -185,7 +185,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
 bsearch:
 		/* Binary search */
 		m = r = find_next_bit(bitmap, ca->sb.njournal_buckets, l + 1);
-		pr_debug("starting binary search, l %u r %u", l, r);
+		pr_debug("starting binary search, l %u r %u\n", l, r);
 
 		while (l + 1 < r) {
 			seq = list_entry(list->prev, struct journal_replay,
@@ -205,7 +205,7 @@ bsearch:
 		 * Read buckets in reverse order until we stop finding more
 		 * journal entries
 		 */
-		pr_debug("finishing up: m %u njournal_buckets %u",
+		pr_debug("finishing up: m %u njournal_buckets %u\n",
 			 m, ca->sb.njournal_buckets);
 		l = m;
 
@@ -336,7 +336,7 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
 		entries++;
 	}
 
-	pr_info("journal replay done, %i keys in %i entries, seq %llu",
+	pr_info("journal replay done, %i keys in %i entries, seq %llu\n",
 		keys, entries, end);
 err:
 	while (!list_empty(list)) {
@@ -531,7 +531,7 @@ void bch_journal_next(struct journal *j)
 	j->cur->data->keys	= 0;
 
 	if (fifo_full(&j->pin))
-		pr_debug("journal_pin full (%zu)", fifo_used(&j->pin));
+		pr_debug("journal_pin full (%zu)\n", fifo_used(&j->pin));
 }
 
 static void journal_write_endio(struct bio *bio, int error)
drivers/md/bcache/movinggc.c +1 -1
index db72d65..fb8ca5f 100644
@@ -228,7 +228,7 @@ void bch_moving_gc(struct cache_set *c)
 
 		ca->gc_move_threshold = bucket_heap_top(ca);
 
-		pr_debug("threshold %u", ca->gc_move_threshold);
+		pr_debug("threshold %u\n", ca->gc_move_threshold);
 	}
 
 	mutex_unlock(&c->bucket_lock);
drivers/md/bcache/request.c +2 -2
index 49ee1cf..0c24b9d 100644
@@ -260,7 +260,7 @@ static void bch_data_invalidate(struct closure *cl)
 	struct data_insert_op *op = container_of(cl, struct data_insert_op, cl);
 	struct bio *bio = op->bio;
 
-	pr_debug("invalidating %i sectors from %llu",
+	pr_debug("invalidating %i sectors from %llu\n",
 		 bio_sectors(bio), (uint64_t) bio->bi_sector);
 
 	while (bio_sectors(bio)) {
@@ -524,7 +524,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
 
 	if (bio->bi_sector & (c->sb.block_size - 1) ||
 	    bio_sectors(bio) & (c->sb.block_size - 1)) {
-		pr_debug("skipping unaligned io");
+		pr_debug("skipping unaligned io\n");
 		goto skip;
 	}
 
drivers/md/bcache/super.c +37 -34

239 lines not on this page · raw message

drivers/md/bcache/sysfs.c +1 -1
index 80d4c2b..c2fa7a8 100644
@@ -265,7 +265,7 @@ STORE(__cached_dev)
 				return size;
 		}
 
-		pr_err("Can't attach %s: cache set not found", buf);
+		pr_err("Can't attach %s: cache set not found\n", buf);
 		size = v;
 	}