diff options
author | 2024-01-05 11:58:50 -0500 | |
---|---|---|
committer | 2024-01-05 23:24:21 -0500 | |
commit | 1f5af5fc178588ff1f1293b5ddadd4228ce5095e (patch) | |
tree | 7d216adaf1195331ec45469c20c6d916a8492091 | |
parent | bcachefs: Improve would_deadlock trace event (diff) | |
download | linux-1f5af5fc178588ff1f1293b5ddadd4228ce5095e.tar.gz linux-1f5af5fc178588ff1f1293b5ddadd4228ce5095e.tar.bz2 linux-1f5af5fc178588ff1f1293b5ddadd4228ce5095e.zip |
bcachefs: %pg is banished
not portable to userspace
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/disk_groups.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/super-io.c | 8 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 49 | ||||
-rw-r--r-- | fs/bcachefs/util.h | 9 |
4 files changed, 52 insertions, 16 deletions
diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c index 1cd6ba8d0cce..06a7df529b40 100644 --- a/fs/bcachefs/disk_groups.c +++ b/fs/bcachefs/disk_groups.c @@ -557,7 +557,7 @@ void bch2_target_to_text(struct printbuf *out, struct bch_fs *c, unsigned v) : NULL; if (ca && percpu_ref_tryget(&ca->io_ref)) { - prt_printf(out, "/dev/%pg", ca->disk_sb.bdev); + prt_printf(out, "/dev/%s", ca->name); percpu_ref_put(&ca->io_ref); } else if (ca) { prt_printf(out, "offline device %u", t.dev); diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index 427426bb326c..042e08a92d4b 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -170,8 +170,12 @@ int bch2_sb_realloc(struct bch_sb_handle *sb, unsigned u64s) u64 max_bytes = 512 << sb->sb->layout.sb_max_size_bits; if (new_bytes > max_bytes) { - pr_err("%pg: superblock too big: want %zu but have %llu", - sb->bdev, new_bytes, max_bytes); + struct printbuf buf = PRINTBUF; + + prt_bdevname(&buf, sb->bdev); + prt_printf(&buf, ": superblock too big: want %zu but have %llu", new_bytes, max_bytes); + pr_err("%s", buf.buf); + printbuf_exit(&buf); return -BCH_ERR_ENOSPC_sb; } } diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 84798059bc21..9dbc35940197 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1083,17 +1083,22 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs, fs->sb->write_time != sb->sb->write_time) { struct printbuf buf = PRINTBUF; - prt_printf(&buf, "Split brain detected between %pg and %pg:", - sb->bdev, fs->bdev); + prt_str(&buf, "Split brain detected between "); + prt_bdevname(&buf, sb->bdev); + prt_str(&buf, " and "); + prt_bdevname(&buf, fs->bdev); + prt_char(&buf, ':'); prt_newline(&buf); prt_printf(&buf, "seq=%llu but write_time different, got", le64_to_cpu(sb->sb->seq)); prt_newline(&buf); - prt_printf(&buf, "%pg ", fs->bdev); + prt_bdevname(&buf, fs->bdev); + prt_char(&buf, ' '); bch2_prt_datetime(&buf, le64_to_cpu(fs->sb->write_time));; prt_newline(&buf); - prt_printf(&buf, "%pg ", sb->bdev); + prt_bdevname(&buf, sb->bdev); + prt_char(&buf, ' '); bch2_prt_datetime(&buf, le64_to_cpu(sb->sb->write_time));; prt_newline(&buf); @@ -1109,13 +1114,26 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs, u64 seq_from_member = le64_to_cpu(sb->sb->seq); if (seq_from_fs && seq_from_fs < seq_from_member) { - pr_err("Split brain detected between %pg and %pg:\n" - "%pg believes seq of %pg to be %llu, but %pg has %llu\n" - "Not using %pg", - sb->bdev, fs->bdev, - fs->bdev, sb->bdev, seq_from_fs, - sb->bdev, seq_from_member, - sb->bdev); + struct printbuf buf = PRINTBUF; + + prt_str(&buf, "Split brain detected between "); + prt_bdevname(&buf, sb->bdev); + prt_str(&buf, " and "); + prt_bdevname(&buf, fs->bdev); + prt_char(&buf, ':'); + prt_newline(&buf); + + prt_bdevname(&buf, fs->bdev); + prt_str(&buf, "believes seq of "); + prt_bdevname(&buf, sb->bdev); + prt_printf(&buf, " to be %llu, but ", seq_from_fs); + prt_bdevname(&buf, sb->bdev); + prt_printf(&buf, " has %llu\n", seq_from_member); + prt_str(&buf, "Not using "); + prt_bdevname(&buf, sb->bdev); + + pr_err("%s", buf.buf); + printbuf_exit(&buf); return -BCH_ERR_device_splitbrain; } @@ -1364,9 +1382,14 @@ static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb) bch2_dev_sysfs_online(c, ca); + struct printbuf name = PRINTBUF; + prt_bdevname(&name, ca->disk_sb.bdev); + if (c->sb.nr_devices == 1) - snprintf(c->name, sizeof(c->name), "%pg", ca->disk_sb.bdev); - snprintf(ca->name, sizeof(ca->name), "%pg", ca->disk_sb.bdev); + strlcpy(c->name, name.buf, sizeof(c->name)); + strlcpy(ca->name, name.buf, sizeof(ca->name)); + + printbuf_exit(&name); rebalance_wakeup(c); return 0; diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 92acda29b581..c75fc31915d3 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -351,6 +351,15 @@ int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *, unsigned); void bch2_prt_backtrace(struct printbuf *, bch_stacktrace *); int bch2_prt_task_backtrace(struct printbuf *, struct task_struct *, unsigned); +static inline void prt_bdevname(struct printbuf *out, struct block_device *bdev) +{ +#ifdef __KERNEL__ + prt_printf(out, "%pg", bdev); +#else + prt_str(out, bdev->name); +#endif +} + #define NR_QUANTILES 15 #define QUANTILE_IDX(i) inorder_to_eytzinger0(i, NR_QUANTILES) #define QUANTILE_FIRST eytzinger0_first(NR_QUANTILES) |