Skip to content

Commit 46f5aa8

Browse files
JoePerchesaxboe
authored andcommitted
bcache: Convert pr_<level> uses to a more typical style
Remove the trailing newline from the define of pr_fmt and add newlines to the uses. Miscellanea: o Convert bch_bkey_dump from multiple uses of pr_err to pr_cont as the earlier conversion was inappropriate done causing multiple lines to be emitted where only a single output line was desired o Use vsprintf extension %pV in bch_cache_set_error to avoid multiple line output where only a single line output was desired o Coalesce formats Fixes: 6ae63e3 ("bcache: replace printk() by pr_*() routines") Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Coly Li <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 3b5b7b1 commit 46f5aa8

File tree

10 files changed

+110
-109
lines changed

10 files changed

+110
-109
lines changed

drivers/md/bcache/bcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
* - updates to non leaf nodes just happen synchronously (see btree_split()).
177177
*/
178178

179-
#define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__
179+
#define pr_fmt(fmt) "bcache: %s() " fmt, __func__
180180

181181
#include <linux/bcache.h>
182182
#include <linux/bio.h>

drivers/md/bcache/bset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright 2012 Google, Inc.
77
*/
88

9-
#define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__
9+
#define pr_fmt(fmt) "bcache: %s() " fmt, __func__
1010

1111
#include "util.h"
1212
#include "bset.h"
@@ -31,7 +31,7 @@ void bch_dump_bset(struct btree_keys *b, struct bset *i, unsigned int set)
3131
if (b->ops->key_dump)
3232
b->ops->key_dump(b, k);
3333
else
34-
pr_err("%llu:%llu\n", KEY_INODE(k), KEY_OFFSET(k));
34+
pr_cont("%llu:%llu\n", KEY_INODE(k), KEY_OFFSET(k));
3535

3636
if (next < bset_bkey_last(i) &&
3737
bkey_cmp(k, b->ops->is_extents ?
@@ -1225,7 +1225,7 @@ static void btree_mergesort(struct btree_keys *b, struct bset *out,
12251225

12261226
out->keys = last ? (uint64_t *) bkey_next(last) - out->d : 0;
12271227

1228-
pr_debug("sorted %i keys", out->keys);
1228+
pr_debug("sorted %i keys\n", out->keys);
12291229
}
12301230

12311231
static void __btree_sort(struct btree_keys *b, struct btree_iter *iter,

drivers/md/bcache/btree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ static int mca_reap(struct btree *b, unsigned int min_order, bool flush)
619619
* and BTREE_NODE_journal_flush bit cleared by btree_flush_write().
620620
*/
621621
if (btree_node_journal_flush(b)) {
622-
pr_debug("bnode %p is flushing by journal, retry", b);
622+
pr_debug("bnode %p is flushing by journal, retry\n", b);
623623
mutex_unlock(&b->write_lock);
624624
udelay(1);
625625
goto retry;
@@ -802,7 +802,7 @@ int bch_btree_cache_alloc(struct cache_set *c)
802802
c->shrink.batch = c->btree_pages * 2;
803803

804804
if (register_shrinker(&c->shrink))
805-
pr_warn("bcache: %s: could not register shrinker",
805+
pr_warn("bcache: %s: could not register shrinker\n",
806806
__func__);
807807

808808
return 0;
@@ -1054,7 +1054,7 @@ static void btree_node_free(struct btree *b)
10541054
*/
10551055
if (btree_node_journal_flush(b)) {
10561056
mutex_unlock(&b->write_lock);
1057-
pr_debug("bnode %p journal_flush set, retry", b);
1057+
pr_debug("bnode %p journal_flush set, retry\n", b);
10581058
udelay(1);
10591059
goto retry;
10601060
}
@@ -1798,7 +1798,7 @@ static void bch_btree_gc(struct cache_set *c)
17981798
schedule_timeout_interruptible(msecs_to_jiffies
17991799
(GC_SLEEP_MS));
18001800
else if (ret)
1801-
pr_warn("gc failed!");
1801+
pr_warn("gc failed!\n");
18021802
} while (ret && !test_bit(CACHE_SET_IO_DISABLE, &c->flags));
18031803

18041804
bch_btree_gc_finish(c);
@@ -2043,7 +2043,7 @@ int bch_btree_check(struct cache_set *c)
20432043
&check_state->infos[i],
20442044
name);
20452045
if (IS_ERR(check_state->infos[i].thread)) {
2046-
pr_err("fails to run thread bch_btrchk[%d]", i);
2046+
pr_err("fails to run thread bch_btrchk[%d]\n", i);
20472047
for (--i; i >= 0; i--)
20482048
kthread_stop(check_state->infos[i].thread);
20492049
ret = -ENOMEM;
@@ -2454,7 +2454,7 @@ int bch_btree_insert(struct cache_set *c, struct keylist *keys,
24542454
if (ret) {
24552455
struct bkey *k;
24562456

2457-
pr_err("error %i", ret);
2457+
pr_err("error %i\n", ret);
24582458

24592459
while ((k = bch_keylist_pop(keys)))
24602460
bkey_put(c, k);
@@ -2742,7 +2742,7 @@ struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
27422742
break;
27432743

27442744
if (bkey_cmp(&buf->last_scanned, end) >= 0) {
2745-
pr_debug("scan finished");
2745+
pr_debug("scan finished\n");
27462746
break;
27472747
}
27482748

drivers/md/bcache/extents.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,18 @@ static void bch_bkey_dump(struct btree_keys *keys, const struct bkey *k)
130130
char buf[80];
131131

132132
bch_extent_to_text(buf, sizeof(buf), k);
133-
pr_err(" %s", buf);
133+
pr_cont(" %s", buf);
134134

135135
for (j = 0; j < KEY_PTRS(k); j++) {
136136
size_t n = PTR_BUCKET_NR(b->c, k, j);
137137

138-
pr_err(" bucket %zu", n);
138+
pr_cont(" bucket %zu", n);
139139
if (n >= b->c->sb.first_bucket && n < b->c->sb.nbuckets)
140-
pr_err(" prio %i",
141-
PTR_BUCKET(b->c, k, j)->prio);
140+
pr_cont(" prio %i",
141+
PTR_BUCKET(b->c, k, j)->prio);
142142
}
143143

144-
pr_err(" %s\n", bch_ptr_status(b->c, k));
144+
pr_cont(" %s\n", bch_ptr_status(b->c, k));
145145
}
146146

147147
/* Btree ptrs */
@@ -553,7 +553,7 @@ static bool bch_extent_bad(struct btree_keys *bk, const struct bkey *k)
553553

554554
if (stale && KEY_DIRTY(k)) {
555555
bch_extent_to_text(buf, sizeof(buf), k);
556-
pr_info("stale dirty pointer, stale %u, key: %s",
556+
pr_info("stale dirty pointer, stale %u, key: %s\n",
557557
stale, buf);
558558
}
559559

drivers/md/bcache/io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio)
6565
* we shouldn't count failed REQ_RAHEAD bio to dc->io_errors.
6666
*/
6767
if (bio->bi_opf & REQ_RAHEAD) {
68-
pr_warn_ratelimited("%s: Read-ahead I/O failed on backing device, ignore",
68+
pr_warn_ratelimited("%s: Read-ahead I/O failed on backing device, ignore\n",
6969
dc->backing_dev_name);
7070
return;
7171
}
7272

7373
errors = atomic_add_return(1, &dc->io_errors);
7474
if (errors < dc->error_limit)
75-
pr_err("%s: IO error on backing device, unrecoverable",
75+
pr_err("%s: IO error on backing device, unrecoverable\n",
7676
dc->backing_dev_name);
7777
else
7878
bch_cached_dev_error(dc);
@@ -123,12 +123,12 @@ void bch_count_io_errors(struct cache *ca,
123123
errors >>= IO_ERROR_SHIFT;
124124

125125
if (errors < ca->set->error_limit)
126-
pr_err("%s: IO error on %s%s",
126+
pr_err("%s: IO error on %s%s\n",
127127
ca->cache_dev_name, m,
128128
is_read ? ", recovering." : ".");
129129
else
130130
bch_cache_set_error(ca->set,
131-
"%s: too many IO errors %s",
131+
"%s: too many IO errors %s\n",
132132
ca->cache_dev_name, m);
133133
}
134134
}

drivers/md/bcache/journal.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int journal_read_bucket(struct cache *ca, struct list_head *list,
4747

4848
closure_init_stack(&cl);
4949

50-
pr_debug("reading %u", bucket_index);
50+
pr_debug("reading %u\n", bucket_index);
5151

5252
while (offset < ca->sb.bucket_size) {
5353
reread: left = ca->sb.bucket_size - offset;
@@ -78,13 +78,13 @@ reread: left = ca->sb.bucket_size - offset;
7878
size_t blocks, bytes = set_bytes(j);
7979

8080
if (j->magic != jset_magic(&ca->sb)) {
81-
pr_debug("%u: bad magic", bucket_index);
81+
pr_debug("%u: bad magic\n", bucket_index);
8282
return ret;
8383
}
8484

8585
if (bytes > left << 9 ||
8686
bytes > PAGE_SIZE << JSET_BITS) {
87-
pr_info("%u: too big, %zu bytes, offset %u",
87+
pr_info("%u: too big, %zu bytes, offset %u\n",
8888
bucket_index, bytes, offset);
8989
return ret;
9090
}
@@ -93,7 +93,7 @@ reread: left = ca->sb.bucket_size - offset;
9393
goto reread;
9494

9595
if (j->csum != csum_set(j)) {
96-
pr_info("%u: bad csum, %zu bytes, offset %u",
96+
pr_info("%u: bad csum, %zu bytes, offset %u\n",
9797
bucket_index, bytes, offset);
9898
return ret;
9999
}
@@ -190,7 +190,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
190190
uint64_t seq;
191191

192192
bitmap_zero(bitmap, SB_JOURNAL_BUCKETS);
193-
pr_debug("%u journal buckets", ca->sb.njournal_buckets);
193+
pr_debug("%u journal buckets\n", ca->sb.njournal_buckets);
194194

195195
/*
196196
* Read journal buckets ordered by golden ratio hash to quickly
@@ -215,7 +215,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
215215
* If that fails, check all the buckets we haven't checked
216216
* already
217217
*/
218-
pr_debug("falling back to linear search");
218+
pr_debug("falling back to linear search\n");
219219

220220
for (l = find_first_zero_bit(bitmap, ca->sb.njournal_buckets);
221221
l < ca->sb.njournal_buckets;
@@ -233,7 +233,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
233233
/* Binary search */
234234
m = l;
235235
r = find_next_bit(bitmap, ca->sb.njournal_buckets, l + 1);
236-
pr_debug("starting binary search, l %u r %u", l, r);
236+
pr_debug("starting binary search, l %u r %u\n", l, r);
237237

238238
while (l + 1 < r) {
239239
seq = list_entry(list->prev, struct journal_replay,
@@ -253,7 +253,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
253253
* Read buckets in reverse order until we stop finding more
254254
* journal entries
255255
*/
256-
pr_debug("finishing up: m %u njournal_buckets %u",
256+
pr_debug("finishing up: m %u njournal_buckets %u\n",
257257
m, ca->sb.njournal_buckets);
258258
l = m;
259259

@@ -370,10 +370,10 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
370370

371371
if (n != i->j.seq) {
372372
if (n == start && is_discard_enabled(s))
373-
pr_info("bcache: journal entries %llu-%llu may be discarded! (replaying %llu-%llu)",
373+
pr_info("journal entries %llu-%llu may be discarded! (replaying %llu-%llu)\n",
374374
n, i->j.seq - 1, start, end);
375375
else {
376-
pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
376+
pr_err("journal entries %llu-%llu missing! (replaying %llu-%llu)\n",
377377
n, i->j.seq - 1, start, end);
378378
ret = -EIO;
379379
goto err;
@@ -403,7 +403,7 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
403403
entries++;
404404
}
405405

406-
pr_info("journal replay done, %i keys in %i entries, seq %llu",
406+
pr_info("journal replay done, %i keys in %i entries, seq %llu\n",
407407
keys, entries, end);
408408
err:
409409
while (!list_empty(list)) {
@@ -481,7 +481,7 @@ static void btree_flush_write(struct cache_set *c)
481481
break;
482482

483483
if (btree_node_journal_flush(b))
484-
pr_err("BUG: flush_write bit should not be set here!");
484+
pr_err("BUG: flush_write bit should not be set here!\n");
485485

486486
mutex_lock(&b->write_lock);
487487

@@ -534,28 +534,28 @@ static void btree_flush_write(struct cache_set *c)
534534
for (i = 0; i < nr; i++) {
535535
b = btree_nodes[i];
536536
if (!b) {
537-
pr_err("BUG: btree_nodes[%d] is NULL", i);
537+
pr_err("BUG: btree_nodes[%d] is NULL\n", i);
538538
continue;
539539
}
540540

541541
/* safe to check without holding b->write_lock */
542542
if (!btree_node_journal_flush(b)) {
543-
pr_err("BUG: bnode %p: journal_flush bit cleaned", b);
543+
pr_err("BUG: bnode %p: journal_flush bit cleaned\n", b);
544544
continue;
545545
}
546546

547547
mutex_lock(&b->write_lock);
548548
if (!btree_current_write(b)->journal) {
549549
clear_bit(BTREE_NODE_journal_flush, &b->flags);
550550
mutex_unlock(&b->write_lock);
551-
pr_debug("bnode %p: written by others", b);
551+
pr_debug("bnode %p: written by others\n", b);
552552
continue;
553553
}
554554

555555
if (!btree_node_dirty(b)) {
556556
clear_bit(BTREE_NODE_journal_flush, &b->flags);
557557
mutex_unlock(&b->write_lock);
558-
pr_debug("bnode %p: dirty bit cleaned by others", b);
558+
pr_debug("bnode %p: dirty bit cleaned by others\n", b);
559559
continue;
560560
}
561561

@@ -716,7 +716,7 @@ void bch_journal_next(struct journal *j)
716716
j->cur->data->keys = 0;
717717

718718
if (fifo_full(&j->pin))
719-
pr_debug("journal_pin full (%zu)", fifo_used(&j->pin));
719+
pr_debug("journal_pin full (%zu)\n", fifo_used(&j->pin));
720720
}
721721

722722
static void journal_write_endio(struct bio *bio)

drivers/md/bcache/request.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void bch_data_invalidate(struct closure *cl)
110110
struct data_insert_op *op = container_of(cl, struct data_insert_op, cl);
111111
struct bio *bio = op->bio;
112112

113-
pr_debug("invalidating %i sectors from %llu",
113+
pr_debug("invalidating %i sectors from %llu\n",
114114
bio_sectors(bio), (uint64_t) bio->bi_iter.bi_sector);
115115

116116
while (bio_sectors(bio)) {
@@ -396,7 +396,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
396396

397397
if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) ||
398398
bio_sectors(bio) & (c->sb.block_size - 1)) {
399-
pr_debug("skipping unaligned io");
399+
pr_debug("skipping unaligned io\n");
400400
goto skip;
401401
}
402402

@@ -650,7 +650,7 @@ static void backing_request_endio(struct bio *bio)
650650
*/
651651
if (unlikely(s->iop.writeback &&
652652
bio->bi_opf & REQ_PREFLUSH)) {
653-
pr_err("Can't flush %s: returned bi_status %i",
653+
pr_err("Can't flush %s: returned bi_status %i\n",
654654
dc->backing_dev_name, bio->bi_status);
655655
} else {
656656
/* set to orig_bio->bi_status in bio_complete() */

0 commit comments

Comments
 (0)