linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] reduce stack footprint printing bdev names
@ 2021-06-02 15:28 Anton Suvorov
  2021-06-02 15:28 ` [PATCH 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
                   ` (9 more replies)
  0 siblings, 10 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Dmitry Monakhov <dmtrmonakhov@yandex-team.ru> started "kernel newbies"
initiative at Yandex allowing developers unfamiliar with kernel
development process to join kernel development. Initiative includes easy
to fix bugs and some small improvments. This patchset was tailored as part
of the initiative.

Few years ago Dmitry Monakhov introduced %pg formatter for vsprintf()
(https://lore.kernel.org/lkml/1428928300-9132-1-git-send-email-dmonakhov@openvz.org/)
and switched some hot code paths to it instead of allocating temporary
buffer for device name on stack. This patchset continues his work and
expands to most places where temporary buffer with BDEVNAME_SIZE size
allocated on stack. There are also some changes in printk() calls
advised by checkpatch.pl script.


The patchset shows significant reduce of stack footprint:

	./block/blk-core.c	submit_bio_checks	248	112	-136
	./block/blk-lib.c	__blkdev_issue_discard	240	104	-136
	./block/blk-settings.c	disk_stack_limits	256	192	-64
	./block/partitions/amiga.c	amiga_partition	424	368	-56
	./block/partitions/sgi.c	sgi_partition	352	288	-64
	./block/partitions/sun.c	sun_partition	392	328	-64
	./drivers/block/drbd/drbd_req.c	drbd_report_io_error	200	72	-128
	./drivers/block/pktcdvd.c	pkt_seq_show	288	224	-64
	./drivers/block/pktcdvd.c	pkt_setup_dev	272	136	-136
	./drivers/block/pktcdvd.c	pkt_submit_bio	288	224	-64
	./drivers/dax/super.c	__bdev_dax_supported	192	56	-136
	./drivers/dax/super.c	__generic_fsdax_supported	344	280	-64
	./drivers/md/dm-cache-target.c	cache_ctr	392	328	-64
	./drivers/md/dm-cache-target.c	cache_io_hints	208	72	-136
	./drivers/md/dm-clone-target.c	clone_ctr	416	352	-64
	./drivers/md/dm-clone-target.c	clone_io_hints	216	80	-136
	./drivers/md/dm-crypt.c	crypt_convert_block_aead	408	272	-136
	./drivers/md/dm-crypt.c	kcryptd_async_done	192	56	-136
	./drivers/md/dm-integrity.c	integrity_metadata	872	808	-64
	./drivers/md/dm-mpath.c	parse_priority_group	368	304	-64
	./drivers/md/dm-table.c	device_area_is_invalid	216	80	-136
	./drivers/md/dm-table.c	dm_set_device_limits	200	72	-128
	./drivers/md/dm-thin.c	pool_io_hints	216	80	-136
	./drivers/md/md-linear.c	linear_make_request	248	112	-136
	./drivers/md/md-multipath.c	multipath_end_request	232	96	-136
	./drivers/md/md-multipath.c	multipath_error	208	72	-136
	./drivers/md/md-multipath.c	multipathd	248	112	-136
	./drivers/md/md-multipath.c	print_multipath_conf	208	64	-144
	./drivers/md/md.c	autorun_devices	312	184	-128
	./drivers/md/md.c	export_rdev	168	32	-136
	./drivers/md/md.c	md_add_new_disk	280	80	-200
	./drivers/md/md.c	md_import_device	200	56	-144
	./drivers/md/md.c	md_integrity_add_rdev	192	56	-136
	./drivers/md/md.c	md_ioctl	560	496	-64
	./drivers/md/md.c	md_reload_sb	224	88	-136
	./drivers/md/md.c	md_run	408	288	-120
	./drivers/md/md.c	md_seq_show	232	96	-136
	./drivers/md/md.c	md_update_sb	304	168	-136
	./drivers/md/md.c	read_disk_sb	184	48	-136
	./drivers/md/md.c	super_1_load	392	192	-200
	./drivers/md/md.c	super_90_load	304	112	-192
	./drivers/md/md.c	unbind_rdev_from_array	200	64	-136
	./drivers/md/raid0.c	create_strip_zones	400	200	-200
	./drivers/md/raid0.c	dump_zones	536	464	-72
	./drivers/md/raid1.c	fix_read_error	352	288	-64
	./drivers/md/raid1.c	print_conf	224	80	-144
	./drivers/md/raid1.c	raid1_end_read_request	216	80	-136
	./drivers/md/raid1.c	raid1_error	216	96	-120
	./drivers/md/raid1.c	sync_request_write	344	208	-136
	./drivers/md/raid10.c	fix_read_error	392	320	-72
	./drivers/md/raid10.c	print_conf	216	72	-144
	./drivers/md/raid10.c	raid10_end_read_request	216	80	-136
	./drivers/md/raid10.c	raid10_error	216	80	-136
	./drivers/md/raid5-cache.c	r5l_init_log	224	88	-136
	./drivers/md/raid5-ppl.c	ppl_do_flush	256	136	-120
	./drivers/md/raid5-ppl.c	ppl_flush_endio	192	56	-136
	./drivers/md/raid5-ppl.c	ppl_modify_log	192	56	-136
	./drivers/md/raid5-ppl.c	ppl_recover_entry	1296	1232	-64
	./drivers/md/raid5-ppl.c	ppl_submit_iounit_bio	192	56	-136
	./drivers/md/raid5-ppl.c	ppl_validate_rdev	184	48	-136
	./drivers/md/raid5.c	print_raid5_conf	208	64	-144
	./drivers/md/raid5.c	raid5_end_read_request	272	128	-144
	./drivers/md/raid5.c	raid5_error	216	80	-136
	./drivers/md/raid5.c	setup_conf	360	296	-64
	./drivers/target/target_core_iblock.c	iblock_show_configfs_dev_params	192	56	-136
	./fs/block_dev.c	__blkdev_put	224	80	-144
	./fs/ext4/page-io.c	ext4_end_bio	224	88	-136
	./security/loadpin/loadpin.c	loadpin_read_file	200	56	-144

Patchset was tested with kvm-xfstests -c 4k full using 
https://github.com/tytso/xfstests-bld/blob/master/kernel-configs/x86_64-config-5.10
kernel config:
	-------------------- Summary report
	KERNEL:    kernel 5.13.0-rc4-next-20210601-xfstests-00001-gf10818e9d103 #8 SMP Tue Jun 1 19:52:19 MSK 2021 x86_64
	CMDLINE:   -c 4k full
	CPUS:      2
	MEM:       1961.41
	
	ext4/4k: 537 tests, 45 skipped, 5331 seconds
	Totals: 492 tests, 45 skipped, 0 failures, 0 errors, 5281s
	
	FSTESTVER: blktests 4bc88ef (Sun, 7 Mar 2021 12:38:37 -0800)
	FSTESTVER: fio  fio-3.26 (Mon, 8 Mar 2021 17:44:38 -0700)
	FSTESTVER: fsverity v1.3-2-gcf8fa5e (Wed, 24 Feb 2021 13:32:36 -0800)
	FSTESTVER: ima-evm-utils v1.3.2 (Wed, 28 Oct 2020 13:18:08 -0400)
	FSTESTVER: nvme-cli v1.13 (Tue, 20 Oct 2020 16:50:31 -0700)
	FSTESTVER: quota  v4.05-40-g25f16b1 (Tue, 16 Mar 2021 17:57:19 +0100)
	FSTESTVER: util-linux v2.36.2 (Fri, 12 Feb 2021 14:59:56 +0100)
	FSTESTVER: xfsprogs v5.11.0 (Fri, 12 Mar 2021 15:05:13 -0500)
	FSTESTVER: xfstests linux-v3.8-3068-g4072b9d3 (Mon, 5 Apr 2021 15:44:33 -0400)
	FSTESTVER: xfstests-bld 4ec07f9 (Mon, 12 Apr 2021 23:49:18 -0400)
	FSTESTCFG: 4k
	FSTESTSET: -g auto
	FSTESTOPT: aex

Anton Suvorov (10):
  drbd: reduce stack footprint in drbd_report_io_error()
  dax: reduce stack footprint dealing with block device names
  raid-md: reduce stack footprint dealing with block device names
  dm: reduce stack footprint dealing with block device names
  block: reduce stack footprint dealing with block device names
  target: reduce stack footprint in iblock_show_configfs_dev_params()
  vfs: reduce stack footprint in __blkdev_put()
  ext4: reduce stack footprint in ext4_end_bio()
  security: reduce stack footprint in loadpin_read_file()
  block: remove unused symbol bio_devname()

 block/bio.c                         |   6 --
 block/blk-core.c                    |  12 +--
 block/blk-lib.c                     |   5 +-
 block/blk-settings.c                |   7 +-
 block/partitions/amiga.c            |  13 ++-
 block/partitions/sgi.c              |   5 +-
 block/partitions/sun.c              |   5 +-
 drivers/block/drbd/drbd_req.c       |  12 +--
 drivers/block/pktcdvd.c             |  15 ++-
 drivers/dax/super.c                 |  34 +++----
 drivers/md/dm-cache-target.c        |  10 +-
 drivers/md/dm-clone-target.c        |  10 +-
 drivers/md/dm-crypt.c               |   6 +-
 drivers/md/dm-integrity.c           |   4 +-
 drivers/md/dm-mpath.c               |   6 +-
 drivers/md/dm-table.c               |  34 +++----
 drivers/md/dm-thin.c                |   8 +-
 drivers/md/md-linear.c              |   5 +-
 drivers/md/md-multipath.c           |  24 ++---
 drivers/md/md.c                     | 146 ++++++++++++----------------
 drivers/md/raid0.c                  |  28 +++---
 drivers/md/raid1.c                  |  25 ++---
 drivers/md/raid10.c                 |  66 +++++--------
 drivers/md/raid5-cache.c            |   5 +-
 drivers/md/raid5-ppl.c              |  41 ++++----
 drivers/md/raid5.c                  |  39 ++++----
 drivers/target/target_core_iblock.c |   5 +-
 fs/block_dev.c                      |   6 +-
 fs/ext4/page-io.c                   |   5 +-
 include/linux/bio.h                 |   2 -
 security/loadpin/loadpin.c          |   5 +-
 31 files changed, 242 insertions(+), 352 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 01/10] drbd: reduce stack footprint in drbd_report_io_error()
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
@ 2021-06-02 15:28 ` Anton Suvorov
  2021-06-02 15:28 ` [PATCH 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./drivers/block/drbd/drbd_req.c drbd_report_io_error    200     72      -128

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/block/drbd/drbd_req.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 13beb98a7c5a..bd7265edf614 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -510,16 +510,14 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
 
 static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req)
 {
-        char b[BDEVNAME_SIZE];
-
 	if (!__ratelimit(&drbd_ratelimit_state))
 		return;
 
-	drbd_warn(device, "local %s IO error sector %llu+%u on %s\n",
-			(req->rq_state & RQ_WRITE) ? "WRITE" : "READ",
-			(unsigned long long)req->i.sector,
-			req->i.size >> 9,
-			bdevname(device->ldev->backing_bdev, b));
+	drbd_warn(device, "local %s IO error sector %llu+%u on %pg\n",
+		  (req->rq_state & RQ_WRITE) ? "WRITE" : "READ",
+		  (unsigned long long)req->i.sector,
+		  req->i.size >> 9,
+		  device->ldev->backing_bdev);
 }
 
 /* Helper for HANDED_OVER_TO_NETWORK.
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 02/10] dax: reduce stack footprint dealing with block device names
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
  2021-06-02 15:28 ` [PATCH 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
@ 2021-06-02 15:28 ` Anton Suvorov
  2021-06-02 17:18   ` Matthew Wilcox
  2021-06-02 15:28 ` [PATCH 03/10] raid-md: reduce stack footprint dealing with block device names Anton Suvorov
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./drivers/dax/super.c   __bdev_dax_supported    192     56      -136
./drivers/dax/super.c   __generic_fsdax_supported       344     280     -64

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/dax/super.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 5fa6ae9dbc8b..f694e25fe6af 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -73,7 +73,6 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 {
 	bool dax_enabled = false;
 	pgoff_t pgoff, pgoff_end;
-	char buf[BDEVNAME_SIZE];
 	void *kaddr, *end_kaddr;
 	pfn_t pfn, end_pfn;
 	sector_t last_page;
@@ -81,29 +80,29 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 	int err, id;
 
 	if (blocksize != PAGE_SIZE) {
-		pr_info("%s: error: unsupported blocksize for dax\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: unsupported blocksize for dax\n",
+			bdev);
 		return false;
 	}
 
 	if (!dax_dev) {
-		pr_debug("%s: error: dax unsupported by block device\n",
-				bdevname(bdev, buf));
+		pr_debug("%pg: error: dax unsupported by block device\n",
+			 bdev);
 		return false;
 	}
 
 	err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff);
 	if (err) {
-		pr_info("%s: error: unaligned partition for dax\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: unaligned partition for dax\n",
+			bdev);
 		return false;
 	}
 
 	last_page = PFN_DOWN((start + sectors - 1) * 512) * PAGE_SIZE / 512;
 	err = bdev_dax_pgoff(bdev, last_page, PAGE_SIZE, &pgoff_end);
 	if (err) {
-		pr_info("%s: error: unaligned partition for dax\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: unaligned partition for dax\n",
+			bdev);
 		return false;
 	}
 
@@ -112,8 +111,8 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 	len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn);
 
 	if (len < 1 || len2 < 1) {
-		pr_info("%s: error: dax access failed (%ld)\n",
-				bdevname(bdev, buf), len < 1 ? len : len2);
+		pr_info("%pg: error: dax access failed (%ld)\n",
+			bdev, len < 1 ? len : len2);
 		dax_read_unlock(id);
 		return false;
 	}
@@ -147,8 +146,8 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 	dax_read_unlock(id);
 
 	if (!dax_enabled) {
-		pr_info("%s: error: dax support not enabled\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: dax support not enabled\n",
+			bdev);
 		return false;
 	}
 	return true;
@@ -169,21 +168,20 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
 {
 	struct dax_device *dax_dev;
 	struct request_queue *q;
-	char buf[BDEVNAME_SIZE];
 	bool ret;
 	int id;
 
 	q = bdev_get_queue(bdev);
 	if (!q || !blk_queue_dax(q)) {
-		pr_debug("%s: error: request queue doesn't support dax\n",
-				bdevname(bdev, buf));
+		pr_debug("%pg: error: request queue doesn't support dax\n",
+			 bdev);
 		return false;
 	}
 
 	dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
 	if (!dax_dev) {
-		pr_debug("%s: error: device does not support dax\n",
-				bdevname(bdev, buf));
+		pr_debug("%pg: error: device does not support dax\n",
+			 bdev);
 		return false;
 	}
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 03/10] raid-md: reduce stack footprint dealing with block device names
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
  2021-06-02 15:28 ` [PATCH 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
  2021-06-02 15:28 ` [PATCH 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
@ 2021-06-02 15:28 ` Anton Suvorov
  2021-06-02 15:28 ` [PATCH 04/10] dm: " Anton Suvorov
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./drivers/md/md-linear.c	linear_make_request	248	112	-136
./drivers/md/md-multipath.c	multipath_end_request	232	96	-136
./drivers/md/md-multipath.c	multipath_error	208	72	-136
./drivers/md/md-multipath.c	multipathd	248	112	-136
./drivers/md/md-multipath.c	print_multipath_conf	208	64	-144
./drivers/md/md.c	autorun_devices	312	184	-128
./drivers/md/md.c	export_rdev	168	32	-136
./drivers/md/md.c	md_add_new_disk	280	80	-200
./drivers/md/md.c	md_import_device	200	56	-144
./drivers/md/md.c	md_integrity_add_rdev	192	56	-136
./drivers/md/md.c	md_ioctl	560	496	-64
./drivers/md/md.c	md_reload_sb	224	88	-136
./drivers/md/md.c	md_run	408	288	-120
./drivers/md/md.c	md_seq_show	232	96	-136
./drivers/md/md.c	md_update_sb	304	168	-136
./drivers/md/md.c	read_disk_sb	184	48	-136
./drivers/md/md.c	super_1_load	392	192	-200
./drivers/md/md.c	super_90_load	304	112	-192
./drivers/md/md.c	unbind_rdev_from_array	200	64	-136
./drivers/md/raid0.c	create_strip_zones	400	200	-200
./drivers/md/raid0.c	dump_zones	536	464	-72
./drivers/md/raid1.c	fix_read_error	352	288	-64
./drivers/md/raid1.c	print_conf	224	80	-144
./drivers/md/raid1.c	raid1_end_read_request	216	80	-136
./drivers/md/raid1.c	raid1_error	216	96	-120
./drivers/md/raid1.c	sync_request_write	344	208	-136
./drivers/md/raid10.c	fix_read_error	392	320	-72
./drivers/md/raid10.c	print_conf	216	72	-144
./drivers/md/raid10.c	raid10_end_read_request	216	80	-136
./drivers/md/raid10.c	raid10_error	216	80	-136
./drivers/md/raid5-cache.c	r5l_init_log	224	88	-136
./drivers/md/raid5-ppl.c	ppl_do_flush	256	136	-120
./drivers/md/raid5-ppl.c	ppl_flush_endio	192	56	-136
./drivers/md/raid5-ppl.c	ppl_modify_log	192	56	-136
./drivers/md/raid5-ppl.c	ppl_recover_entry	1296	1232	-64
./drivers/md/raid5-ppl.c	ppl_submit_iounit_bio	192	56	-136
./drivers/md/raid5-ppl.c	ppl_validate_rdev	184	48	-136
./drivers/md/raid5.c	print_raid5_conf	208	64	-144
./drivers/md/raid5.c	raid5_end_read_request	272	128	-144
./drivers/md/raid5.c	raid5_error	216	80	-136
./drivers/md/raid5.c	setup_conf	360	296	-64

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/md/md-linear.c    |   5 +-
 drivers/md/md-multipath.c |  24 +++----
 drivers/md/md.c           | 146 ++++++++++++++++----------------------
 drivers/md/raid0.c        |  28 ++++----
 drivers/md/raid1.c        |  25 +++----
 drivers/md/raid10.c       |  66 +++++++----------
 drivers/md/raid5-cache.c  |   5 +-
 drivers/md/raid5-ppl.c    |  41 +++++------
 drivers/md/raid5.c        |  39 +++++-----
 9 files changed, 158 insertions(+), 221 deletions(-)

diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index 63ed8329a98d..ddd45fe4a53a 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -215,7 +215,6 @@ static void linear_free(struct mddev *mddev, void *priv)
 
 static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 {
-	char b[BDEVNAME_SIZE];
 	struct dev_info *tmp_dev;
 	sector_t start_sector, end_sector, data_offset;
 	sector_t bio_sector = bio->bi_iter.bi_sector;
@@ -266,10 +265,10 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 	return true;
 
 out_of_bounds:
-	pr_err("md/linear:%s: make_request: Sector %llu out of bounds on dev %s: %llu sectors, offset %llu\n",
+	pr_err("md/linear:%s: make_request: Sector %llu out of bounds on dev %pg: %llu sectors, offset %llu\n",
 	       mdname(mddev),
 	       (unsigned long long)bio->bi_iter.bi_sector,
-	       bdevname(tmp_dev->rdev->bdev, b),
+	       tmp_dev->rdev->bdev,
 	       (unsigned long long)tmp_dev->rdev->sectors,
 	       (unsigned long long)start_sector);
 	bio_io_error(bio);
diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c
index 776bbe542db5..cba67d983944 100644
--- a/drivers/md/md-multipath.c
+++ b/drivers/md/md-multipath.c
@@ -87,10 +87,9 @@ static void multipath_end_request(struct bio *bio)
 		/*
 		 * oops, IO error:
 		 */
-		char b[BDEVNAME_SIZE];
 		md_error (mp_bh->mddev, rdev);
-		pr_info("multipath: %s: rescheduling sector %llu\n",
-			bdevname(rdev->bdev,b),
+		pr_info("multipath: %pg: rescheduling sector %llu\n",
+			rdev->bdev,
 			(unsigned long long)bio->bi_iter.bi_sector);
 		multipath_reschedule_retry(mp_bh);
 	} else
@@ -157,7 +156,6 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
 static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
 {
 	struct mpconf *conf = mddev->private;
-	char b[BDEVNAME_SIZE];
 
 	if (conf->raid_disks - mddev->degraded <= 1) {
 		/*
@@ -180,9 +178,9 @@ static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
 	}
 	set_bit(Faulty, &rdev->flags);
 	set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
-	pr_err("multipath: IO failure on %s, disabling IO path.\n"
+	pr_err("multipath: IO failure on %pg, disabling IO path.\n"
 	       "multipath: Operation continuing on %d IO paths.\n",
-	       bdevname(rdev->bdev, b),
+	       rdev->bdev,
 	       conf->raid_disks - mddev->degraded);
 }
 
@@ -200,12 +198,11 @@ static void print_multipath_conf (struct mpconf *conf)
 		 conf->raid_disks);
 
 	for (i = 0; i < conf->raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		tmp = conf->multipaths + i;
 		if (tmp->rdev)
-			pr_debug(" disk%d, o:%d, dev:%s\n",
+			pr_debug(" disk%d, o:%d, dev:%pg\n",
 				 i,!test_bit(Faulty, &tmp->rdev->flags),
-				 bdevname(tmp->rdev->bdev,b));
+				 tmp->rdev->bdev);
 	}
 }
 
@@ -299,7 +296,6 @@ static void multipathd(struct md_thread *thread)
 
 	md_check_recovery(mddev);
 	for (;;) {
-		char b[BDEVNAME_SIZE];
 		spin_lock_irqsave(&conf->device_lock, flags);
 		if (list_empty(head))
 			break;
@@ -311,13 +307,13 @@ static void multipathd(struct md_thread *thread)
 		bio->bi_iter.bi_sector = mp_bh->master_bio->bi_iter.bi_sector;
 
 		if ((mp_bh->path = multipath_map (conf))<0) {
-			pr_err("multipath: %s: unrecoverable IO read error for block %llu\n",
-			       bio_devname(bio, b),
+			pr_err("multipath: %pg: unrecoverable IO read error for block %llu\n",
+			       bio->bi_bdev,
 			       (unsigned long long)bio->bi_iter.bi_sector);
 			multipath_end_bh_io(mp_bh, BLK_STS_IOERR);
 		} else {
-			pr_err("multipath: %s: redirecting sector %llu to another IO path\n",
-			       bio_devname(bio, b),
+			pr_err("multipath: %pg: redirecting sector %llu to another IO path\n",
+			       bio->bi_bdev,
 			       (unsigned long long)bio->bi_iter.bi_sector);
 			*bio = *(mp_bh->master_bio);
 			bio->bi_iter.bi_sector +=
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 49f897fbb89b..9d762cdad046 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1057,8 +1057,6 @@ EXPORT_SYMBOL_GPL(sync_page_io);
 
 static int read_disk_sb(struct md_rdev *rdev, int size)
 {
-	char b[BDEVNAME_SIZE];
-
 	if (rdev->sb_loaded)
 		return 0;
 
@@ -1068,8 +1066,8 @@ static int read_disk_sb(struct md_rdev *rdev, int size)
 	return 0;
 
 fail:
-	pr_err("md: disabled device %s, could not read superblock.\n",
-	       bdevname(rdev->bdev,b));
+	pr_err("md: disabled device %pg, could not read superblock.\n",
+	       rdev->bdev);
 	return -EINVAL;
 }
 
@@ -1215,7 +1213,6 @@ EXPORT_SYMBOL(md_check_no_bitmap);
  */
 static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_version)
 {
-	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 	mdp_super_t *sb;
 	int ret;
 	bool spare_disk = true;
@@ -1234,19 +1231,18 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 
 	ret = -EINVAL;
 
-	bdevname(rdev->bdev, b);
 	sb = page_address(rdev->sb_page);
 
 	if (sb->md_magic != MD_SB_MAGIC) {
-		pr_warn("md: invalid raid superblock magic on %s\n", b);
+		pr_warn("md: invalid raid superblock magic on %pg\n", rdev->bdev);
 		goto abort;
 	}
 
 	if (sb->major_version != 0 ||
 	    sb->minor_version < 90 ||
 	    sb->minor_version > 91) {
-		pr_warn("Bad version number %d.%d on %s\n",
-			sb->major_version, sb->minor_version, b);
+		pr_warn("Bad version number %d.%d on %pg\n",
+			sb->major_version, sb->minor_version, rdev->bdev);
 		goto abort;
 	}
 
@@ -1254,7 +1250,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 		goto abort;
 
 	if (md_csum_fold(calc_sb_csum(sb)) != md_csum_fold(sb->sb_csum)) {
-		pr_warn("md: invalid superblock checksum on %s\n", b);
+		pr_warn("md: invalid superblock checksum on %pg\n", rdev->bdev);
 		goto abort;
 	}
 
@@ -1286,13 +1282,13 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 		__u64 ev1, ev2;
 		mdp_super_t *refsb = page_address(refdev->sb_page);
 		if (!md_uuid_equal(refsb, sb)) {
-			pr_warn("md: %s has different UUID to %s\n",
-				b, bdevname(refdev->bdev,b2));
+			pr_warn("md: %pg has different UUID to %pg\n",
+				rdev->bdev, refdev->bdev);
 			goto abort;
 		}
 		if (!md_sb_equal(refsb, sb)) {
-			pr_warn("md: %s has same UUID but different superblock to %s\n",
-				b, bdevname(refdev->bdev, b2));
+			pr_warn("md: %pg has same UUID but different superblock to %pg\n",
+				rdev->bdev, refdev->bdev);
 			goto abort;
 		}
 		ev1 = md_event(sb);
@@ -1656,7 +1652,6 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 	int ret;
 	sector_t sb_start;
 	sector_t sectors;
-	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 	int bmask;
 	bool spare_disk = true;
 
@@ -1701,13 +1696,13 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 		return -EINVAL;
 
 	if (calc_sb_1_csum(sb) != sb->sb_csum) {
-		pr_warn("md: invalid superblock checksum on %s\n",
-			bdevname(rdev->bdev,b));
+		pr_warn("md: invalid superblock checksum on %pg\n",
+			rdev->bdev);
 		return -EINVAL;
 	}
 	if (le64_to_cpu(sb->data_size) < 10) {
-		pr_warn("md: data_size too small on %s\n",
-			bdevname(rdev->bdev,b));
+		pr_warn("md: data_size too small on %pg\n",
+			rdev->bdev);
 		return -EINVAL;
 	}
 	if (sb->pad0 ||
@@ -1813,9 +1808,9 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 		    sb->level != refsb->level ||
 		    sb->layout != refsb->layout ||
 		    sb->chunksize != refsb->chunksize) {
-			pr_warn("md: %s has strangely different superblock to %s\n",
-				bdevname(rdev->bdev,b),
-				bdevname(refdev->bdev,b2));
+			pr_warn("md: %pg has strangely different superblock to %pg\n",
+				rdev->bdev,
+				refdev->bdev);
 			return -EINVAL;
 		}
 		ev1 = le64_to_cpu(sb->events);
@@ -2395,7 +2390,6 @@ EXPORT_SYMBOL(md_integrity_register);
 int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev)
 {
 	struct blk_integrity *bi_mddev;
-	char name[BDEVNAME_SIZE];
 
 	if (!mddev->gendisk)
 		return 0;
@@ -2406,8 +2400,8 @@ int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev)
 		return 0;
 
 	if (blk_integrity_compare(mddev->gendisk, rdev->bdev->bd_disk) != 0) {
-		pr_err("%s: incompatible integrity profile for %s\n",
-		       mdname(mddev), bdevname(rdev->bdev, name));
+		pr_err("%s: incompatible integrity profile for %pg\n",
+		       mdname(mddev), rdev->bdev);
 		return -ENXIO;
 	}
 
@@ -2516,11 +2510,9 @@ static void rdev_delayed_delete(struct work_struct *ws)
 
 static void unbind_rdev_from_array(struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
-
 	bd_unlink_disk_holder(rdev->bdev, rdev->mddev->gendisk);
 	list_del_rcu(&rdev->same_set);
-	pr_debug("md: unbind<%s>\n", bdevname(rdev->bdev,b));
+	pr_debug("md: unbind<%pg>\n", rdev->bdev);
 	mddev_destroy_serial_pool(rdev->mddev, rdev, false);
 	rdev->mddev = NULL;
 	sysfs_remove_link(&rdev->kobj, "block");
@@ -2573,9 +2565,7 @@ void md_autodetect_dev(dev_t dev);
 
 static void export_rdev(struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
-
-	pr_debug("md: export_rdev(%s)\n", bdevname(rdev->bdev,b));
+	pr_debug("md: export_rdev(%pg)\n", rdev->bdev);
 	md_rdev_clear(rdev);
 #ifndef MODULE
 	if (test_bit(AutoDetected, &rdev->flags))
@@ -2831,8 +2821,6 @@ void md_update_sb(struct mddev *mddev, int force_change)
 rewrite:
 	md_bitmap_update_sb(mddev->bitmap);
 	rdev_for_each(rdev, mddev) {
-		char b[BDEVNAME_SIZE];
-
 		if (rdev->sb_loaded != 1)
 			continue; /* no noise on spare devices */
 
@@ -2840,8 +2828,8 @@ void md_update_sb(struct mddev *mddev, int force_change)
 			md_super_write(mddev,rdev,
 				       rdev->sb_start, rdev->sb_size,
 				       rdev->sb_page);
-			pr_debug("md: (write) %s's sb offset: %llu\n",
-				 bdevname(rdev->bdev, b),
+			pr_debug("md: (write) %pg's sb offset: %llu\n",
+				 rdev->bdev,
 				 (unsigned long long)rdev->sb_start);
 			rdev->sb_events = mddev->events;
 			if (rdev->badblocks.size) {
@@ -2853,8 +2841,8 @@ void md_update_sb(struct mddev *mddev, int force_change)
 			}
 
 		} else
-			pr_debug("md: %s (skipping faulty)\n",
-				 bdevname(rdev->bdev, b));
+			pr_debug("md: %pg (skipping faulty)\n",
+				 rdev->bdev);
 
 		if (mddev->level == LEVEL_MULTIPATH)
 			/* only need to write one superblock... */
@@ -3718,7 +3706,6 @@ EXPORT_SYMBOL_GPL(md_rdev_init);
  */
 static struct md_rdev *md_import_device(dev_t newdev, int super_format, int super_minor)
 {
-	char b[BDEVNAME_SIZE];
 	int err;
 	struct md_rdev *rdev;
 	sector_t size;
@@ -3742,8 +3729,8 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
 
 	size = i_size_read(rdev->bdev->bd_inode) >> BLOCK_SIZE_BITS;
 	if (!size) {
-		pr_warn("md: %s has zero or unknown size, marking faulty!\n",
-			bdevname(rdev->bdev,b));
+		pr_warn("md: %pg has zero or unknown size, marking faulty!\n",
+			rdev->bdev);
 		err = -EINVAL;
 		goto abort_free;
 	}
@@ -3752,14 +3739,14 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
 		err = super_types[super_format].
 			load_super(rdev, NULL, super_minor);
 		if (err == -EINVAL) {
-			pr_warn("md: %s does not have a valid v%d.%d superblock, not importing!\n",
-				bdevname(rdev->bdev,b),
+			pr_warn("md: %pg does not have a valid v%d.%d superblock, not importing!\n",
+				rdev->bdev,
 				super_format, super_minor);
 			goto abort_free;
 		}
 		if (err < 0) {
-			pr_warn("md: could not read %s's sb, not importing!\n",
-				bdevname(rdev->bdev,b));
+			pr_warn("md: could not read %pg's sb, not importing!\n",
+				rdev->bdev);
 			goto abort_free;
 		}
 	}
@@ -3782,7 +3769,6 @@ static int analyze_sbs(struct mddev *mddev)
 {
 	int i;
 	struct md_rdev *rdev, *freshest, *tmp;
-	char b[BDEVNAME_SIZE];
 
 	freshest = NULL;
 	rdev_for_each_safe(rdev, tmp, mddev)
@@ -3794,8 +3780,8 @@ static int analyze_sbs(struct mddev *mddev)
 		case 0:
 			break;
 		default:
-			pr_warn("md: fatal superblock inconsistency in %s -- removing from array\n",
-				bdevname(rdev->bdev,b));
+			pr_warn("md: fatal superblock inconsistency in %pg -- removing from array\n",
+				rdev->bdev);
 			md_kick_rdev_from_array(rdev);
 		}
 
@@ -3813,8 +3799,8 @@ static int analyze_sbs(struct mddev *mddev)
 		if (mddev->max_disks &&
 		    (rdev->desc_nr >= mddev->max_disks ||
 		     i > mddev->max_disks)) {
-			pr_warn("md: %s: %s: only %d devices permitted\n",
-				mdname(mddev), bdevname(rdev->bdev, b),
+			pr_warn("md: %s: %pg: only %d devices permitted\n",
+				mdname(mddev), rdev->bdev,
 				mddev->max_disks);
 			md_kick_rdev_from_array(rdev);
 			continue;
@@ -3822,8 +3808,8 @@ static int analyze_sbs(struct mddev *mddev)
 		if (rdev != freshest) {
 			if (super_types[mddev->major_version].
 			    validate_super(mddev, rdev)) {
-				pr_warn("md: kicking non-fresh %s from array!\n",
-					bdevname(rdev->bdev,b));
+				pr_warn("md: kicking non-fresh %pg from array!\n",
+					rdev->bdev);
 				md_kick_rdev_from_array(rdev);
 				continue;
 			}
@@ -5942,7 +5928,6 @@ int md_run(struct mddev *mddev)
 		/* Warn if this is a potentially silly
 		 * configuration.
 		 */
-		char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 		struct md_rdev *rdev2;
 		int warned = 0;
 
@@ -5951,10 +5936,10 @@ int md_run(struct mddev *mddev)
 				if (rdev < rdev2 &&
 				    rdev->bdev->bd_disk ==
 				    rdev2->bdev->bd_disk) {
-					pr_warn("%s: WARNING: %s appears to be on the same physical disk as %s.\n",
+					pr_warn("%s: WARNING: %pg appears to be on the same physical disk as %pg.\n",
 						mdname(mddev),
-						bdevname(rdev->bdev,b),
-						bdevname(rdev2->bdev,b2));
+						rdev->bdev,
+						rdev2->bdev);
 					warned = 1;
 				}
 			}
@@ -6474,8 +6459,7 @@ static void autorun_array(struct mddev *mddev)
 	pr_info("md: running: ");
 
 	rdev_for_each(rdev, mddev) {
-		char b[BDEVNAME_SIZE];
-		pr_cont("<%s>", bdevname(rdev->bdev,b));
+		pr_cont("<%pg>", rdev->bdev);
 	}
 	pr_cont("\n");
 
@@ -6502,7 +6486,6 @@ static void autorun_devices(int part)
 {
 	struct md_rdev *rdev0, *rdev, *tmp;
 	struct mddev *mddev;
-	char b[BDEVNAME_SIZE];
 
 	pr_info("md: autorun ...\n");
 	while (!list_empty(&pending_raid_disks)) {
@@ -6512,12 +6495,12 @@ static void autorun_devices(int part)
 		rdev0 = list_entry(pending_raid_disks.next,
 					 struct md_rdev, same_set);
 
-		pr_debug("md: considering %s ...\n", bdevname(rdev0->bdev,b));
+		pr_debug("md: considering %pg ...\n", rdev0->bdev);
 		INIT_LIST_HEAD(&candidates);
 		rdev_for_each_list(rdev, tmp, &pending_raid_disks)
 			if (super_90_load(rdev, rdev0, 0) >= 0) {
-				pr_debug("md:  adding %s ...\n",
-					 bdevname(rdev->bdev,b));
+				pr_debug("md:  adding %pg ...\n",
+					 rdev->bdev);
 				list_move(&rdev->same_set, &candidates);
 			}
 		/*
@@ -6534,8 +6517,8 @@ static void autorun_devices(int part)
 			unit = MINOR(dev);
 		}
 		if (rdev0->preferred_minor != unit) {
-			pr_warn("md: unit number in %s is bad: %d\n",
-				bdevname(rdev0->bdev, b), rdev0->preferred_minor);
+			pr_warn("md: unit number in %pg is bad: %d\n",
+				rdev0->bdev, rdev0->preferred_minor);
 			break;
 		}
 
@@ -6548,8 +6531,8 @@ static void autorun_devices(int part)
 			pr_warn("md: %s locked, cannot run\n", mdname(mddev));
 		else if (mddev->raid_disks || mddev->major_version
 			 || !list_empty(&mddev->disks)) {
-			pr_warn("md: %s already running, cannot run %s\n",
-				mdname(mddev), bdevname(rdev0->bdev,b));
+			pr_warn("md: %s already running, cannot run %pg\n",
+				mdname(mddev), rdev0->bdev);
 			mddev_unlock(mddev);
 		} else {
 			pr_debug("md: created %s\n", mdname(mddev));
@@ -6723,7 +6706,6 @@ static int get_disk_info(struct mddev *mddev, void __user * arg)
 
 int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 {
-	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 	struct md_rdev *rdev;
 	dev_t dev = MKDEV(info->major,info->minor);
 
@@ -6753,9 +6735,9 @@ int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 			err = super_types[mddev->major_version]
 				.load_super(rdev, rdev0, mddev->minor_version);
 			if (err < 0) {
-				pr_warn("md: %s has different UUID to %s\n",
-					bdevname(rdev->bdev,b),
-					bdevname(rdev0->bdev,b2));
+				pr_warn("md: %pg has different UUID to %pg\n",
+					rdev->bdev,
+					rdev0->bdev);
 				export_rdev(rdev);
 				return -EINVAL;
 			}
@@ -6930,7 +6912,6 @@ int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 
 static int hot_remove_disk(struct mddev *mddev, dev_t dev)
 {
-	char b[BDEVNAME_SIZE];
 	struct md_rdev *rdev;
 
 	if (!mddev->pers)
@@ -6965,14 +6946,13 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev)
 
 	return 0;
 busy:
-	pr_debug("md: cannot remove active disk %s from %s ...\n",
-		 bdevname(rdev->bdev,b), mdname(mddev));
+	pr_debug("md: cannot remove active disk %pg from %s ...\n",
+		 rdev->bdev, mdname(mddev));
 	return -EBUSY;
 }
 
 static int hot_add_disk(struct mddev *mddev, dev_t dev)
 {
-	char b[BDEVNAME_SIZE];
 	int err;
 	struct md_rdev *rdev;
 
@@ -7005,8 +6985,8 @@ static int hot_add_disk(struct mddev *mddev, dev_t dev)
 	rdev->sectors = rdev->sb_start;
 
 	if (test_bit(Faulty, &rdev->flags)) {
-		pr_warn("md: can not hot-add faulty %s disk to %s!\n",
-			bdevname(rdev->bdev,b), mdname(mddev));
+		pr_warn("md: can not hot-add faulty %pg disk to %s!\n",
+			rdev->bdev, mdname(mddev));
 		err = -EINVAL;
 		goto abort_export;
 	}
@@ -8022,10 +8002,8 @@ static void status_unused(struct seq_file *seq)
 	seq_printf(seq, "unused devices: ");
 
 	list_for_each_entry(rdev, &pending_raid_disks, same_set) {
-		char b[BDEVNAME_SIZE];
 		i++;
-		seq_printf(seq, "%s ",
-			      bdevname(rdev->bdev,b));
+		seq_printf(seq, "%pg ", rdev->bdev);
 	}
 	if (!i)
 		seq_printf(seq, "<none>");
@@ -8265,9 +8243,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
 		sectors = 0;
 		rcu_read_lock();
 		rdev_for_each_rcu(rdev, mddev) {
-			char b[BDEVNAME_SIZE];
-			seq_printf(seq, " %s[%d]",
-				bdevname(rdev->bdev,b), rdev->desc_nr);
+			seq_printf(seq, " %pg[%d]", rdev->bdev, rdev->desc_nr);
 			if (test_bit(WriteMostly, &rdev->flags))
 				seq_printf(seq, "(W)");
 			if (test_bit(Journal, &rdev->flags))
@@ -9609,7 +9585,6 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 	struct mdp_superblock_1 *sb = page_address(rdev->sb_page);
 	struct md_rdev *rdev2, *tmp;
 	int role, ret;
-	char b[BDEVNAME_SIZE];
 
 	/*
 	 * If size is changed in another node then we need to
@@ -9633,7 +9608,8 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 
 		if (test_bit(Candidate, &rdev2->flags)) {
 			if (role == 0xfffe) {
-				pr_info("md: Removing Candidate device %s because add failed\n", bdevname(rdev2->bdev,b));
+				pr_info("md: Removing Candidate device %pg because add failed\n",
+					rdev2->bdev);
 				md_kick_rdev_from_array(rdev2);
 				continue;
 			}
@@ -9650,8 +9626,8 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 			      MD_FEATURE_RESHAPE_ACTIVE)) {
 				rdev2->saved_raid_disk = role;
 				ret = remove_and_add_spares(mddev, rdev2);
-				pr_info("Activated spare: %s\n",
-					bdevname(rdev2->bdev,b));
+				pr_info("Activated spare: %pg\n",
+					rdev2->bdev);
 				/* wakeup mddev->thread here, so array could
 				 * perform resync with the new activated disk */
 				set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e5d7411cba9b..82e7dbf71542 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -37,7 +37,6 @@ static void dump_zones(struct mddev *mddev)
 	int j, k;
 	sector_t zone_size = 0;
 	sector_t zone_start = 0;
-	char b[BDEVNAME_SIZE];
 	struct r0conf *conf = mddev->private;
 	int raid_disks = conf->strip_zone[0].nb_dev;
 	pr_debug("md: RAID0 configuration for %s - %d zone%s\n",
@@ -48,9 +47,9 @@ static void dump_zones(struct mddev *mddev)
 		int len = 0;
 
 		for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
-			len += snprintf(line+len, 200-len, "%s%s", k?"/":"",
-					bdevname(conf->devlist[j*raid_disks
-							       + k]->bdev, b));
+			len += snprintf(line + len, 200 - len, "%s%pg",
+					k ? "/" : "",
+					conf->devlist[j * raid_disks + k]->bdev);
 		pr_debug("md: zone%d=[%s]\n", j, line);
 
 		zone_size  = conf->strip_zone[j].zone_end - zone_start;
@@ -69,8 +68,6 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	struct md_rdev *smallest, *rdev1, *rdev2, *rdev, **dev;
 	struct strip_zone *zone;
 	int cnt;
-	char b[BDEVNAME_SIZE];
-	char b2[BDEVNAME_SIZE];
 	struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	unsigned blksize = 512;
 
@@ -78,9 +75,9 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	if (!conf)
 		return -ENOMEM;
 	rdev_for_each(rdev1, mddev) {
-		pr_debug("md/raid0:%s: looking at %s\n",
+		pr_debug("md/raid0:%s: looking at %pg\n",
 			 mdname(mddev),
-			 bdevname(rdev1->bdev, b));
+			 rdev1->bdev);
 		c = 0;
 
 		/* round size to chunk_size */
@@ -92,12 +89,11 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 				      rdev1->bdev->bd_disk->queue));
 
 		rdev_for_each(rdev2, mddev) {
-			pr_debug("md/raid0:%s:   comparing %s(%llu)"
-				 " with %s(%llu)\n",
+			pr_debug("md/raid0:%s:   comparing %pg(%llu) with %pg(%llu)\n",
 				 mdname(mddev),
-				 bdevname(rdev1->bdev,b),
+				 rdev1->bdev,
 				 (unsigned long long)rdev1->sectors,
-				 bdevname(rdev2->bdev,b2),
+				 rdev2->bdev,
 				 (unsigned long long)rdev2->sectors);
 			if (rdev2 == rdev1) {
 				pr_debug("md/raid0:%s:   END\n",
@@ -240,15 +236,15 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		for (j=0; j<cnt; j++) {
 			rdev = conf->devlist[j];
 			if (rdev->sectors <= zone->dev_start) {
-				pr_debug("md/raid0:%s: checking %s ... nope\n",
+				pr_debug("md/raid0:%s: checking %pg ... nope\n",
 					 mdname(mddev),
-					 bdevname(rdev->bdev, b));
+					 rdev->bdev);
 				continue;
 			}
-			pr_debug("md/raid0:%s: checking %s ..."
+			pr_debug("md/raid0:%s: checking %pg ..."
 				 " contained as device %d\n",
 				 mdname(mddev),
-				 bdevname(rdev->bdev, b), c);
+				 rdev->bdev, c);
 			dev[c] = rdev;
 			c++;
 			if (!smallest || rdev->sectors < smallest->sectors) {
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ced076ba560e..d32a8b5f256b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -396,10 +396,9 @@ static void raid1_end_read_request(struct bio *bio)
 		/*
 		 * oops, read error:
 		 */
-		char b[BDEVNAME_SIZE];
-		pr_err_ratelimited("md/raid1:%s: %s: rescheduling sector %llu\n",
+		pr_err_ratelimited("md/raid1:%s: %pg: rescheduling sector %llu\n",
 				   mdname(conf->mddev),
-				   bdevname(rdev->bdev, b),
+				   rdev->bdev,
 				   (unsigned long long)r1_bio->sector);
 		set_bit(R1BIO_ReadError, &r1_bio->state);
 		reschedule_retry(r1_bio);
@@ -1594,7 +1593,6 @@ static void raid1_status(struct seq_file *seq, struct mddev *mddev)
 
 static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	struct r1conf *conf = mddev->private;
 	unsigned long flags;
 
@@ -1628,9 +1626,9 @@ static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_bit(MD_RECOVERY_INTR, &mddev->recovery);
 	set_mask_bits(&mddev->sb_flags, 0,
 		      BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
-	pr_crit("md/raid1:%s: Disk failure on %s, disabling device.\n"
+	pr_crit("md/raid1:%s: Disk failure on %pg, disabling device.\n"
 		"md/raid1:%s: Operation continuing on %d devices.\n",
-		mdname(mddev), bdevname(rdev->bdev, b),
+		mdname(mddev), rdev->bdev,
 		mdname(mddev), conf->raid_disks - mddev->degraded);
 }
 
@@ -1648,13 +1646,12 @@ static void print_conf(struct r1conf *conf)
 
 	rcu_read_lock();
 	for (i = 0; i < conf->raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
 		if (rdev)
-			pr_debug(" disk %d, wo:%d, o:%d, dev:%s\n",
+			pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n",
 				 i, !test_bit(In_sync, &rdev->flags),
 				 !test_bit(Faulty, &rdev->flags),
-				 bdevname(rdev->bdev,b));
+				 rdev->bdev);
 	}
 	rcu_read_unlock();
 }
@@ -2015,15 +2012,14 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
 		} while (!success && d != r1_bio->read_disk);
 
 		if (!success) {
-			char b[BDEVNAME_SIZE];
 			int abort = 0;
 			/* Cannot read from anywhere, this block is lost.
 			 * Record a bad block on each device.  If that doesn't
 			 * work just disable and interrupt the recovery.
 			 * Don't fail devices as that won't really help.
 			 */
-			pr_crit_ratelimited("md/raid1:%s: %s: unrecoverable I/O read error for block %llu\n",
-					    mdname(mddev), bio_devname(bio, b),
+			pr_crit_ratelimited("md/raid1:%s: %pg: unrecoverable I/O read error for block %llu\n",
+					    mdname(mddev), bio->bi_bdev,
 					    (unsigned long long)r1_bio->sector);
 			for (d = 0; d < conf->raid_disks * 2; d++) {
 				rdev = conf->mirrors[d].rdev;
@@ -2293,7 +2289,6 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 		}
 		d = start;
 		while (d != read_disk) {
-			char b[BDEVNAME_SIZE];
 			if (d==0)
 				d = conf->raid_disks * 2;
 			d--;
@@ -2306,11 +2301,11 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 				if (r1_sync_page_io(rdev, sect, s,
 						    conf->tmppage, READ)) {
 					atomic_add(s, &rdev->corrected_errors);
-					pr_info("md/raid1:%s: read error corrected (%d sectors at %llu on %s)\n",
+					pr_info("md/raid1:%s: read error corrected (%d sectors at %llu on %pg)\n",
 						mdname(mddev), s,
 						(unsigned long long)(sect +
 								     rdev->data_offset),
-						bdevname(rdev->bdev, b));
+						rdev->bdev);
 				}
 				rdev_dec_pending(rdev, mddev);
 			} else
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 13f5e6b2a73d..e3ea67adc7b2 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -388,10 +388,9 @@ static void raid10_end_read_request(struct bio *bio)
 		/*
 		 * oops, read error - keep the refcount on the rdev
 		 */
-		char b[BDEVNAME_SIZE];
-		pr_err_ratelimited("md/raid10:%s: %s: rescheduling sector %llu\n",
+		pr_err_ratelimited("md/raid10:%s: %pg: rescheduling sector %llu\n",
 				   mdname(conf->mddev),
-				   bdevname(rdev->bdev, b),
+				   rdev->bdev,
 				   (unsigned long long)r10_bio->sector);
 		set_bit(R10BIO_ReadError, &r10_bio->state);
 		reschedule_retry(r10_bio);
@@ -1935,7 +1934,6 @@ static int enough(struct r10conf *conf, int ignore)
 
 static void raid10_error(struct mddev *mddev, struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	struct r10conf *conf = mddev->private;
 	unsigned long flags;
 
@@ -1965,9 +1963,9 @@ static void raid10_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_mask_bits(&mddev->sb_flags, 0,
 		      BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
 	spin_unlock_irqrestore(&conf->device_lock, flags);
-	pr_crit("md/raid10:%s: Disk failure on %s, disabling device.\n"
+	pr_crit("md/raid10:%s: Disk failure on %pg, disabling device.\n"
 		"md/raid10:%s: Operation continuing on %d devices.\n",
-		mdname(mddev), bdevname(rdev->bdev, b),
+		mdname(mddev), rdev->bdev,
 		mdname(mddev), conf->geo.raid_disks - mddev->degraded);
 }
 
@@ -1987,13 +1985,12 @@ static void print_conf(struct r10conf *conf)
 	/* This is only called with ->reconfix_mutex held, so
 	 * rcu protection of rdev is not needed */
 	for (i = 0; i < conf->geo.raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		rdev = conf->mirrors[i].rdev;
 		if (rdev)
-			pr_debug(" disk %d, wo:%d, o:%d, dev:%s\n",
+			pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n",
 				 i, !test_bit(In_sync, &rdev->flags),
 				 !test_bit(Faulty, &rdev->flags),
-				 bdevname(rdev->bdev,b));
+				 rdev->bdev);
 	}
 }
 
@@ -2650,14 +2647,11 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 	check_decay_read_errors(mddev, rdev);
 	atomic_inc(&rdev->read_errors);
 	if (atomic_read(&rdev->read_errors) > max_read_errors) {
-		char b[BDEVNAME_SIZE];
-		bdevname(rdev->bdev, b);
-
-		pr_notice("md/raid10:%s: %s: Raid device exceeded read_error threshold [cur %d:max %d]\n",
-			  mdname(mddev), b,
+		pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n",
+			  mdname(mddev), rdev->bdev,
 			  atomic_read(&rdev->read_errors), max_read_errors);
-		pr_notice("md/raid10:%s: %s: Failing raid device\n",
-			  mdname(mddev), b);
+		pr_notice("md/raid10:%s: %pg: Failing raid device\n",
+			  mdname(mddev), rdev->bdev);
 		md_error(mddev, rdev);
 		r10_bio->devs[r10_bio->read_slot].bio = IO_BLOCKED;
 		return;
@@ -2727,8 +2721,6 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 		/* write it back and re-read */
 		rcu_read_lock();
 		while (sl != r10_bio->read_slot) {
-			char b[BDEVNAME_SIZE];
-
 			if (sl==0)
 				sl = conf->copies;
 			sl--;
@@ -2747,24 +2739,22 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 					     s, conf->tmppage, WRITE)
 			    == 0) {
 				/* Well, this device is dead */
-				pr_notice("md/raid10:%s: read correction write failed (%d sectors at %llu on %s)\n",
+				pr_notice("md/raid10:%s: read correction write failed (%d sectors at %llu on %pg)\n",
 					  mdname(mddev), s,
 					  (unsigned long long)(
 						  sect +
 						  choose_data_offset(r10_bio,
 								     rdev)),
-					  bdevname(rdev->bdev, b));
-				pr_notice("md/raid10:%s: %s: failing drive\n",
+					  rdev->bdev);
+				pr_notice("md/raid10:%s: %pg: failing drive\n",
 					  mdname(mddev),
-					  bdevname(rdev->bdev, b));
+					  rdev->bdev);
 			}
 			rdev_dec_pending(rdev, mddev);
 			rcu_read_lock();
 		}
 		sl = start;
 		while (sl != r10_bio->read_slot) {
-			char b[BDEVNAME_SIZE];
-
 			if (sl==0)
 				sl = conf->copies;
 			sl--;
@@ -2784,23 +2774,21 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 						 READ)) {
 			case 0:
 				/* Well, this device is dead */
-				pr_notice("md/raid10:%s: unable to read back corrected sectors (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio, rdev)),
-				       bdevname(rdev->bdev, b));
-				pr_notice("md/raid10:%s: %s: failing drive\n",
-				       mdname(mddev),
-				       bdevname(rdev->bdev, b));
+				pr_notice("md/raid10:%s: unable to read back corrected sectors (%d sectors at %llu on %pg)\n",
+					  mdname(mddev), s,
+					  (unsigned long long)(sect
+						  + choose_data_offset(r10_bio, rdev)),
+					  rdev->bdev);
+				pr_notice("md/raid10:%s: %pg: failing drive\n",
+					  mdname(mddev),
+					  rdev->bdev);
 				break;
 			case 1:
-				pr_info("md/raid10:%s: read error corrected (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio, rdev)),
-				       bdevname(rdev->bdev, b));
+				pr_info("md/raid10:%s: read error corrected (%d sectors at %llu on %pg)\n",
+					mdname(mddev), s,
+					(unsigned long long)(sect
+						+ choose_data_offset(r10_bio, rdev)),
+					rdev->bdev);
 				atomic_add(s, &rdev->corrected_errors);
 			}
 
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 0b5dcaabbc15..0323eb8fa949 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -3067,11 +3067,10 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
 {
 	struct request_queue *q = bdev_get_queue(rdev->bdev);
 	struct r5l_log *log;
-	char b[BDEVNAME_SIZE];
 	int ret;
 
-	pr_debug("md/raid:%s: using device %s as journal\n",
-		 mdname(conf->mddev), bdevname(rdev->bdev, b));
+	pr_debug("md/raid:%s: using device %pg as journal\n",
+		 mdname(conf->mddev), rdev->bdev);
 
 	if (PAGE_SIZE != 4096)
 		return -EINVAL;
diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c
index 3ddc2aa0b530..800793b0d0f5 100644
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@ -416,12 +416,10 @@ static void ppl_log_endio(struct bio *bio)
 
 static void ppl_submit_iounit_bio(struct ppl_io_unit *io, struct bio *bio)
 {
-	char b[BDEVNAME_SIZE];
-
-	pr_debug("%s: seq: %llu size: %u sector: %llu dev: %s\n",
+	pr_debug("%s: seq: %llu size: %u sector: %llu dev: %pg\n",
 		 __func__, io->seq, bio->bi_iter.bi_size,
 		 (unsigned long long)bio->bi_iter.bi_sector,
-		 bio_devname(bio, b));
+		 bio->bi_bdev);
 
 	submit_bio(bio);
 }
@@ -590,9 +588,8 @@ static void ppl_flush_endio(struct bio *bio)
 	struct ppl_log *log = io->log;
 	struct ppl_conf *ppl_conf = log->ppl_conf;
 	struct r5conf *conf = ppl_conf->mddev->private;
-	char b[BDEVNAME_SIZE];
 
-	pr_debug("%s: dev: %s\n", __func__, bio_devname(bio, b));
+	pr_debug("%s: dev: %pg\n", __func__, bio->bi_bdev);
 
 	if (bio->bi_status) {
 		struct md_rdev *rdev;
@@ -635,7 +632,6 @@ static void ppl_do_flush(struct ppl_io_unit *io)
 
 		if (bdev) {
 			struct bio *bio;
-			char b[BDEVNAME_SIZE];
 
 			bio = bio_alloc_bioset(GFP_NOIO, 0, &ppl_conf->flush_bs);
 			bio_set_dev(bio, bdev);
@@ -643,8 +639,8 @@ static void ppl_do_flush(struct ppl_io_unit *io)
 			bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
 			bio->bi_end_io = ppl_flush_endio;
 
-			pr_debug("%s: dev: %s\n", __func__,
-				 bio_devname(bio, b));
+			pr_debug("%s: dev: %pg\n", __func__,
+				 bio->bi_bdev);
 
 			submit_bio(bio);
 			flushed_disks++;
@@ -807,7 +803,6 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
 	int data_disks;
 	int i;
 	int ret = 0;
-	char b[BDEVNAME_SIZE];
 	unsigned int pp_size = le32_to_cpu(e->pp_size);
 	unsigned int data_size = le32_to_cpu(e->data_size);
 
@@ -901,8 +896,8 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
 				break;
 			}
 
-			pr_debug("%s:%*s reading data member disk %s sector %llu\n",
-				 __func__, indent, "", bdevname(rdev->bdev, b),
+			pr_debug("%s:%*s reading data member disk %pg sector %llu\n",
+				 __func__, indent, "", rdev->bdev,
 				 (unsigned long long)sector);
 			if (!sync_page_io(rdev, sector, block_size, page2,
 					REQ_OP_READ, 0, false)) {
@@ -946,10 +941,10 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
 		parity_rdev = conf->disks[sh.pd_idx].rdev;
 
 		BUG_ON(parity_rdev->bdev->bd_dev != log->rdev->bdev->bd_dev);
-		pr_debug("%s:%*s write parity at sector %llu, disk %s\n",
+		pr_debug("%s:%*s write parity at sector %llu, disk %pg\n",
 			 __func__, indent, "",
 			 (unsigned long long)parity_sector,
-			 bdevname(parity_rdev->bdev, b));
+			 parity_rdev->bdev);
 		if (!sync_page_io(parity_rdev, parity_sector, block_size,
 				page1, REQ_OP_WRITE, 0, false)) {
 			pr_debug("%s:%*s parity write error!\n", __func__,
@@ -1261,7 +1256,6 @@ void ppl_exit_log(struct r5conf *conf)
 
 static int ppl_validate_rdev(struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	int ppl_data_sectors;
 	int ppl_size_new;
 
@@ -1278,8 +1272,8 @@ static int ppl_validate_rdev(struct md_rdev *rdev)
 				RAID5_STRIPE_SECTORS((struct r5conf *)rdev->mddev->private));
 
 	if (ppl_data_sectors <= 0) {
-		pr_warn("md/raid:%s: PPL space too small on %s\n",
-			mdname(rdev->mddev), bdevname(rdev->bdev, b));
+		pr_warn("md/raid:%s: PPL space too small on %pg\n",
+			mdname(rdev->mddev), rdev->bdev);
 		return -ENOSPC;
 	}
 
@@ -1289,16 +1283,16 @@ static int ppl_validate_rdev(struct md_rdev *rdev)
 	     rdev->ppl.sector + ppl_size_new > rdev->data_offset) ||
 	    (rdev->ppl.sector >= rdev->data_offset &&
 	     rdev->data_offset + rdev->sectors > rdev->ppl.sector)) {
-		pr_warn("md/raid:%s: PPL space overlaps with data on %s\n",
-			mdname(rdev->mddev), bdevname(rdev->bdev, b));
+		pr_warn("md/raid:%s: PPL space overlaps with data on %pg\n",
+			mdname(rdev->mddev), rdev->bdev);
 		return -EINVAL;
 	}
 
 	if (!rdev->mddev->external &&
 	    ((rdev->ppl.offset > 0 && rdev->ppl.offset < (rdev->sb_size >> 9)) ||
 	     (rdev->ppl.offset <= 0 && rdev->ppl.offset + ppl_size_new > 0))) {
-		pr_warn("md/raid:%s: PPL space overlaps with superblock on %s\n",
-			mdname(rdev->mddev), bdevname(rdev->bdev, b));
+		pr_warn("md/raid:%s: PPL space overlaps with superblock on %pg\n",
+			mdname(rdev->mddev), rdev->bdev);
 		return -EINVAL;
 	}
 
@@ -1468,14 +1462,13 @@ int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add)
 	struct ppl_conf *ppl_conf = conf->log_private;
 	struct ppl_log *log;
 	int ret = 0;
-	char b[BDEVNAME_SIZE];
 
 	if (!rdev)
 		return -EINVAL;
 
-	pr_debug("%s: disk: %d operation: %s dev: %s\n",
+	pr_debug("%s: disk: %d operation: %s dev: %pg\n",
 		 __func__, rdev->raid_disk, add ? "add" : "remove",
-		 bdevname(rdev->bdev, b));
+		 rdev->bdev);
 
 	if (rdev->raid_disk < 0)
 		return 0;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 7d4ff8a5c55e..ecafb102bdaf 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2665,7 +2665,6 @@ static void raid5_end_read_request(struct bio * bi)
 	struct stripe_head *sh = bi->bi_private;
 	struct r5conf *conf = sh->raid_conf;
 	int disks = sh->disks, i;
-	char b[BDEVNAME_SIZE];
 	struct md_rdev *rdev = NULL;
 	sector_t s;
 
@@ -2703,10 +2702,10 @@ static void raid5_end_read_request(struct bio * bi)
 			 * any error
 			 */
 			pr_info_ratelimited(
-				"md/raid:%s: read error corrected (%lu sectors at %llu on %s)\n",
+				"md/raid:%s: read error corrected (%lu sectors at %llu on %pg)\n",
 				mdname(conf->mddev), RAID5_STRIPE_SECTORS(conf),
 				(unsigned long long)s,
-				bdevname(rdev->bdev, b));
+				rdev->bdev);
 			atomic_add(RAID5_STRIPE_SECTORS(conf), &rdev->corrected_errors);
 			clear_bit(R5_ReadError, &sh->dev[i].flags);
 			clear_bit(R5_ReWrite, &sh->dev[i].flags);
@@ -2723,7 +2722,6 @@ static void raid5_end_read_request(struct bio * bi)
 		if (atomic_read(&rdev->read_errors))
 			atomic_set(&rdev->read_errors, 0);
 	} else {
-		const char *bdn = bdevname(rdev->bdev, b);
 		int retry = 0;
 		int set_bad = 0;
 
@@ -2732,25 +2730,25 @@ static void raid5_end_read_request(struct bio * bi)
 			atomic_inc(&rdev->read_errors);
 		if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
 			pr_warn_ratelimited(
-				"md/raid:%s: read error on replacement device (sector %llu on %s).\n",
+				"md/raid:%s: read error on replacement device (sector %llu on %pg).\n",
 				mdname(conf->mddev),
 				(unsigned long long)s,
-				bdn);
+				rdev->bdev);
 		else if (conf->mddev->degraded >= conf->max_degraded) {
 			set_bad = 1;
 			pr_warn_ratelimited(
-				"md/raid:%s: read error not correctable (sector %llu on %s).\n",
+				"md/raid:%s: read error not correctable (sector %llu on %pg).\n",
 				mdname(conf->mddev),
 				(unsigned long long)s,
-				bdn);
+				rdev->bdev);
 		} else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) {
 			/* Oh, no!!! */
 			set_bad = 1;
 			pr_warn_ratelimited(
-				"md/raid:%s: read error NOT corrected!! (sector %llu on %s).\n",
+				"md/raid:%s: read error NOT corrected!! (sector %llu on %pg).\n",
 				mdname(conf->mddev),
 				(unsigned long long)s,
-				bdn);
+				rdev->bdev);
 		} else if (atomic_read(&rdev->read_errors)
 			 > conf->max_nr_stripes) {
 			if (!test_bit(Faulty, &rdev->flags)) {
@@ -2758,8 +2756,8 @@ static void raid5_end_read_request(struct bio * bi)
 				    mdname(conf->mddev),
 				    atomic_read(&rdev->read_errors),
 				    conf->max_nr_stripes);
-				pr_warn("md/raid:%s: Too many read errors, failing device %s.\n",
-				    mdname(conf->mddev), bdn);
+				pr_warn("md/raid:%s: Too many read errors, failing device %pg.\n",
+					mdname(conf->mddev), rdev->bdev);
 			}
 		} else
 			retry = 1;
@@ -2872,7 +2870,6 @@ static void raid5_end_write_request(struct bio *bi)
 
 static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	struct r5conf *conf = mddev->private;
 	unsigned long flags;
 	pr_debug("raid456: error called\n");
@@ -2899,10 +2896,10 @@ static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_bit(Blocked, &rdev->flags);
 	set_mask_bits(&mddev->sb_flags, 0,
 		      BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
-	pr_crit("md/raid:%s: Disk failure on %s, disabling device.\n"
+	pr_crit("md/raid:%s: Disk failure on %pg, disabling device.\n"
 		"md/raid:%s: Operation continuing on %d devices.\n",
 		mdname(mddev),
-		bdevname(rdev->bdev, b),
+		rdev->bdev,
 		mdname(mddev),
 		conf->raid_disks - mddev->degraded);
 	r5c_update_on_rdev_error(mddev, rdev);
@@ -7300,9 +7297,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		}
 
 		if (test_bit(In_sync, &rdev->flags)) {
-			char b[BDEVNAME_SIZE];
-			pr_info("md/raid:%s: device %s operational as raid disk %d\n",
-				mdname(mddev), bdevname(rdev->bdev, b), raid_disk);
+			pr_info("md/raid:%s: device %pg operational as raid disk %d\n",
+				mdname(mddev), rdev->bdev, raid_disk);
 		} else if (rdev->saved_raid_disk != raid_disk)
 			/* Cannot rely on bitmap to complete recovery */
 			conf->fullsync = 1;
@@ -7805,12 +7801,11 @@ static void print_raid5_conf (struct r5conf *conf)
 	       conf->raid_disks - conf->mddev->degraded);
 
 	for (i = 0; i < conf->raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		tmp = conf->disks + i;
 		if (tmp->rdev)
-			pr_debug(" disk %d, o:%d, dev:%s\n",
-			       i, !test_bit(Faulty, &tmp->rdev->flags),
-			       bdevname(tmp->rdev->bdev, b));
+			pr_debug(" disk %d, o:%d, dev:%pg\n",
+				 i, !test_bit(Faulty, &tmp->rdev->flags),
+				 tmp->rdev->bdev);
 	}
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 04/10] dm: reduce stack footprint dealing with block device names
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (2 preceding siblings ...)
  2021-06-02 15:28 ` [PATCH 03/10] raid-md: reduce stack footprint dealing with block device names Anton Suvorov
@ 2021-06-02 15:28 ` Anton Suvorov
  2021-06-23 20:20   ` Mike Snitzer
  2021-06-02 15:28 ` [PATCH 05/10] block: " Anton Suvorov
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./drivers/md/dm-cache-target.c	cache_ctr	392	328	-64
./drivers/md/dm-cache-target.c	cache_io_hints	208	72	-136
./drivers/md/dm-clone-target.c	clone_ctr	416	352	-64
./drivers/md/dm-clone-target.c	clone_io_hints	216	80	-136
./drivers/md/dm-crypt.c	crypt_convert_block_aead	408	272	-136
./drivers/md/dm-crypt.c	kcryptd_async_done	192	56	-136
./drivers/md/dm-integrity.c	integrity_metadata	872	808	-64
./drivers/md/dm-mpath.c	parse_priority_group	368	304	-64
./drivers/md/dm-table.c	device_area_is_invalid	216	80	-136
./drivers/md/dm-table.c	dm_set_device_limits	200	72	-128
./drivers/md/dm-thin.c	pool_io_hints	216	80	-136

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/md/dm-cache-target.c | 10 ++++------
 drivers/md/dm-clone-target.c | 10 ++++------
 drivers/md/dm-crypt.c        |  6 ++----
 drivers/md/dm-integrity.c    |  4 ++--
 drivers/md/dm-mpath.c        |  6 ++----
 drivers/md/dm-table.c        | 34 ++++++++++++++++------------------
 drivers/md/dm-thin.c         |  8 +++-----
 7 files changed, 33 insertions(+), 45 deletions(-)

diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index d62ec0380c39..981739043bfb 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2096,7 +2096,6 @@ static int parse_metadata_dev(struct cache_args *ca, struct dm_arg_set *as,
 {
 	int r;
 	sector_t metadata_dev_size;
-	char b[BDEVNAME_SIZE];
 
 	if (!at_least_one_arg(as, error))
 		return -EINVAL;
@@ -2110,8 +2109,8 @@ static int parse_metadata_dev(struct cache_args *ca, struct dm_arg_set *as,
 
 	metadata_dev_size = get_dev_size(ca->metadata_dev);
 	if (metadata_dev_size > DM_CACHE_METADATA_MAX_SECTORS_WARNING)
-		DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
-		       bdevname(ca->metadata_dev->bdev, b), THIN_METADATA_MAX_SECTORS);
+		DMWARN("Metadata device %pg is larger than %u sectors: excess space will not be used.",
+		       ca->metadata_dev->bdev, THIN_METADATA_MAX_SECTORS);
 
 	return 0;
 }
@@ -3402,7 +3401,6 @@ static void disable_passdown_if_not_supported(struct cache *cache)
 	struct block_device *origin_bdev = cache->origin_dev->bdev;
 	struct queue_limits *origin_limits = &bdev_get_queue(origin_bdev)->limits;
 	const char *reason = NULL;
-	char buf[BDEVNAME_SIZE];
 
 	if (!cache->features.discard_passdown)
 		return;
@@ -3414,8 +3412,8 @@ static void disable_passdown_if_not_supported(struct cache *cache)
 		reason = "max discard sectors smaller than a block";
 
 	if (reason) {
-		DMWARN("Origin device (%s) %s: Disabling discard passdown.",
-		       bdevname(origin_bdev, buf), reason);
+		DMWARN("Origin device (%pg) %s: Disabling discard passdown.",
+		       origin_bdev, reason);
 		cache->features.discard_passdown = false;
 	}
 }
diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c
index a90bdf9b2ca6..10e2e8d8fbec 100644
--- a/drivers/md/dm-clone-target.c
+++ b/drivers/md/dm-clone-target.c
@@ -1677,7 +1677,6 @@ static int parse_metadata_dev(struct clone *clone, struct dm_arg_set *as, char *
 {
 	int r;
 	sector_t metadata_dev_size;
-	char b[BDEVNAME_SIZE];
 
 	r = dm_get_device(clone->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE,
 			  &clone->metadata_dev);
@@ -1688,8 +1687,8 @@ static int parse_metadata_dev(struct clone *clone, struct dm_arg_set *as, char *
 
 	metadata_dev_size = get_dev_size(clone->metadata_dev);
 	if (metadata_dev_size > DM_CLONE_METADATA_MAX_SECTORS_WARNING)
-		DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
-		       bdevname(clone->metadata_dev->bdev, b), DM_CLONE_METADATA_MAX_SECTORS);
+		DMWARN("Metadata device %pg is larger than %u sectors: excess space will not be used.",
+		       clone->metadata_dev->bdev, DM_CLONE_METADATA_MAX_SECTORS);
 
 	return 0;
 }
@@ -2028,7 +2027,6 @@ static void disable_passdown_if_not_supported(struct clone *clone)
 	struct block_device *dest_dev = clone->dest_dev->bdev;
 	struct queue_limits *dest_limits = &bdev_get_queue(dest_dev)->limits;
 	const char *reason = NULL;
-	char buf[BDEVNAME_SIZE];
 
 	if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags))
 		return;
@@ -2039,8 +2037,8 @@ static void disable_passdown_if_not_supported(struct clone *clone)
 		reason = "max discard sectors smaller than a region";
 
 	if (reason) {
-		DMWARN("Destination device (%s) %s: Disabling discard passdown.",
-		       bdevname(dest_dev, buf), reason);
+		DMWARN("Destination device (%pg) %s: Disabling discard passdown.",
+		       dest_dev, reason);
 		clear_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
 	}
 }
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index b0ab080f2567..993dda7d67c2 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1361,8 +1361,7 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
 	}
 
 	if (r == -EBADMSG) {
-		char b[BDEVNAME_SIZE];
-		DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
+		DMERR_LIMIT("%pg: INTEGRITY AEAD ERROR, sector %llu", ctx->bio_in->bi_bdev,
 			    (unsigned long long)le64_to_cpu(*sector));
 	}
 
@@ -2172,8 +2171,7 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
 		error = cc->iv_gen_ops->post(cc, org_iv_of_dmreq(cc, dmreq), dmreq);
 
 	if (error == -EBADMSG) {
-		char b[BDEVNAME_SIZE];
-		DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
+		DMERR_LIMIT("%pg: INTEGRITY AEAD ERROR, sector %llu", ctx->bio_in->bi_bdev,
 			    (unsigned long long)le64_to_cpu(*org_sector_of_dmreq(cc, dmreq)));
 		io->error = BLK_STS_PROTECTION;
 	} else if (error < 0)
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 20f2510db1f6..d2fec41635ff 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -1781,8 +1781,8 @@ static void integrity_metadata(struct work_struct *w)
 						checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);
 			if (unlikely(r)) {
 				if (r > 0) {
-					char b[BDEVNAME_SIZE];
-					DMERR_LIMIT("%s: Checksum failed at sector 0x%llx", bio_devname(bio, b),
+					DMERR_LIMIT("%pg: Checksum failed at sector 0x%llx",
+						    bio->bi_bdev,
 						    (sector - ((r + ic->tag_size - 1) / ic->tag_size)));
 					r = -EILSEQ;
 					atomic64_inc(&ic->number_of_mismatches);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index bced42f082b0..678e5bb0fa5a 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -900,10 +900,8 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
 	if (m->hw_handler_name) {
 		r = scsi_dh_attach(q, m->hw_handler_name);
 		if (r == -EBUSY) {
-			char b[BDEVNAME_SIZE];
-
-			printk(KERN_INFO "dm-mpath: retaining handler on device %s\n",
-			       bdevname(bdev, b));
+			pr_info("dm-mpath: retaining handler on device %pg\n",
+				bdev);
 			goto retain;
 		}
 		if (r < 0) {
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 7e88e5e06922..175b9c7b1c48 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -230,15 +230,14 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		i_size_read(bdev->bd_inode) >> SECTOR_SHIFT;
 	unsigned short logical_block_size_sectors =
 		limits->logical_block_size >> SECTOR_SHIFT;
-	char b[BDEVNAME_SIZE];
 
 	if (!dev_size)
 		return 0;
 
 	if ((start >= dev_size) || (start + len > dev_size)) {
-		DMWARN("%s: %s too small for target: "
+		DMWARN("%s: %pg too small for target: "
 		       "start=%llu, len=%llu, dev_size=%llu",
-		       dm_device_name(ti->table->md), bdevname(bdev, b),
+		       dm_device_name(ti->table->md), bdev,
 		       (unsigned long long)start,
 		       (unsigned long long)len,
 		       (unsigned long long)dev_size);
@@ -253,10 +252,10 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		unsigned int zone_sectors = bdev_zone_sectors(bdev);
 
 		if (start & (zone_sectors - 1)) {
-			DMWARN("%s: start=%llu not aligned to h/w zone size %u of %s",
+			DMWARN("%s: start=%llu not aligned to h/w zone size %u of %pg",
 			       dm_device_name(ti->table->md),
 			       (unsigned long long)start,
-			       zone_sectors, bdevname(bdev, b));
+			       zone_sectors, bdev);
 			return 1;
 		}
 
@@ -270,10 +269,10 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		 * the sector range.
 		 */
 		if (len & (zone_sectors - 1)) {
-			DMWARN("%s: len=%llu not aligned to h/w zone size %u of %s",
+			DMWARN("%s: len=%llu not aligned to h/w zone size %u of %pg",
 			       dm_device_name(ti->table->md),
 			       (unsigned long long)len,
-			       zone_sectors, bdevname(bdev, b));
+			       zone_sectors, bdev);
 			return 1;
 		}
 	}
@@ -282,20 +281,20 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		return 0;
 
 	if (start & (logical_block_size_sectors - 1)) {
-		DMWARN("%s: start=%llu not aligned to h/w "
-		       "logical block size %u of %s",
+		DMWARN("%s: start=%llu not aligned to h/w logical block size %u of %pg",
 		       dm_device_name(ti->table->md),
 		       (unsigned long long)start,
-		       limits->logical_block_size, bdevname(bdev, b));
+		       limits->logical_block_size,
+		       bdev);
 		return 1;
 	}
 
 	if (len & (logical_block_size_sectors - 1)) {
-		DMWARN("%s: len=%llu not aligned to h/w "
-		       "logical block size %u of %s",
+		DMWARN("%s: len=%llu not aligned to h/w logical block size %u of %pg",
 		       dm_device_name(ti->table->md),
 		       (unsigned long long)len,
-		       limits->logical_block_size, bdevname(bdev, b));
+		       limits->logical_block_size,
+		       bdev);
 		return 1;
 	}
 
@@ -400,20 +399,19 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
 	struct queue_limits *limits = data;
 	struct block_device *bdev = dev->bdev;
 	struct request_queue *q = bdev_get_queue(bdev);
-	char b[BDEVNAME_SIZE];
 
 	if (unlikely(!q)) {
-		DMWARN("%s: Cannot set limits for nonexistent device %s",
-		       dm_device_name(ti->table->md), bdevname(bdev, b));
+		DMWARN("%s: Cannot set limits for nonexistent device %pg",
+		       dm_device_name(ti->table->md), bdev);
 		return 0;
 	}
 
 	if (blk_stack_limits(limits, &q->limits,
 			get_start_sect(bdev) + start) < 0)
-		DMWARN("%s: adding target device %s caused an alignment inconsistency: "
+		DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
 		       "physical_block_size=%u, logical_block_size=%u, "
 		       "alignment_offset=%u, start=%llu",
-		       dm_device_name(ti->table->md), bdevname(bdev, b),
+		       dm_device_name(ti->table->md), bdev,
 		       q->limits.physical_block_size,
 		       q->limits.logical_block_size,
 		       q->limits.alignment_offset,
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 031d60318e1e..94a53c59aaa0 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2834,7 +2834,6 @@ static void disable_passdown_if_not_supported(struct pool_c *pt)
 	struct block_device *data_bdev = pt->data_dev->bdev;
 	struct queue_limits *data_limits = &bdev_get_queue(data_bdev)->limits;
 	const char *reason = NULL;
-	char buf[BDEVNAME_SIZE];
 
 	if (!pt->adjusted_pf.discard_passdown)
 		return;
@@ -2846,7 +2845,7 @@ static void disable_passdown_if_not_supported(struct pool_c *pt)
 		reason = "max discard sectors smaller than a block";
 
 	if (reason) {
-		DMWARN("Data device (%s) %s: Disabling discard passdown.", bdevname(data_bdev, buf), reason);
+		DMWARN("Data device (%pg) %s: Disabling discard passdown.", data_bdev, reason);
 		pt->adjusted_pf.discard_passdown = false;
 	}
 }
@@ -3218,11 +3217,10 @@ static sector_t get_dev_size(struct block_device *bdev)
 static void warn_if_metadata_device_too_big(struct block_device *bdev)
 {
 	sector_t metadata_dev_size = get_dev_size(bdev);
-	char buffer[BDEVNAME_SIZE];
 
 	if (metadata_dev_size > THIN_METADATA_MAX_SECTORS_WARNING)
-		DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
-		       bdevname(bdev, buffer), THIN_METADATA_MAX_SECTORS);
+		DMWARN("Metadata device %pg is larger than %u sectors: excess space will not be used.",
+		       bdev, THIN_METADATA_MAX_SECTORS);
 }
 
 static sector_t get_metadata_dev_size(struct block_device *bdev)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 05/10] block: reduce stack footprint dealing with block device names
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (3 preceding siblings ...)
  2021-06-02 15:28 ` [PATCH 04/10] dm: " Anton Suvorov
@ 2021-06-02 15:28 ` Anton Suvorov
  2021-06-02 15:28 ` [PATCH 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params() Anton Suvorov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./block/blk-core.c	submit_bio_checks	248	112	-136
./block/blk-lib.c	__blkdev_issue_discard	240	104	-136
./block/blk-settings.c	disk_stack_limits	256	192	-64
./block/partitions/amiga.c	amiga_partition	424	368	-56
./block/partitions/sgi.c	sgi_partition	352	288	-64
./block/partitions/sun.c	sun_partition	392	328	-64
./drivers/block/drbd/drbd_req.c	drbd_report_io_error	200	72	-128
./drivers/block/pktcdvd.c	pkt_seq_show	288	224	-64
./drivers/block/pktcdvd.c	pkt_setup_dev	272	136	-136
./drivers/block/pktcdvd.c	pkt_submit_bio	288	224	-64

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 block/blk-core.c         | 12 ++++--------
 block/blk-lib.c          |  5 +----
 block/blk-settings.c     |  7 ++-----
 block/partitions/amiga.c | 13 ++++++-------
 block/partitions/sgi.c   |  5 ++---
 block/partitions/sun.c   |  5 ++---
 drivers/block/pktcdvd.c  | 15 ++++++---------
 7 files changed, 23 insertions(+), 39 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 689aac2625d2..d85693882e6e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -650,11 +650,9 @@ EXPORT_SYMBOL(blk_put_request);
 
 static void handle_bad_sector(struct bio *bio, sector_t maxsector)
 {
-	char b[BDEVNAME_SIZE];
-
 	pr_info_ratelimited("attempt to access beyond end of device\n"
-			    "%s: rw=%d, want=%llu, limit=%llu\n",
-			    bio_devname(bio, b), bio->bi_opf,
+			    "%pg: rw=%d, want=%llu, limit=%llu\n",
+			    bio->bi_bdev, bio->bi_opf,
 			    bio_end_sector(bio), maxsector);
 }
 
@@ -696,14 +694,12 @@ static inline bool should_fail_request(struct block_device *part,
 static inline bool bio_check_ro(struct bio *bio)
 {
 	if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) {
-		char b[BDEVNAME_SIZE];
-
 		if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
 			return false;
 
 		WARN_ONCE(1,
-		       "Trying to write to read-only block-device %s (partno %d)\n",
-			bio_devname(bio, b), bio->bi_bdev->bd_partno);
+		       "Trying to write to read-only block-device %pg (partno %d)\n",
+			bio->bi_bdev, bio->bi_bdev->bd_partno);
 		/* Older lvm-tools actually trigger this */
 		return false;
 	}
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 7b256131b20b..6fe52f7f3f48 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -49,10 +49,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 
 	/* In case the discard granularity isn't set by buggy device driver */
 	if (WARN_ON_ONCE(!q->limits.discard_granularity)) {
-		char dev_name[BDEVNAME_SIZE];
-
-		bdevname(bdev, dev_name);
-		pr_err_ratelimited("%s: Error: discard_granularity is 0.\n", dev_name);
+		pr_err_ratelimited("%pg: Error: discard_granularity is 0.\n", bdev);
 		return -EOPNOTSUPP;
 	}
 
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 902c40d67120..01972174b1b9 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -662,13 +662,10 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
 
 	if (blk_stack_limits(&t->limits, &bdev_get_queue(bdev)->limits,
 			get_start_sect(bdev) + (offset >> 9)) < 0) {
-		char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE];
+		char top[BDEVNAME_SIZE];
 
 		disk_name(disk, 0, top);
-		bdevname(bdev, bottom);
-
-		printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",
-		       top, bottom);
+		pr_notice("%s: Warning: Device %pg is misaligned\n", top, bdev);
 	}
 
 	blk_queue_update_readahead(disk->queue);
diff --git a/block/partitions/amiga.c b/block/partitions/amiga.c
index 9526491d9aed..36255fba6863 100644
--- a/block/partitions/amiga.c
+++ b/block/partitions/amiga.c
@@ -34,15 +34,14 @@ int amiga_partition(struct parsed_partitions *state)
 	int start_sect, nr_sects, blk, part, res = 0;
 	int blksize = 1;	/* Multiplier for disk block size */
 	int slot = 1;
-	char b[BDEVNAME_SIZE];
 
 	for (blk = 0; ; blk++, put_dev_sector(sect)) {
 		if (blk == RDB_ALLOCATION_LIMIT)
 			goto rdb_done;
 		data = read_part_sector(state, blk, &sect);
 		if (!data) {
-			pr_err("Dev %s: unable to read RDB block %d\n",
-			       bdevname(state->bdev, b), blk);
+			pr_err("Dev %pg: unable to read RDB block %d\n",
+			       state->bdev, blk);
 			res = -1;
 			goto rdb_done;
 		}
@@ -63,8 +62,8 @@ int amiga_partition(struct parsed_partitions *state)
 			break;
 		}
 
-		pr_err("Dev %s: RDB in block %d has bad checksum\n",
-		       bdevname(state->bdev, b), blk);
+		pr_err("Dev %pg: RDB in block %d has bad checksum\n",
+		       state->bdev, blk);
 	}
 
 	/* blksize is blocks per 512 byte standard block */
@@ -83,8 +82,8 @@ int amiga_partition(struct parsed_partitions *state)
 		blk *= blksize;	/* Read in terms partition table understands */
 		data = read_part_sector(state, blk, &sect);
 		if (!data) {
-			pr_err("Dev %s: unable to read partition block %d\n",
-			       bdevname(state->bdev, b), blk);
+			pr_err("Dev %pg: unable to read partition block %d\n",
+			       state->bdev, blk);
 			res = -1;
 			goto rdb_done;
 		}
diff --git a/block/partitions/sgi.c b/block/partitions/sgi.c
index 4273f1bb0515..65cf137760ac 100644
--- a/block/partitions/sgi.c
+++ b/block/partitions/sgi.c
@@ -43,7 +43,6 @@ int sgi_partition(struct parsed_partitions *state)
 	Sector sect;
 	struct sgi_disklabel *label;
 	struct sgi_partition *p;
-	char b[BDEVNAME_SIZE];
 
 	label = read_part_sector(state, 0, &sect);
 	if (!label)
@@ -62,8 +61,8 @@ int sgi_partition(struct parsed_partitions *state)
 		csum += be32_to_cpu(cs);
 	}
 	if(csum) {
-		printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
-		       bdevname(state->bdev, b));
+		pr_warn("Dev %pg SGI disklabel: csum bad, label corrupted\n",
+			state->bdev);
 		put_dev_sector(sect);
 		return 0;
 	}
diff --git a/block/partitions/sun.c b/block/partitions/sun.c
index 47dc53eccf77..483be15f2800 100644
--- a/block/partitions/sun.c
+++ b/block/partitions/sun.c
@@ -65,7 +65,6 @@ int sun_partition(struct parsed_partitions *state)
 	} * label;
 	struct sun_partition *p;
 	unsigned long spc;
-	char b[BDEVNAME_SIZE];
 	int use_vtoc;
 	int nparts;
 
@@ -85,8 +84,8 @@ int sun_partition(struct parsed_partitions *state)
 	for (csum = 0; ush >= ((__be16 *) label);)
 		csum ^= *ush--;
 	if (csum) {
-		printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
-		       bdevname(state->bdev, b));
+		pr_info("Dev %pg Sun disklabel: Csum bad, label corrupted\n",
+			state->bdev);
 		put_dev_sector(sect);
 		return 0;
 	}
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index bd3556585122..765c2d1567ba 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2405,14 +2405,13 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
 static blk_qc_t pkt_submit_bio(struct bio *bio)
 {
 	struct pktcdvd_device *pd;
-	char b[BDEVNAME_SIZE];
 	struct bio *split;
 
 	blk_queue_split(&bio);
 
 	pd = bio->bi_bdev->bd_disk->queue->queuedata;
 	if (!pd) {
-		pr_err("%s incorrect request queue\n", bio_devname(bio, b));
+		pr_err("%pg incorrect request queue\n", bio->bi_bdev);
 		goto end_io;
 	}
 
@@ -2476,11 +2475,10 @@ static int pkt_seq_show(struct seq_file *m, void *p)
 {
 	struct pktcdvd_device *pd = m->private;
 	char *msg;
-	char bdev_buf[BDEVNAME_SIZE];
 	int states[PACKET_NUM_STATES];
 
-	seq_printf(m, "Writer %s mapped to %s:\n", pd->name,
-		   bdevname(pd->bdev, bdev_buf));
+	seq_printf(m, "Writer %s mapped to %pg:\n", pd->name,
+		   pd->bdev);
 
 	seq_printf(m, "\nSettings:\n");
 	seq_printf(m, "\tpacket size:\t\t%dkB\n", pd->settings.size / 2);
@@ -2537,7 +2535,6 @@ static int pkt_seq_show(struct seq_file *m, void *p)
 static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 {
 	int i;
-	char b[BDEVNAME_SIZE];
 	struct block_device *bdev;
 
 	if (pd->pkt_dev == dev) {
@@ -2549,8 +2546,8 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 		if (!pd2)
 			continue;
 		if (pd2->bdev->bd_dev == dev) {
-			pkt_err(pd, "%s already setup\n",
-				bdevname(pd2->bdev, b));
+			pkt_err(pd, "%pg already setup\n",
+				pd2->bdev);
 			return -EBUSY;
 		}
 		if (pd2->pkt_dev == dev) {
@@ -2583,7 +2580,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 	}
 
 	proc_create_single_data(pd->name, 0, pkt_proc, pkt_seq_show, pd);
-	pkt_dbg(1, pd, "writer mapped to %s\n", bdevname(bdev, b));
+	pkt_dbg(1, pd, "writer mapped to %pg\n", bdev);
 	return 0;
 
 out_mem:
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params()
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (4 preceding siblings ...)
  2021-06-02 15:28 ` [PATCH 05/10] block: " Anton Suvorov
@ 2021-06-02 15:28 ` Anton Suvorov
  2021-06-02 15:29 ` [PATCH 07/10] vfs: reduce stack footprint in __blkdev_put() Anton Suvorov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./drivers/target/target_core_iblock.c   iblock_show_configfs_dev_params 192     56      -136

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/target/target_core_iblock.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 44d9d028f716..b3425a5bbac2 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -634,12 +634,11 @@ static ssize_t iblock_show_configfs_dev_params(struct se_device *dev, char *b)
 {
 	struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
 	struct block_device *bd = ib_dev->ibd_bd;
-	char buf[BDEVNAME_SIZE];
 	ssize_t bl = 0;
 
 	if (bd)
-		bl += sprintf(b + bl, "iBlock device: %s",
-				bdevname(bd, buf));
+		bl += sprintf(b + bl, "iBlock device: %pg",
+				bd);
 	if (ib_dev->ibd_flags & IBDF_HAS_UDEV_PATH)
 		bl += sprintf(b + bl, "  UDEV PATH: %s",
 				ib_dev->ibd_udev_path);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 07/10] vfs: reduce stack footprint in __blkdev_put()
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (5 preceding siblings ...)
  2021-06-02 15:28 ` [PATCH 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params() Anton Suvorov
@ 2021-06-02 15:29 ` Anton Suvorov
  2021-06-02 15:29 ` [PATCH 08/10] ext4: reduce stack footprint in ext4_end_bio() Anton Suvorov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./fs/block_dev.c        __blkdev_put    224     80      -144

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 fs/block_dev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6cc4d4cfe0c2..cef3a4aa46dc 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -64,10 +64,8 @@ static void bdev_write_inode(struct block_device *bdev)
 		spin_unlock(&inode->i_lock);
 		ret = write_inode_now(inode, true);
 		if (ret) {
-			char name[BDEVNAME_SIZE];
-			pr_warn_ratelimited("VFS: Dirty inode writeback failed "
-					    "for block device %s (err=%d).\n",
-					    bdevname(bdev, name), ret);
+			pr_warn_ratelimited("VFS: Dirty inode writeback failed for block device %pg (err=%d).\n",
+					    bdev, ret);
 		}
 		spin_lock(&inode->i_lock);
 	}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 08/10] ext4: reduce stack footprint in ext4_end_bio()
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (6 preceding siblings ...)
  2021-06-02 15:29 ` [PATCH 07/10] vfs: reduce stack footprint in __blkdev_put() Anton Suvorov
@ 2021-06-02 15:29 ` Anton Suvorov
  2021-06-02 15:29 ` [PATCH 09/10] security: reduce stack footprint in loadpin_read_file() Anton Suvorov
  2021-06-02 15:29 ` [PATCH 10/10] block: remove unused symbol bio_devname() Anton Suvorov
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./fs/ext4/page-io.c     ext4_end_bio    224     88      -136

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 fs/ext4/page-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index f038d578d8d8..56074f2f5e63 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -323,10 +323,9 @@ static void ext4_end_bio(struct bio *bio)
 {
 	ext4_io_end_t *io_end = bio->bi_private;
 	sector_t bi_sector = bio->bi_iter.bi_sector;
-	char b[BDEVNAME_SIZE];
 
-	if (WARN_ONCE(!io_end, "io_end is NULL: %s: sector %Lu len %u err %d\n",
-		      bio_devname(bio, b),
+	if (WARN_ONCE(!io_end, "io_end is NULL: %pg: sector %llu len %u err %d\n",
+		      bio->bi_bdev,
 		      (long long) bio->bi_iter.bi_sector,
 		      (unsigned) bio_sectors(bio),
 		      bio->bi_status)) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 09/10] security: reduce stack footprint in loadpin_read_file()
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (7 preceding siblings ...)
  2021-06-02 15:29 ` [PATCH 08/10] ext4: reduce stack footprint in ext4_end_bio() Anton Suvorov
@ 2021-06-02 15:29 ` Anton Suvorov
  2021-06-02 15:29 ` [PATCH 10/10] block: remove unused symbol bio_devname() Anton Suvorov
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

Stack usage reduced (measured with allyesconfig):

./security/loadpin/loadpin.c    loadpin_read_file       200     56      -144

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 security/loadpin/loadpin.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index b12f7d986b1e..ad4e6756c038 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -78,11 +78,8 @@ static void check_pinning_enforcement(struct super_block *mnt_sb)
 	 * device, allow sysctl to change modes for testing.
 	 */
 	if (mnt_sb->s_bdev) {
-		char bdev[BDEVNAME_SIZE];
-
 		ro = bdev_read_only(mnt_sb->s_bdev);
-		bdevname(mnt_sb->s_bdev, bdev);
-		pr_info("%s (%u:%u): %s\n", bdev,
+		pr_info("%pg (%u:%u): %s\n", mnt_sb->s_bdev,
 			MAJOR(mnt_sb->s_bdev->bd_dev),
 			MINOR(mnt_sb->s_bdev->bd_dev),
 			ro ? "read-only" : "writable");
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 10/10] block: remove unused symbol bio_devname()
  2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
                   ` (8 preceding siblings ...)
  2021-06-02 15:29 ` [PATCH 09/10] security: reduce stack footprint in loadpin_read_file() Anton Suvorov
@ 2021-06-02 15:29 ` Anton Suvorov
  9 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-02 15:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: warwish, linux-fsdevel, dmtrmonakhov, linux-block, viro

This patch removes not used any more bio_devname() symbol.
It should be only applied after all other patches in the series applied.

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 block/bio.c         | 6 ------
 include/linux/bio.h | 2 --
 2 files changed, 8 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 44205dfb6b60..8674f9a4e527 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -684,12 +684,6 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
 }
 EXPORT_SYMBOL(bio_clone_fast);
 
-const char *bio_devname(struct bio *bio, char *buf)
-{
-	return bdevname(bio->bi_bdev, buf);
-}
-EXPORT_SYMBOL(bio_devname);
-
 static inline bool page_is_mergeable(const struct bio_vec *bv,
 		struct page *page, unsigned int len, unsigned int off,
 		bool *same_page)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index a0b4cfdf62a4..d20e658ff16b 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -488,8 +488,6 @@ void bio_truncate(struct bio *bio, unsigned new_size);
 void guard_bio_eod(struct bio *bio);
 void zero_fill_bio(struct bio *bio);
 
-extern const char *bio_devname(struct bio *bio, char *buffer);
-
 #define bio_set_dev(bio, bdev) 				\
 do {							\
 	bio_clear_flag(bio, BIO_REMAPPED);		\
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 02/10] dax: reduce stack footprint dealing with block device names
  2021-06-02 15:28 ` [PATCH 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
@ 2021-06-02 17:18   ` Matthew Wilcox
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
  2021-06-22 17:45     ` [PATCH v2 10/10] block: remove unused symbol bio_devname() Anton Suvorov
  0 siblings, 2 replies; 26+ messages in thread
From: Matthew Wilcox @ 2021-06-02 17:18 UTC (permalink / raw)
  To: Anton Suvorov
  Cc: linux-kernel, linux-fsdevel, dmtrmonakhov, linux-block, viro

On Wed, Jun 02, 2021 at 06:28:55PM +0300, Anton Suvorov wrote:
> @@ -81,29 +80,29 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
>  	int err, id;
>  
>  	if (blocksize != PAGE_SIZE) {
> -		pr_info("%s: error: unsupported blocksize for dax\n",
> -				bdevname(bdev, buf));
> +		pr_info("%pg: error: unsupported blocksize for dax\n",
> +			bdev);

You can combine these onto one line without passing 80 columns:

		pr_info("%pg: error: unsupported blocksize for dax\n", bdev);

(many other examples of this)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 00/10] reduce stack footprint printing bdev names
  2021-06-02 17:18   ` Matthew Wilcox
@ 2021-06-22 17:44     ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
                         ` (8 more replies)
  2021-06-22 17:45     ` [PATCH v2 10/10] block: remove unused symbol bio_devname() Anton Suvorov
  1 sibling, 9 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Changes from v1:
Updated formatting according to Matthew Wilcox <willy@infradead.org> advice.
Some lines may be longer than preferred 80 characters (even 100 in some cases),
but they still remain easily readable (and could be found via grep).

The patchset shows significant reduce of stack footprint:

	./block/blk-core.c	submit_bio_checks	248	112	-136
	./block/blk-lib.c	__blkdev_issue_discard	240	104	-136
	./block/blk-settings.c	disk_stack_limits	256	192	-64
	./block/partitions/amiga.c	amiga_partition	424	368	-56
	./block/partitions/sgi.c	sgi_partition	352	288	-64
	./block/partitions/sun.c	sun_partition	392	328	-64
	./drivers/block/drbd/drbd_req.c	drbd_report_io_error	200	72	-128
	./drivers/block/pktcdvd.c	pkt_seq_show	288	224	-64
	./drivers/block/pktcdvd.c	pkt_setup_dev	272	136	-136
	./drivers/block/pktcdvd.c	pkt_submit_bio	288	224	-64
	./drivers/dax/super.c	__bdev_dax_supported	192	56	-136
	./drivers/dax/super.c	__generic_fsdax_supported	344	280	-64
	./drivers/md/dm-cache-target.c	cache_ctr	392	328	-64
	./drivers/md/dm-cache-target.c	cache_io_hints	208	72	-136
	./drivers/md/dm-clone-target.c	clone_ctr	416	352	-64
	./drivers/md/dm-clone-target.c	clone_io_hints	216	80	-136
	./drivers/md/dm-crypt.c	crypt_convert_block_aead	408	272	-136
	./drivers/md/dm-crypt.c	kcryptd_async_done	192	56	-136
	./drivers/md/dm-integrity.c	integrity_metadata	872	808	-64
	./drivers/md/dm-mpath.c	parse_priority_group	368	304	-64
	./drivers/md/dm-table.c	device_area_is_invalid	208	72	-136
	./drivers/md/dm-table.c	dm_set_device_limits	200	72	-128
	./drivers/md/dm-thin.c	pool_io_hints	216	80	-136
	./drivers/md/md-linear.c	linear_make_request	248	112	-136
	./drivers/md/md-multipath.c	multipath_end_request	232	96	-136
	./drivers/md/md-multipath.c	multipath_error	208	72	-136
	./drivers/md/md-multipath.c	multipathd	248	112	-136
	./drivers/md/md-multipath.c	print_multipath_conf	208	64	-144
	./drivers/md/md.c	autorun_devices	312	184	-128
	./drivers/md/md.c	export_rdev	168	32	-136
	./drivers/md/md.c	md_add_new_disk	280	80	-200
	./drivers/md/md.c	md_import_device	200	56	-144
	./drivers/md/md.c	md_integrity_add_rdev	192	56	-136
	./drivers/md/md.c	md_ioctl	560	496	-64
	./drivers/md/md.c	md_reload_sb	224	88	-136
	./drivers/md/md.c	md_run	416	296	-120
	./drivers/md/md.c	md_seq_show	232	96	-136
	./drivers/md/md.c	md_update_sb	304	168	-136
	./drivers/md/md.c	read_disk_sb	184	48	-136
	./drivers/md/md.c	super_1_load	392	192	-200
	./drivers/md/md.c	super_90_load	304	112	-192
	./drivers/md/md.c	unbind_rdev_from_array	200	64	-136
	./drivers/md/raid0.c	create_strip_zones	400	200	-200
	./drivers/md/raid0.c	dump_zones	536	464	-72
	./drivers/md/raid1.c	fix_read_error	352	288	-64
	./drivers/md/raid1.c	print_conf	224	80	-144
	./drivers/md/raid1.c	raid1_end_read_request	216	80	-136
	./drivers/md/raid1.c	raid1_error	216	96	-120
	./drivers/md/raid1.c	sync_request_write	336	200	-136
	./drivers/md/raid10.c	fix_read_error	384	312	-72
	./drivers/md/raid10.c	print_conf	216	72	-144
	./drivers/md/raid10.c	raid10_end_read_request	216	80	-136
	./drivers/md/raid10.c	raid10_error	216	80	-136
	./drivers/md/raid5-cache.c	r5l_init_log	224	88	-136
	./drivers/md/raid5-ppl.c	ppl_do_flush	256	136	-120
	./drivers/md/raid5-ppl.c	ppl_flush_endio	192	56	-136
	./drivers/md/raid5-ppl.c	ppl_modify_log	192	56	-136
	./drivers/md/raid5-ppl.c	ppl_recover_entry	1296	1232	-64
	./drivers/md/raid5-ppl.c	ppl_submit_iounit_bio	192	56	-136
	./drivers/md/raid5-ppl.c	ppl_validate_rdev	184	48	-136
	./drivers/md/raid5.c	print_raid5_conf	208	64	-144
	./drivers/md/raid5.c	raid5_end_read_request	272	128	-144
	./drivers/md/raid5.c	raid5_error	216	80	-136
	./drivers/md/raid5.c	setup_conf	360	296	-64
	./drivers/target/target_core_iblock.c	iblock_show_configfs_dev_params	192	56	-136
	./fs/block_dev.c	blkdev_flush_mapping	200	56	-144
	./fs/ext4/page-io.c	ext4_end_bio	224	88	-136
	./security/loadpin/loadpin.c	loadpin_read_file	200	56	-144

Patchset was tested with kvm-xfstests -c 4k full using
https://github.com/tytso/xfstests-bld/blob/master/kernel-configs/x86_64-config-5.10
kernel config:
	-------------------- Summary report
	KERNEL:    kernel 5.13.0-rc6-next-20210618-xfstests-00010-g225cff5e67be #12 SMP Sat Jun 19 00:13:37 MSK 2021 x86_64
	CMDLINE:   -c 4k full
	CPUS:      2
	MEM:       1960.88
	
	ext4/4k: 537 tests, 45 skipped, 5381 seconds
	Totals: 492 tests, 45 skipped, 0 failures, 0 errors, 5327s
	
	FSTESTVER: blktests 4bc88ef (Sun, 7 Mar 2021 12:38:37 -0800)
	FSTESTVER: fio  fio-3.26 (Mon, 8 Mar 2021 17:44:38 -0700)
	FSTESTVER: fsverity v1.3-2-gcf8fa5e (Wed, 24 Feb 2021 13:32:36 -0800)
	FSTESTVER: ima-evm-utils v1.3.2 (Wed, 28 Oct 2020 13:18:08 -0400)
	FSTESTVER: nvme-cli v1.13 (Tue, 20 Oct 2020 16:50:31 -0700)
	FSTESTVER: quota  v4.05-40-g25f16b1 (Tue, 16 Mar 2021 17:57:19 +0100)
	FSTESTVER: util-linux v2.36.2 (Fri, 12 Feb 2021 14:59:56 +0100)
	FSTESTVER: xfsprogs v5.11.0 (Fri, 12 Mar 2021 15:05:13 -0500)
	FSTESTVER: xfstests linux-v3.8-3068-g4072b9d3 (Mon, 5 Apr 2021 15:44:33 -0400)
	FSTESTVER: xfstests-bld 4ec07f9 (Mon, 12 Apr 2021 23:49:18 -0400)
	FSTESTCFG: 4k
	FSTESTSET: -g auto
	FSTESTOPT: aex

Anton Suvorov (10):
  drbd: reduce stack footprint in drbd_report_io_error()
  dax: reduce stack footprint dealing with block device names
  raid-md: reduce stack footprint dealing with block device names
  dm: reduce stack footprint dealing with block device names
  block: reduce stack footprint dealing with block device names
  target: reduce stack footprint in iblock_show_configfs_dev_params()
  vfs: reduce stack footprint in __blkdev_put()
  ext4: reduce stack footprint in ext4_end_bio()
  security: reduce stack footprint in loadpin_read_file()
  block: remove unused symbol bio_devname()

 block/bio.c                         |   6 --
 block/blk-core.c                    |  12 +--
 block/blk-lib.c                     |   5 +-
 block/blk-settings.c                |   7 +-
 block/partitions/amiga.c            |  10 +--
 block/partitions/sgi.c              |   4 +-
 block/partitions/sun.c              |   4 +-
 drivers/block/drbd/drbd_req.c       |  12 ++-
 drivers/block/pktcdvd.c             |  13 +--
 drivers/dax/super.c                 |  27 ++----
 drivers/md/dm-cache-target.c        |  10 +--
 drivers/md/dm-clone-target.c        |  10 +--
 drivers/md/dm-crypt.c               |   6 +-
 drivers/md/dm-integrity.c           |   4 +-
 drivers/md/dm-mpath.c               |   5 +-
 drivers/md/dm-table.c               |  34 ++++---
 drivers/md/dm-thin.c                |   8 +-
 drivers/md/md-linear.c              |   5 +-
 drivers/md/md-multipath.c           |  24 +++--
 drivers/md/md.c                     | 135 +++++++++++-----------------
 drivers/md/raid0.c                  |  28 +++---
 drivers/md/raid1.c                  |  25 +++---
 drivers/md/raid10.c                 |  65 ++++++--------
 drivers/md/raid5-cache.c            |   5 +-
 drivers/md/raid5-ppl.c              |  40 ++++-----
 drivers/md/raid5.c                  |  39 ++++----
 drivers/target/target_core_iblock.c |   4 +-
 fs/block_dev.c                      |   6 +-
 fs/ext4/page-io.c                   |   5 +-
 include/linux/bio.h                 |   2 -
 security/loadpin/loadpin.c          |   5 +-
 31 files changed, 212 insertions(+), 353 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 01/10] drbd: reduce stack footprint in drbd_report_io_error()
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
                         ` (7 subsequent siblings)
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./drivers/block/drbd/drbd_req.c drbd_report_io_error    200     72      -128

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/block/drbd/drbd_req.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 13beb98a7c5a..bd7265edf614 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -510,16 +510,14 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
 
 static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req)
 {
-        char b[BDEVNAME_SIZE];
-
 	if (!__ratelimit(&drbd_ratelimit_state))
 		return;
 
-	drbd_warn(device, "local %s IO error sector %llu+%u on %s\n",
-			(req->rq_state & RQ_WRITE) ? "WRITE" : "READ",
-			(unsigned long long)req->i.sector,
-			req->i.size >> 9,
-			bdevname(device->ldev->backing_bdev, b));
+	drbd_warn(device, "local %s IO error sector %llu+%u on %pg\n",
+		  (req->rq_state & RQ_WRITE) ? "WRITE" : "READ",
+		  (unsigned long long)req->i.sector,
+		  req->i.size >> 9,
+		  device->ldev->backing_bdev);
 }
 
 /* Helper for HANDED_OVER_TO_NETWORK.
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 02/10] dax: reduce stack footprint dealing with block device names
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 03/10] raid-md: " Anton Suvorov
                         ` (6 subsequent siblings)
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./drivers/dax/super.c   __bdev_dax_supported    192     56      -136
./drivers/dax/super.c   __generic_fsdax_supported       344     280     -64

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/dax/super.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 5fa6ae9dbc8b..f519e59abf02 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -73,7 +73,6 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 {
 	bool dax_enabled = false;
 	pgoff_t pgoff, pgoff_end;
-	char buf[BDEVNAME_SIZE];
 	void *kaddr, *end_kaddr;
 	pfn_t pfn, end_pfn;
 	sector_t last_page;
@@ -81,29 +80,25 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 	int err, id;
 
 	if (blocksize != PAGE_SIZE) {
-		pr_info("%s: error: unsupported blocksize for dax\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: unsupported blocksize for dax\n", bdev);
 		return false;
 	}
 
 	if (!dax_dev) {
-		pr_debug("%s: error: dax unsupported by block device\n",
-				bdevname(bdev, buf));
+		pr_debug("%pg: error: dax unsupported by block device\n", bdev);
 		return false;
 	}
 
 	err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff);
 	if (err) {
-		pr_info("%s: error: unaligned partition for dax\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: unaligned partition for dax\n", bdev);
 		return false;
 	}
 
 	last_page = PFN_DOWN((start + sectors - 1) * 512) * PAGE_SIZE / 512;
 	err = bdev_dax_pgoff(bdev, last_page, PAGE_SIZE, &pgoff_end);
 	if (err) {
-		pr_info("%s: error: unaligned partition for dax\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: unaligned partition for dax\n", bdev);
 		return false;
 	}
 
@@ -112,8 +107,8 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 	len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn);
 
 	if (len < 1 || len2 < 1) {
-		pr_info("%s: error: dax access failed (%ld)\n",
-				bdevname(bdev, buf), len < 1 ? len : len2);
+		pr_info("%pg: error: dax access failed (%ld)\n",
+			bdev, len < 1 ? len : len2);
 		dax_read_unlock(id);
 		return false;
 	}
@@ -147,8 +142,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 	dax_read_unlock(id);
 
 	if (!dax_enabled) {
-		pr_info("%s: error: dax support not enabled\n",
-				bdevname(bdev, buf));
+		pr_info("%pg: error: dax support not enabled\n", bdev);
 		return false;
 	}
 	return true;
@@ -169,21 +163,18 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
 {
 	struct dax_device *dax_dev;
 	struct request_queue *q;
-	char buf[BDEVNAME_SIZE];
 	bool ret;
 	int id;
 
 	q = bdev_get_queue(bdev);
 	if (!q || !blk_queue_dax(q)) {
-		pr_debug("%s: error: request queue doesn't support dax\n",
-				bdevname(bdev, buf));
+		pr_debug("%pg: error: request queue doesn't support dax\n", bdev);
 		return false;
 	}
 
 	dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
 	if (!dax_dev) {
-		pr_debug("%s: error: device does not support dax\n",
-				bdevname(bdev, buf));
+		pr_debug("%pg: error: device does not support dax\n", bdev);
 		return false;
 	}
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 03/10] raid-md: reduce stack footprint dealing with block device names
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-23  8:26         ` Guoqing Jiang
  2021-06-22 17:44       ` [PATCH v2 04/10] dm: " Anton Suvorov
                         ` (5 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./drivers/md/md-linear.c	linear_make_request	248	112	-136
./drivers/md/md-multipath.c	multipath_end_request	232	96	-136
./drivers/md/md-multipath.c	multipath_error	208	72	-136
./drivers/md/md-multipath.c	multipathd	248	112	-136
./drivers/md/md-multipath.c	print_multipath_conf	208	64	-144
./drivers/md/md.c	autorun_devices	312	184	-128
./drivers/md/md.c	export_rdev	168	32	-136
./drivers/md/md.c	md_add_new_disk	280	80	-200
./drivers/md/md.c	md_import_device	200	56	-144
./drivers/md/md.c	md_integrity_add_rdev	192	56	-136
./drivers/md/md.c	md_ioctl	560	496	-64
./drivers/md/md.c	md_reload_sb	224	88	-136
./drivers/md/md.c	md_run	408	288	-120
./drivers/md/md.c	md_seq_show	232	96	-136
./drivers/md/md.c	md_update_sb	304	168	-136
./drivers/md/md.c	read_disk_sb	184	48	-136
./drivers/md/md.c	super_1_load	392	192	-200
./drivers/md/md.c	super_90_load	304	112	-192
./drivers/md/md.c	unbind_rdev_from_array	200	64	-136
./drivers/md/raid0.c	create_strip_zones	400	200	-200
./drivers/md/raid0.c	dump_zones	536	464	-72
./drivers/md/raid1.c	fix_read_error	352	288	-64
./drivers/md/raid1.c	print_conf	224	80	-144
./drivers/md/raid1.c	raid1_end_read_request	216	80	-136
./drivers/md/raid1.c	raid1_error	216	96	-120
./drivers/md/raid1.c	sync_request_write	344	208	-136
./drivers/md/raid10.c	fix_read_error	392	320	-72
./drivers/md/raid10.c	print_conf	216	72	-144
./drivers/md/raid10.c	raid10_end_read_request	216	80	-136
./drivers/md/raid10.c	raid10_error	216	80	-136
./drivers/md/raid5-cache.c	r5l_init_log	224	88	-136
./drivers/md/raid5-ppl.c	ppl_do_flush	256	136	-120
./drivers/md/raid5-ppl.c	ppl_flush_endio	192	56	-136
./drivers/md/raid5-ppl.c	ppl_modify_log	192	56	-136
./drivers/md/raid5-ppl.c	ppl_recover_entry	1296	1232	-64
./drivers/md/raid5-ppl.c	ppl_submit_iounit_bio	192	56	-136
./drivers/md/raid5-ppl.c	ppl_validate_rdev	184	48	-136
./drivers/md/raid5.c	print_raid5_conf	208	64	-144
./drivers/md/raid5.c	raid5_end_read_request	272	128	-144
./drivers/md/raid5.c	raid5_error	216	80	-136
./drivers/md/raid5.c	setup_conf	360	296	-64

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/md/md-linear.c    |   5 +-
 drivers/md/md-multipath.c |  24 +++----
 drivers/md/md.c           | 135 ++++++++++++++------------------------
 drivers/md/raid0.c        |  28 ++++----
 drivers/md/raid1.c        |  25 +++----
 drivers/md/raid10.c       |  65 ++++++++----------
 drivers/md/raid5-cache.c  |   5 +-
 drivers/md/raid5-ppl.c    |  40 +++++------
 drivers/md/raid5.c        |  39 +++++------
 9 files changed, 144 insertions(+), 222 deletions(-)

diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index 1ff51647a682..40bdc6aecd0b 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -215,7 +215,6 @@ static void linear_free(struct mddev *mddev, void *priv)
 
 static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 {
-	char b[BDEVNAME_SIZE];
 	struct dev_info *tmp_dev;
 	sector_t start_sector, end_sector, data_offset;
 	sector_t bio_sector = bio->bi_iter.bi_sector;
@@ -266,10 +265,10 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
 	return true;
 
 out_of_bounds:
-	pr_err("md/linear:%s: make_request: Sector %llu out of bounds on dev %s: %llu sectors, offset %llu\n",
+	pr_err("md/linear:%s: make_request: Sector %llu out of bounds on dev %pg: %llu sectors, offset %llu\n",
 	       mdname(mddev),
 	       (unsigned long long)bio->bi_iter.bi_sector,
-	       bdevname(tmp_dev->rdev->bdev, b),
+	       tmp_dev->rdev->bdev,
 	       (unsigned long long)tmp_dev->rdev->sectors,
 	       (unsigned long long)start_sector);
 	bio_io_error(bio);
diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c
index e7d6486f090f..e2141cd76838 100644
--- a/drivers/md/md-multipath.c
+++ b/drivers/md/md-multipath.c
@@ -87,10 +87,9 @@ static void multipath_end_request(struct bio *bio)
 		/*
 		 * oops, IO error:
 		 */
-		char b[BDEVNAME_SIZE];
 		md_error (mp_bh->mddev, rdev);
-		pr_info("multipath: %s: rescheduling sector %llu\n",
-			bdevname(rdev->bdev,b),
+		pr_info("multipath: %pg: rescheduling sector %llu\n",
+			rdev->bdev,
 			(unsigned long long)bio->bi_iter.bi_sector);
 		multipath_reschedule_retry(mp_bh);
 	} else
@@ -157,7 +156,6 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
 static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
 {
 	struct mpconf *conf = mddev->private;
-	char b[BDEVNAME_SIZE];
 
 	if (conf->raid_disks - mddev->degraded <= 1) {
 		/*
@@ -180,9 +178,9 @@ static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
 	}
 	set_bit(Faulty, &rdev->flags);
 	set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
-	pr_err("multipath: IO failure on %s, disabling IO path.\n"
+	pr_err("multipath: IO failure on %pg, disabling IO path.\n"
 	       "multipath: Operation continuing on %d IO paths.\n",
-	       bdevname(rdev->bdev, b),
+	       rdev->bdev,
 	       conf->raid_disks - mddev->degraded);
 }
 
@@ -200,12 +198,11 @@ static void print_multipath_conf (struct mpconf *conf)
 		 conf->raid_disks);
 
 	for (i = 0; i < conf->raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		tmp = conf->multipaths + i;
 		if (tmp->rdev)
-			pr_debug(" disk%d, o:%d, dev:%s\n",
+			pr_debug(" disk%d, o:%d, dev:%pg\n",
 				 i,!test_bit(Faulty, &tmp->rdev->flags),
-				 bdevname(tmp->rdev->bdev,b));
+				 tmp->rdev->bdev);
 	}
 }
 
@@ -299,7 +296,6 @@ static void multipathd(struct md_thread *thread)
 
 	md_check_recovery(mddev);
 	for (;;) {
-		char b[BDEVNAME_SIZE];
 		spin_lock_irqsave(&conf->device_lock, flags);
 		if (list_empty(head))
 			break;
@@ -311,13 +307,13 @@ static void multipathd(struct md_thread *thread)
 		bio->bi_iter.bi_sector = mp_bh->master_bio->bi_iter.bi_sector;
 
 		if ((mp_bh->path = multipath_map (conf))<0) {
-			pr_err("multipath: %s: unrecoverable IO read error for block %llu\n",
-			       bio_devname(bio, b),
+			pr_err("multipath: %pg: unrecoverable IO read error for block %llu\n",
+			       bio->bi_bdev,
 			       (unsigned long long)bio->bi_iter.bi_sector);
 			multipath_end_bh_io(mp_bh, BLK_STS_IOERR);
 		} else {
-			pr_err("multipath: %s: redirecting sector %llu to another IO path\n",
-			       bio_devname(bio, b),
+			pr_err("multipath: %pg: redirecting sector %llu to another IO path\n",
+			       bio->bi_bdev,
 			       (unsigned long long)bio->bi_iter.bi_sector);
 			*bio = *(mp_bh->master_bio);
 			bio->bi_iter.bi_sector +=
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ae8fe54ea358..5bfc0a55e28c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1018,8 +1018,6 @@ EXPORT_SYMBOL_GPL(sync_page_io);
 
 static int read_disk_sb(struct md_rdev *rdev, int size)
 {
-	char b[BDEVNAME_SIZE];
-
 	if (rdev->sb_loaded)
 		return 0;
 
@@ -1029,8 +1027,7 @@ static int read_disk_sb(struct md_rdev *rdev, int size)
 	return 0;
 
 fail:
-	pr_err("md: disabled device %s, could not read superblock.\n",
-	       bdevname(rdev->bdev,b));
+	pr_err("md: disabled device %pg, could not read superblock.\n", rdev->bdev);
 	return -EINVAL;
 }
 
@@ -1176,7 +1173,6 @@ EXPORT_SYMBOL(md_check_no_bitmap);
  */
 static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_version)
 {
-	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 	mdp_super_t *sb;
 	int ret;
 	bool spare_disk = true;
@@ -1195,19 +1191,18 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 
 	ret = -EINVAL;
 
-	bdevname(rdev->bdev, b);
 	sb = page_address(rdev->sb_page);
 
 	if (sb->md_magic != MD_SB_MAGIC) {
-		pr_warn("md: invalid raid superblock magic on %s\n", b);
+		pr_warn("md: invalid raid superblock magic on %pg\n", rdev->bdev);
 		goto abort;
 	}
 
 	if (sb->major_version != 0 ||
 	    sb->minor_version < 90 ||
 	    sb->minor_version > 91) {
-		pr_warn("Bad version number %d.%d on %s\n",
-			sb->major_version, sb->minor_version, b);
+		pr_warn("Bad version number %d.%d on %pg\n",
+			sb->major_version, sb->minor_version, rdev->bdev);
 		goto abort;
 	}
 
@@ -1215,7 +1210,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 		goto abort;
 
 	if (md_csum_fold(calc_sb_csum(sb)) != md_csum_fold(sb->sb_csum)) {
-		pr_warn("md: invalid superblock checksum on %s\n", b);
+		pr_warn("md: invalid superblock checksum on %pg\n", rdev->bdev);
 		goto abort;
 	}
 
@@ -1247,13 +1242,13 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
 		__u64 ev1, ev2;
 		mdp_super_t *refsb = page_address(refdev->sb_page);
 		if (!md_uuid_equal(refsb, sb)) {
-			pr_warn("md: %s has different UUID to %s\n",
-				b, bdevname(refdev->bdev,b2));
+			pr_warn("md: %pg has different UUID to %pg\n",
+				rdev->bdev, refdev->bdev);
 			goto abort;
 		}
 		if (!md_sb_equal(refsb, sb)) {
-			pr_warn("md: %s has same UUID but different superblock to %s\n",
-				b, bdevname(refdev->bdev, b2));
+			pr_warn("md: %pg has same UUID but different superblock to %pg\n",
+				rdev->bdev, refdev->bdev);
 			goto abort;
 		}
 		ev1 = md_event(sb);
@@ -1617,7 +1612,6 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 	int ret;
 	sector_t sb_start;
 	sector_t sectors;
-	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 	int bmask;
 	bool spare_disk = true;
 
@@ -1662,13 +1656,11 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 		return -EINVAL;
 
 	if (calc_sb_1_csum(sb) != sb->sb_csum) {
-		pr_warn("md: invalid superblock checksum on %s\n",
-			bdevname(rdev->bdev,b));
+		pr_warn("md: invalid superblock checksum on %pg\n", rdev->bdev);
 		return -EINVAL;
 	}
 	if (le64_to_cpu(sb->data_size) < 10) {
-		pr_warn("md: data_size too small on %s\n",
-			bdevname(rdev->bdev,b));
+		pr_warn("md: data_size too small on %pg\n", rdev->bdev);
 		return -EINVAL;
 	}
 	if (sb->pad0 ||
@@ -1774,9 +1766,9 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
 		    sb->level != refsb->level ||
 		    sb->layout != refsb->layout ||
 		    sb->chunksize != refsb->chunksize) {
-			pr_warn("md: %s has strangely different superblock to %s\n",
-				bdevname(rdev->bdev,b),
-				bdevname(refdev->bdev,b2));
+			pr_warn("md: %pg has strangely different superblock to %pg\n",
+				rdev->bdev,
+				refdev->bdev);
 			return -EINVAL;
 		}
 		ev1 = le64_to_cpu(sb->events);
@@ -2364,7 +2356,6 @@ EXPORT_SYMBOL(md_integrity_register);
 int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev)
 {
 	struct blk_integrity *bi_mddev;
-	char name[BDEVNAME_SIZE];
 
 	if (!mddev->gendisk)
 		return 0;
@@ -2375,8 +2366,8 @@ int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev)
 		return 0;
 
 	if (blk_integrity_compare(mddev->gendisk, rdev->bdev->bd_disk) != 0) {
-		pr_err("%s: incompatible integrity profile for %s\n",
-		       mdname(mddev), bdevname(rdev->bdev, name));
+		pr_err("%s: incompatible integrity profile for %pg\n",
+		       mdname(mddev), rdev->bdev);
 		return -ENXIO;
 	}
 
@@ -2485,11 +2476,9 @@ static void rdev_delayed_delete(struct work_struct *ws)
 
 static void unbind_rdev_from_array(struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
-
 	bd_unlink_disk_holder(rdev->bdev, rdev->mddev->gendisk);
 	list_del_rcu(&rdev->same_set);
-	pr_debug("md: unbind<%s>\n", bdevname(rdev->bdev,b));
+	pr_debug("md: unbind<%pg>\n", rdev->bdev);
 	mddev_destroy_serial_pool(rdev->mddev, rdev, false);
 	rdev->mddev = NULL;
 	sysfs_remove_link(&rdev->kobj, "block");
@@ -2542,9 +2531,7 @@ void md_autodetect_dev(dev_t dev);
 
 static void export_rdev(struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
-
-	pr_debug("md: export_rdev(%s)\n", bdevname(rdev->bdev,b));
+	pr_debug("md: export_rdev(%pg)\n", rdev->bdev);
 	md_rdev_clear(rdev);
 #ifndef MODULE
 	if (test_bit(AutoDetected, &rdev->flags))
@@ -2800,8 +2787,6 @@ void md_update_sb(struct mddev *mddev, int force_change)
 rewrite:
 	md_bitmap_update_sb(mddev->bitmap);
 	rdev_for_each(rdev, mddev) {
-		char b[BDEVNAME_SIZE];
-
 		if (rdev->sb_loaded != 1)
 			continue; /* no noise on spare devices */
 
@@ -2809,8 +2794,8 @@ void md_update_sb(struct mddev *mddev, int force_change)
 			md_super_write(mddev,rdev,
 				       rdev->sb_start, rdev->sb_size,
 				       rdev->sb_page);
-			pr_debug("md: (write) %s's sb offset: %llu\n",
-				 bdevname(rdev->bdev, b),
+			pr_debug("md: (write) %pg's sb offset: %llu\n",
+				 rdev->bdev,
 				 (unsigned long long)rdev->sb_start);
 			rdev->sb_events = mddev->events;
 			if (rdev->badblocks.size) {
@@ -2822,8 +2807,7 @@ void md_update_sb(struct mddev *mddev, int force_change)
 			}
 
 		} else
-			pr_debug("md: %s (skipping faulty)\n",
-				 bdevname(rdev->bdev, b));
+			pr_debug("md: %pg (skipping faulty)\n", rdev->bdev);
 
 		if (mddev->level == LEVEL_MULTIPATH)
 			/* only need to write one superblock... */
@@ -3687,7 +3671,6 @@ EXPORT_SYMBOL_GPL(md_rdev_init);
  */
 static struct md_rdev *md_import_device(dev_t newdev, int super_format, int super_minor)
 {
-	char b[BDEVNAME_SIZE];
 	int err;
 	struct md_rdev *rdev;
 	sector_t size;
@@ -3711,8 +3694,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
 
 	size = i_size_read(rdev->bdev->bd_inode) >> BLOCK_SIZE_BITS;
 	if (!size) {
-		pr_warn("md: %s has zero or unknown size, marking faulty!\n",
-			bdevname(rdev->bdev,b));
+		pr_warn("md: %pg has zero or unknown size, marking faulty!\n", rdev->bdev);
 		err = -EINVAL;
 		goto abort_free;
 	}
@@ -3721,14 +3703,13 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
 		err = super_types[super_format].
 			load_super(rdev, NULL, super_minor);
 		if (err == -EINVAL) {
-			pr_warn("md: %s does not have a valid v%d.%d superblock, not importing!\n",
-				bdevname(rdev->bdev,b),
+			pr_warn("md: %pg does not have a valid v%d.%d superblock, not importing!\n",
+				rdev->bdev,
 				super_format, super_minor);
 			goto abort_free;
 		}
 		if (err < 0) {
-			pr_warn("md: could not read %s's sb, not importing!\n",
-				bdevname(rdev->bdev,b));
+			pr_warn("md: could not read %pg's sb, not importing!\n", rdev->bdev);
 			goto abort_free;
 		}
 	}
@@ -3751,7 +3732,6 @@ static int analyze_sbs(struct mddev *mddev)
 {
 	int i;
 	struct md_rdev *rdev, *freshest, *tmp;
-	char b[BDEVNAME_SIZE];
 
 	freshest = NULL;
 	rdev_for_each_safe(rdev, tmp, mddev)
@@ -3763,8 +3743,8 @@ static int analyze_sbs(struct mddev *mddev)
 		case 0:
 			break;
 		default:
-			pr_warn("md: fatal superblock inconsistency in %s -- removing from array\n",
-				bdevname(rdev->bdev,b));
+			pr_warn("md: fatal superblock inconsistency in %pg -- removing from array\n",
+				rdev->bdev);
 			md_kick_rdev_from_array(rdev);
 		}
 
@@ -3782,8 +3762,8 @@ static int analyze_sbs(struct mddev *mddev)
 		if (mddev->max_disks &&
 		    (rdev->desc_nr >= mddev->max_disks ||
 		     i > mddev->max_disks)) {
-			pr_warn("md: %s: %s: only %d devices permitted\n",
-				mdname(mddev), bdevname(rdev->bdev, b),
+			pr_warn("md: %s: %pg: only %d devices permitted\n",
+				mdname(mddev), rdev->bdev,
 				mddev->max_disks);
 			md_kick_rdev_from_array(rdev);
 			continue;
@@ -3791,8 +3771,7 @@ static int analyze_sbs(struct mddev *mddev)
 		if (rdev != freshest) {
 			if (super_types[mddev->major_version].
 			    validate_super(mddev, rdev)) {
-				pr_warn("md: kicking non-fresh %s from array!\n",
-					bdevname(rdev->bdev,b));
+				pr_warn("md: kicking non-fresh %pg from array!\n", rdev->bdev);
 				md_kick_rdev_from_array(rdev);
 				continue;
 			}
@@ -5907,7 +5886,6 @@ int md_run(struct mddev *mddev)
 		/* Warn if this is a potentially silly
 		 * configuration.
 		 */
-		char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 		struct md_rdev *rdev2;
 		int warned = 0;
 
@@ -5916,10 +5894,10 @@ int md_run(struct mddev *mddev)
 				if (rdev < rdev2 &&
 				    rdev->bdev->bd_disk ==
 				    rdev2->bdev->bd_disk) {
-					pr_warn("%s: WARNING: %s appears to be on the same physical disk as %s.\n",
+					pr_warn("%s: WARNING: %pg appears to be on the same physical disk as %pg.\n",
 						mdname(mddev),
-						bdevname(rdev->bdev,b),
-						bdevname(rdev2->bdev,b2));
+						rdev->bdev,
+						rdev2->bdev);
 					warned = 1;
 				}
 			}
@@ -6446,8 +6424,7 @@ static void autorun_array(struct mddev *mddev)
 	pr_info("md: running: ");
 
 	rdev_for_each(rdev, mddev) {
-		char b[BDEVNAME_SIZE];
-		pr_cont("<%s>", bdevname(rdev->bdev,b));
+		pr_cont("<%pg>", rdev->bdev);
 	}
 	pr_cont("\n");
 
@@ -6474,7 +6451,6 @@ static void autorun_devices(int part)
 {
 	struct md_rdev *rdev0, *rdev, *tmp;
 	struct mddev *mddev;
-	char b[BDEVNAME_SIZE];
 
 	pr_info("md: autorun ...\n");
 	while (!list_empty(&pending_raid_disks)) {
@@ -6484,12 +6460,11 @@ static void autorun_devices(int part)
 		rdev0 = list_entry(pending_raid_disks.next,
 					 struct md_rdev, same_set);
 
-		pr_debug("md: considering %s ...\n", bdevname(rdev0->bdev,b));
+		pr_debug("md: considering %pg ...\n", rdev0->bdev);
 		INIT_LIST_HEAD(&candidates);
 		rdev_for_each_list(rdev, tmp, &pending_raid_disks)
 			if (super_90_load(rdev, rdev0, 0) >= 0) {
-				pr_debug("md:  adding %s ...\n",
-					 bdevname(rdev->bdev,b));
+				pr_debug("md:  adding %pg ...\n", rdev->bdev);
 				list_move(&rdev->same_set, &candidates);
 			}
 		/*
@@ -6506,8 +6481,8 @@ static void autorun_devices(int part)
 			unit = MINOR(dev);
 		}
 		if (rdev0->preferred_minor != unit) {
-			pr_warn("md: unit number in %s is bad: %d\n",
-				bdevname(rdev0->bdev, b), rdev0->preferred_minor);
+			pr_warn("md: unit number in %pg is bad: %d\n",
+				rdev0->bdev, rdev0->preferred_minor);
 			break;
 		}
 
@@ -6520,8 +6495,8 @@ static void autorun_devices(int part)
 			pr_warn("md: %s locked, cannot run\n", mdname(mddev));
 		else if (mddev->raid_disks || mddev->major_version
 			 || !list_empty(&mddev->disks)) {
-			pr_warn("md: %s already running, cannot run %s\n",
-				mdname(mddev), bdevname(rdev0->bdev,b));
+			pr_warn("md: %s already running, cannot run %pg\n",
+				mdname(mddev), rdev0->bdev);
 			mddev_unlock(mddev);
 		} else {
 			pr_debug("md: created %s\n", mdname(mddev));
@@ -6695,7 +6670,6 @@ static int get_disk_info(struct mddev *mddev, void __user * arg)
 
 int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 {
-	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
 	struct md_rdev *rdev;
 	dev_t dev = MKDEV(info->major,info->minor);
 
@@ -6725,9 +6699,8 @@ int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 			err = super_types[mddev->major_version]
 				.load_super(rdev, rdev0, mddev->minor_version);
 			if (err < 0) {
-				pr_warn("md: %s has different UUID to %s\n",
-					bdevname(rdev->bdev,b),
-					bdevname(rdev0->bdev,b2));
+				pr_warn("md: %pg has different UUID to %pg\n",
+					rdev->bdev, rdev0->bdev);
 				export_rdev(rdev);
 				return -EINVAL;
 			}
@@ -6902,7 +6875,6 @@ int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info)
 
 static int hot_remove_disk(struct mddev *mddev, dev_t dev)
 {
-	char b[BDEVNAME_SIZE];
 	struct md_rdev *rdev;
 
 	if (!mddev->pers)
@@ -6937,14 +6909,13 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev)
 
 	return 0;
 busy:
-	pr_debug("md: cannot remove active disk %s from %s ...\n",
-		 bdevname(rdev->bdev,b), mdname(mddev));
+	pr_debug("md: cannot remove active disk %pg from %s ...\n",
+		 rdev->bdev, mdname(mddev));
 	return -EBUSY;
 }
 
 static int hot_add_disk(struct mddev *mddev, dev_t dev)
 {
-	char b[BDEVNAME_SIZE];
 	int err;
 	struct md_rdev *rdev;
 
@@ -6977,8 +6948,8 @@ static int hot_add_disk(struct mddev *mddev, dev_t dev)
 	rdev->sectors = rdev->sb_start;
 
 	if (test_bit(Faulty, &rdev->flags)) {
-		pr_warn("md: can not hot-add faulty %s disk to %s!\n",
-			bdevname(rdev->bdev,b), mdname(mddev));
+		pr_warn("md: can not hot-add faulty %pg disk to %s!\n",
+			rdev->bdev, mdname(mddev));
 		err = -EINVAL;
 		goto abort_export;
 	}
@@ -7994,10 +7965,8 @@ static void status_unused(struct seq_file *seq)
 	seq_printf(seq, "unused devices: ");
 
 	list_for_each_entry(rdev, &pending_raid_disks, same_set) {
-		char b[BDEVNAME_SIZE];
 		i++;
-		seq_printf(seq, "%s ",
-			      bdevname(rdev->bdev,b));
+		seq_printf(seq, "%pg ", rdev->bdev);
 	}
 	if (!i)
 		seq_printf(seq, "<none>");
@@ -8237,9 +8206,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
 		sectors = 0;
 		rcu_read_lock();
 		rdev_for_each_rcu(rdev, mddev) {
-			char b[BDEVNAME_SIZE];
-			seq_printf(seq, " %s[%d]",
-				bdevname(rdev->bdev,b), rdev->desc_nr);
+			seq_printf(seq, " %pg[%d]", rdev->bdev, rdev->desc_nr);
 			if (test_bit(WriteMostly, &rdev->flags))
 				seq_printf(seq, "(W)");
 			if (test_bit(Journal, &rdev->flags))
@@ -9616,7 +9583,6 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 	struct mdp_superblock_1 *sb = page_address(rdev->sb_page);
 	struct md_rdev *rdev2, *tmp;
 	int role, ret;
-	char b[BDEVNAME_SIZE];
 
 	/*
 	 * If size is changed in another node then we need to
@@ -9640,7 +9606,7 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 
 		if (test_bit(Candidate, &rdev2->flags)) {
 			if (role == 0xfffe) {
-				pr_info("md: Removing Candidate device %s because add failed\n", bdevname(rdev2->bdev,b));
+				pr_info("md: Removing Candidate device %pg because add failed\n", rdev2->bdev);
 				md_kick_rdev_from_array(rdev2);
 				continue;
 			}
@@ -9657,8 +9623,7 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 			      MD_FEATURE_RESHAPE_ACTIVE)) {
 				rdev2->saved_raid_disk = role;
 				ret = remove_and_add_spares(mddev, rdev2);
-				pr_info("Activated spare: %s\n",
-					bdevname(rdev2->bdev,b));
+				pr_info("Activated spare: %pg\n", rdev2->bdev);
 				/* wakeup mddev->thread here, so array could
 				 * perform resync with the new activated disk */
 				set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 62c8b6adac70..cfa85da71898 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -37,7 +37,6 @@ static void dump_zones(struct mddev *mddev)
 	int j, k;
 	sector_t zone_size = 0;
 	sector_t zone_start = 0;
-	char b[BDEVNAME_SIZE];
 	struct r0conf *conf = mddev->private;
 	int raid_disks = conf->strip_zone[0].nb_dev;
 	pr_debug("md: RAID0 configuration for %s - %d zone%s\n",
@@ -48,9 +47,9 @@ static void dump_zones(struct mddev *mddev)
 		int len = 0;
 
 		for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
-			len += snprintf(line+len, 200-len, "%s%s", k?"/":"",
-					bdevname(conf->devlist[j*raid_disks
-							       + k]->bdev, b));
+			len += snprintf(line + len, 200 - len, "%s%pg",
+					k ? "/" : "",
+					conf->devlist[j * raid_disks + k]->bdev);
 		pr_debug("md: zone%d=[%s]\n", j, line);
 
 		zone_size  = conf->strip_zone[j].zone_end - zone_start;
@@ -69,8 +68,6 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	struct md_rdev *smallest, *rdev1, *rdev2, *rdev, **dev;
 	struct strip_zone *zone;
 	int cnt;
-	char b[BDEVNAME_SIZE];
-	char b2[BDEVNAME_SIZE];
 	struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	unsigned blksize = 512;
 
@@ -78,9 +75,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	if (!conf)
 		return -ENOMEM;
 	rdev_for_each(rdev1, mddev) {
-		pr_debug("md/raid0:%s: looking at %s\n",
-			 mdname(mddev),
-			 bdevname(rdev1->bdev, b));
+		pr_debug("md/raid0:%s: looking at %pg\n", mdname(mddev), rdev1->bdev);
 		c = 0;
 
 		/* round size to chunk_size */
@@ -92,12 +87,11 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 				      rdev1->bdev->bd_disk->queue));
 
 		rdev_for_each(rdev2, mddev) {
-			pr_debug("md/raid0:%s:   comparing %s(%llu)"
-				 " with %s(%llu)\n",
+			pr_debug("md/raid0:%s:   comparing %pg(%llu) with %pg(%llu)\n",
 				 mdname(mddev),
-				 bdevname(rdev1->bdev,b),
+				 rdev1->bdev,
 				 (unsigned long long)rdev1->sectors,
-				 bdevname(rdev2->bdev,b2),
+				 rdev2->bdev,
 				 (unsigned long long)rdev2->sectors);
 			if (rdev2 == rdev1) {
 				pr_debug("md/raid0:%s:   END\n",
@@ -240,15 +234,15 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		for (j=0; j<cnt; j++) {
 			rdev = conf->devlist[j];
 			if (rdev->sectors <= zone->dev_start) {
-				pr_debug("md/raid0:%s: checking %s ... nope\n",
+				pr_debug("md/raid0:%s: checking %pg ... nope\n",
 					 mdname(mddev),
-					 bdevname(rdev->bdev, b));
+					 rdev->bdev);
 				continue;
 			}
-			pr_debug("md/raid0:%s: checking %s ..."
+			pr_debug("md/raid0:%s: checking %pg ..."
 				 " contained as device %d\n",
 				 mdname(mddev),
-				 bdevname(rdev->bdev, b), c);
+				 rdev->bdev, c);
 			dev[c] = rdev;
 			c++;
 			if (!smallest || rdev->sectors < smallest->sectors) {
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 51f2547c2007..7ff505c1c091 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -398,10 +398,9 @@ static void raid1_end_read_request(struct bio *bio)
 		/*
 		 * oops, read error:
 		 */
-		char b[BDEVNAME_SIZE];
-		pr_err_ratelimited("md/raid1:%s: %s: rescheduling sector %llu\n",
+		pr_err_ratelimited("md/raid1:%s: %pg: rescheduling sector %llu\n",
 				   mdname(conf->mddev),
-				   bdevname(rdev->bdev, b),
+				   rdev->bdev,
 				   (unsigned long long)r1_bio->sector);
 		set_bit(R1BIO_ReadError, &r1_bio->state);
 		reschedule_retry(r1_bio);
@@ -1601,7 +1600,6 @@ static void raid1_status(struct seq_file *seq, struct mddev *mddev)
 
 static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	struct r1conf *conf = mddev->private;
 	unsigned long flags;
 
@@ -1635,9 +1633,9 @@ static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_bit(MD_RECOVERY_INTR, &mddev->recovery);
 	set_mask_bits(&mddev->sb_flags, 0,
 		      BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
-	pr_crit("md/raid1:%s: Disk failure on %s, disabling device.\n"
+	pr_crit("md/raid1:%s: Disk failure on %pg, disabling device.\n"
 		"md/raid1:%s: Operation continuing on %d devices.\n",
-		mdname(mddev), bdevname(rdev->bdev, b),
+		mdname(mddev), rdev->bdev,
 		mdname(mddev), conf->raid_disks - mddev->degraded);
 }
 
@@ -1655,13 +1653,12 @@ static void print_conf(struct r1conf *conf)
 
 	rcu_read_lock();
 	for (i = 0; i < conf->raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
 		if (rdev)
-			pr_debug(" disk %d, wo:%d, o:%d, dev:%s\n",
+			pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n",
 				 i, !test_bit(In_sync, &rdev->flags),
 				 !test_bit(Faulty, &rdev->flags),
-				 bdevname(rdev->bdev,b));
+				 rdev->bdev);
 	}
 	rcu_read_unlock();
 }
@@ -2022,15 +2019,14 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
 		} while (!success && d != r1_bio->read_disk);
 
 		if (!success) {
-			char b[BDEVNAME_SIZE];
 			int abort = 0;
 			/* Cannot read from anywhere, this block is lost.
 			 * Record a bad block on each device.  If that doesn't
 			 * work just disable and interrupt the recovery.
 			 * Don't fail devices as that won't really help.
 			 */
-			pr_crit_ratelimited("md/raid1:%s: %s: unrecoverable I/O read error for block %llu\n",
-					    mdname(mddev), bio_devname(bio, b),
+			pr_crit_ratelimited("md/raid1:%s: %pg: unrecoverable I/O read error for block %llu\n",
+					    mdname(mddev), bio->bi_bdev,
 					    (unsigned long long)r1_bio->sector);
 			for (d = 0; d < conf->raid_disks * 2; d++) {
 				rdev = conf->mirrors[d].rdev;
@@ -2300,7 +2296,6 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 		}
 		d = start;
 		while (d != read_disk) {
-			char b[BDEVNAME_SIZE];
 			if (d==0)
 				d = conf->raid_disks * 2;
 			d--;
@@ -2313,11 +2308,11 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 				if (r1_sync_page_io(rdev, sect, s,
 						    conf->tmppage, READ)) {
 					atomic_add(s, &rdev->corrected_errors);
-					pr_info("md/raid1:%s: read error corrected (%d sectors at %llu on %s)\n",
+					pr_info("md/raid1:%s: read error corrected (%d sectors at %llu on %pg)\n",
 						mdname(mddev), s,
 						(unsigned long long)(sect +
 								     rdev->data_offset),
-						bdevname(rdev->bdev, b));
+						rdev->bdev);
 				}
 				rdev_dec_pending(rdev, mddev);
 			} else
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 16977e8e075d..d1b85478bb8d 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -390,10 +390,9 @@ static void raid10_end_read_request(struct bio *bio)
 		/*
 		 * oops, read error - keep the refcount on the rdev
 		 */
-		char b[BDEVNAME_SIZE];
-		pr_err_ratelimited("md/raid10:%s: %s: rescheduling sector %llu\n",
+		pr_err_ratelimited("md/raid10:%s: %pg: rescheduling sector %llu\n",
 				   mdname(conf->mddev),
-				   bdevname(rdev->bdev, b),
+				   rdev->bdev,
 				   (unsigned long long)r10_bio->sector);
 		set_bit(R10BIO_ReadError, &r10_bio->state);
 		reschedule_retry(r10_bio);
@@ -1941,7 +1940,6 @@ static int enough(struct r10conf *conf, int ignore)
 
 static void raid10_error(struct mddev *mddev, struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	struct r10conf *conf = mddev->private;
 	unsigned long flags;
 
@@ -1971,9 +1969,9 @@ static void raid10_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_mask_bits(&mddev->sb_flags, 0,
 		      BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
 	spin_unlock_irqrestore(&conf->device_lock, flags);
-	pr_crit("md/raid10:%s: Disk failure on %s, disabling device.\n"
+	pr_crit("md/raid10:%s: Disk failure on %pg, disabling device.\n"
 		"md/raid10:%s: Operation continuing on %d devices.\n",
-		mdname(mddev), bdevname(rdev->bdev, b),
+		mdname(mddev), rdev->bdev,
 		mdname(mddev), conf->geo.raid_disks - mddev->degraded);
 }
 
@@ -1993,13 +1991,12 @@ static void print_conf(struct r10conf *conf)
 	/* This is only called with ->reconfix_mutex held, so
 	 * rcu protection of rdev is not needed */
 	for (i = 0; i < conf->geo.raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		rdev = conf->mirrors[i].rdev;
 		if (rdev)
-			pr_debug(" disk %d, wo:%d, o:%d, dev:%s\n",
+			pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n",
 				 i, !test_bit(In_sync, &rdev->flags),
 				 !test_bit(Faulty, &rdev->flags),
-				 bdevname(rdev->bdev,b));
+				 rdev->bdev);
 	}
 }
 
@@ -2656,14 +2653,10 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 	check_decay_read_errors(mddev, rdev);
 	atomic_inc(&rdev->read_errors);
 	if (atomic_read(&rdev->read_errors) > max_read_errors) {
-		char b[BDEVNAME_SIZE];
-		bdevname(rdev->bdev, b);
-
-		pr_notice("md/raid10:%s: %s: Raid device exceeded read_error threshold [cur %d:max %d]\n",
-			  mdname(mddev), b,
+		pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n",
+			  mdname(mddev), rdev->bdev,
 			  atomic_read(&rdev->read_errors), max_read_errors);
-		pr_notice("md/raid10:%s: %s: Failing raid device\n",
-			  mdname(mddev), b);
+		pr_notice("md/raid10:%s: %pg: Failing raid device\n", mdname(mddev), rdev->bdev);
 		md_error(mddev, rdev);
 		r10_bio->devs[r10_bio->read_slot].bio = IO_BLOCKED;
 		return;
@@ -2733,8 +2726,6 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 		/* write it back and re-read */
 		rcu_read_lock();
 		while (sl != r10_bio->read_slot) {
-			char b[BDEVNAME_SIZE];
-
 			if (sl==0)
 				sl = conf->copies;
 			sl--;
@@ -2753,24 +2744,22 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 					     s, conf->tmppage, WRITE)
 			    == 0) {
 				/* Well, this device is dead */
-				pr_notice("md/raid10:%s: read correction write failed (%d sectors at %llu on %s)\n",
+				pr_notice("md/raid10:%s: read correction write failed (%d sectors at %llu on %pg)\n",
 					  mdname(mddev), s,
 					  (unsigned long long)(
 						  sect +
 						  choose_data_offset(r10_bio,
 								     rdev)),
-					  bdevname(rdev->bdev, b));
-				pr_notice("md/raid10:%s: %s: failing drive\n",
+					  rdev->bdev);
+				pr_notice("md/raid10:%s: %pg: failing drive\n",
 					  mdname(mddev),
-					  bdevname(rdev->bdev, b));
+					  rdev->bdev);
 			}
 			rdev_dec_pending(rdev, mddev);
 			rcu_read_lock();
 		}
 		sl = start;
 		while (sl != r10_bio->read_slot) {
-			char b[BDEVNAME_SIZE];
-
 			if (sl==0)
 				sl = conf->copies;
 			sl--;
@@ -2790,23 +2779,21 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 						 READ)) {
 			case 0:
 				/* Well, this device is dead */
-				pr_notice("md/raid10:%s: unable to read back corrected sectors (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio, rdev)),
-				       bdevname(rdev->bdev, b));
-				pr_notice("md/raid10:%s: %s: failing drive\n",
-				       mdname(mddev),
-				       bdevname(rdev->bdev, b));
+				pr_notice("md/raid10:%s: unable to read back corrected sectors (%d sectors at %llu on %pg)\n",
+					  mdname(mddev), s,
+					  (unsigned long long)(sect
+						  + choose_data_offset(r10_bio, rdev)),
+					  rdev->bdev);
+				pr_notice("md/raid10:%s: %pg: failing drive\n",
+					  mdname(mddev),
+					  rdev->bdev);
 				break;
 			case 1:
-				pr_info("md/raid10:%s: read error corrected (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio, rdev)),
-				       bdevname(rdev->bdev, b));
+				pr_info("md/raid10:%s: read error corrected (%d sectors at %llu on %pg)\n",
+					mdname(mddev), s,
+					(unsigned long long)(sect
+						+ choose_data_offset(r10_bio, rdev)),
+					rdev->bdev);
 				atomic_add(s, &rdev->corrected_errors);
 			}
 
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 0b5dcaabbc15..0323eb8fa949 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -3067,11 +3067,10 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
 {
 	struct request_queue *q = bdev_get_queue(rdev->bdev);
 	struct r5l_log *log;
-	char b[BDEVNAME_SIZE];
 	int ret;
 
-	pr_debug("md/raid:%s: using device %s as journal\n",
-		 mdname(conf->mddev), bdevname(rdev->bdev, b));
+	pr_debug("md/raid:%s: using device %pg as journal\n",
+		 mdname(conf->mddev), rdev->bdev);
 
 	if (PAGE_SIZE != 4096)
 		return -EINVAL;
diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c
index 3ddc2aa0b530..827bc6f75639 100644
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@ -416,12 +416,10 @@ static void ppl_log_endio(struct bio *bio)
 
 static void ppl_submit_iounit_bio(struct ppl_io_unit *io, struct bio *bio)
 {
-	char b[BDEVNAME_SIZE];
-
-	pr_debug("%s: seq: %llu size: %u sector: %llu dev: %s\n",
+	pr_debug("%s: seq: %llu size: %u sector: %llu dev: %pg\n",
 		 __func__, io->seq, bio->bi_iter.bi_size,
 		 (unsigned long long)bio->bi_iter.bi_sector,
-		 bio_devname(bio, b));
+		 bio->bi_bdev);
 
 	submit_bio(bio);
 }
@@ -590,9 +588,8 @@ static void ppl_flush_endio(struct bio *bio)
 	struct ppl_log *log = io->log;
 	struct ppl_conf *ppl_conf = log->ppl_conf;
 	struct r5conf *conf = ppl_conf->mddev->private;
-	char b[BDEVNAME_SIZE];
 
-	pr_debug("%s: dev: %s\n", __func__, bio_devname(bio, b));
+	pr_debug("%s: dev: %pg\n", __func__, bio->bi_bdev);
 
 	if (bio->bi_status) {
 		struct md_rdev *rdev;
@@ -635,7 +632,6 @@ static void ppl_do_flush(struct ppl_io_unit *io)
 
 		if (bdev) {
 			struct bio *bio;
-			char b[BDEVNAME_SIZE];
 
 			bio = bio_alloc_bioset(GFP_NOIO, 0, &ppl_conf->flush_bs);
 			bio_set_dev(bio, bdev);
@@ -643,8 +639,7 @@ static void ppl_do_flush(struct ppl_io_unit *io)
 			bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
 			bio->bi_end_io = ppl_flush_endio;
 
-			pr_debug("%s: dev: %s\n", __func__,
-				 bio_devname(bio, b));
+			pr_debug("%s: dev: %pg\n", __func__, bio->bi_bdev);
 
 			submit_bio(bio);
 			flushed_disks++;
@@ -807,7 +802,6 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
 	int data_disks;
 	int i;
 	int ret = 0;
-	char b[BDEVNAME_SIZE];
 	unsigned int pp_size = le32_to_cpu(e->pp_size);
 	unsigned int data_size = le32_to_cpu(e->data_size);
 
@@ -901,8 +895,8 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
 				break;
 			}
 
-			pr_debug("%s:%*s reading data member disk %s sector %llu\n",
-				 __func__, indent, "", bdevname(rdev->bdev, b),
+			pr_debug("%s:%*s reading data member disk %pg sector %llu\n",
+				 __func__, indent, "", rdev->bdev,
 				 (unsigned long long)sector);
 			if (!sync_page_io(rdev, sector, block_size, page2,
 					REQ_OP_READ, 0, false)) {
@@ -946,10 +940,10 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
 		parity_rdev = conf->disks[sh.pd_idx].rdev;
 
 		BUG_ON(parity_rdev->bdev->bd_dev != log->rdev->bdev->bd_dev);
-		pr_debug("%s:%*s write parity at sector %llu, disk %s\n",
+		pr_debug("%s:%*s write parity at sector %llu, disk %pg\n",
 			 __func__, indent, "",
 			 (unsigned long long)parity_sector,
-			 bdevname(parity_rdev->bdev, b));
+			 parity_rdev->bdev);
 		if (!sync_page_io(parity_rdev, parity_sector, block_size,
 				page1, REQ_OP_WRITE, 0, false)) {
 			pr_debug("%s:%*s parity write error!\n", __func__,
@@ -1261,7 +1255,6 @@ void ppl_exit_log(struct r5conf *conf)
 
 static int ppl_validate_rdev(struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	int ppl_data_sectors;
 	int ppl_size_new;
 
@@ -1278,8 +1271,8 @@ static int ppl_validate_rdev(struct md_rdev *rdev)
 				RAID5_STRIPE_SECTORS((struct r5conf *)rdev->mddev->private));
 
 	if (ppl_data_sectors <= 0) {
-		pr_warn("md/raid:%s: PPL space too small on %s\n",
-			mdname(rdev->mddev), bdevname(rdev->bdev, b));
+		pr_warn("md/raid:%s: PPL space too small on %pg\n",
+			mdname(rdev->mddev), rdev->bdev);
 		return -ENOSPC;
 	}
 
@@ -1289,16 +1282,16 @@ static int ppl_validate_rdev(struct md_rdev *rdev)
 	     rdev->ppl.sector + ppl_size_new > rdev->data_offset) ||
 	    (rdev->ppl.sector >= rdev->data_offset &&
 	     rdev->data_offset + rdev->sectors > rdev->ppl.sector)) {
-		pr_warn("md/raid:%s: PPL space overlaps with data on %s\n",
-			mdname(rdev->mddev), bdevname(rdev->bdev, b));
+		pr_warn("md/raid:%s: PPL space overlaps with data on %pg\n",
+			mdname(rdev->mddev), rdev->bdev);
 		return -EINVAL;
 	}
 
 	if (!rdev->mddev->external &&
 	    ((rdev->ppl.offset > 0 && rdev->ppl.offset < (rdev->sb_size >> 9)) ||
 	     (rdev->ppl.offset <= 0 && rdev->ppl.offset + ppl_size_new > 0))) {
-		pr_warn("md/raid:%s: PPL space overlaps with superblock on %s\n",
-			mdname(rdev->mddev), bdevname(rdev->bdev, b));
+		pr_warn("md/raid:%s: PPL space overlaps with superblock on %pg\n",
+			mdname(rdev->mddev), rdev->bdev);
 		return -EINVAL;
 	}
 
@@ -1468,14 +1461,13 @@ int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add)
 	struct ppl_conf *ppl_conf = conf->log_private;
 	struct ppl_log *log;
 	int ret = 0;
-	char b[BDEVNAME_SIZE];
 
 	if (!rdev)
 		return -EINVAL;
 
-	pr_debug("%s: disk: %d operation: %s dev: %s\n",
+	pr_debug("%s: disk: %d operation: %s dev: %pg\n",
 		 __func__, rdev->raid_disk, add ? "add" : "remove",
-		 bdevname(rdev->bdev, b));
+		 rdev->bdev);
 
 	if (rdev->raid_disk < 0)
 		return 0;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index b8436e4930ed..66df734dd3a6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2665,7 +2665,6 @@ static void raid5_end_read_request(struct bio * bi)
 	struct stripe_head *sh = bi->bi_private;
 	struct r5conf *conf = sh->raid_conf;
 	int disks = sh->disks, i;
-	char b[BDEVNAME_SIZE];
 	struct md_rdev *rdev = NULL;
 	sector_t s;
 
@@ -2703,10 +2702,10 @@ static void raid5_end_read_request(struct bio * bi)
 			 * any error
 			 */
 			pr_info_ratelimited(
-				"md/raid:%s: read error corrected (%lu sectors at %llu on %s)\n",
+				"md/raid:%s: read error corrected (%lu sectors at %llu on %pg)\n",
 				mdname(conf->mddev), RAID5_STRIPE_SECTORS(conf),
 				(unsigned long long)s,
-				bdevname(rdev->bdev, b));
+				rdev->bdev);
 			atomic_add(RAID5_STRIPE_SECTORS(conf), &rdev->corrected_errors);
 			clear_bit(R5_ReadError, &sh->dev[i].flags);
 			clear_bit(R5_ReWrite, &sh->dev[i].flags);
@@ -2723,7 +2722,6 @@ static void raid5_end_read_request(struct bio * bi)
 		if (atomic_read(&rdev->read_errors))
 			atomic_set(&rdev->read_errors, 0);
 	} else {
-		const char *bdn = bdevname(rdev->bdev, b);
 		int retry = 0;
 		int set_bad = 0;
 
@@ -2732,25 +2730,25 @@ static void raid5_end_read_request(struct bio * bi)
 			atomic_inc(&rdev->read_errors);
 		if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
 			pr_warn_ratelimited(
-				"md/raid:%s: read error on replacement device (sector %llu on %s).\n",
+				"md/raid:%s: read error on replacement device (sector %llu on %pg).\n",
 				mdname(conf->mddev),
 				(unsigned long long)s,
-				bdn);
+				rdev->bdev);
 		else if (conf->mddev->degraded >= conf->max_degraded) {
 			set_bad = 1;
 			pr_warn_ratelimited(
-				"md/raid:%s: read error not correctable (sector %llu on %s).\n",
+				"md/raid:%s: read error not correctable (sector %llu on %pg).\n",
 				mdname(conf->mddev),
 				(unsigned long long)s,
-				bdn);
+				rdev->bdev);
 		} else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) {
 			/* Oh, no!!! */
 			set_bad = 1;
 			pr_warn_ratelimited(
-				"md/raid:%s: read error NOT corrected!! (sector %llu on %s).\n",
+				"md/raid:%s: read error NOT corrected!! (sector %llu on %pg).\n",
 				mdname(conf->mddev),
 				(unsigned long long)s,
-				bdn);
+				rdev->bdev);
 		} else if (atomic_read(&rdev->read_errors)
 			 > conf->max_nr_stripes) {
 			if (!test_bit(Faulty, &rdev->flags)) {
@@ -2758,8 +2756,8 @@ static void raid5_end_read_request(struct bio * bi)
 				    mdname(conf->mddev),
 				    atomic_read(&rdev->read_errors),
 				    conf->max_nr_stripes);
-				pr_warn("md/raid:%s: Too many read errors, failing device %s.\n",
-				    mdname(conf->mddev), bdn);
+				pr_warn("md/raid:%s: Too many read errors, failing device %pg.\n",
+					mdname(conf->mddev), rdev->bdev);
 			}
 		} else
 			retry = 1;
@@ -2872,7 +2870,6 @@ static void raid5_end_write_request(struct bio *bi)
 
 static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
 {
-	char b[BDEVNAME_SIZE];
 	struct r5conf *conf = mddev->private;
 	unsigned long flags;
 	pr_debug("raid456: error called\n");
@@ -2899,10 +2896,10 @@ static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_bit(Blocked, &rdev->flags);
 	set_mask_bits(&mddev->sb_flags, 0,
 		      BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
-	pr_crit("md/raid:%s: Disk failure on %s, disabling device.\n"
+	pr_crit("md/raid:%s: Disk failure on %pg, disabling device.\n"
 		"md/raid:%s: Operation continuing on %d devices.\n",
 		mdname(mddev),
-		bdevname(rdev->bdev, b),
+		rdev->bdev,
 		mdname(mddev),
 		conf->raid_disks - mddev->degraded);
 	r5c_update_on_rdev_error(mddev, rdev);
@@ -7324,9 +7321,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		}
 
 		if (test_bit(In_sync, &rdev->flags)) {
-			char b[BDEVNAME_SIZE];
-			pr_info("md/raid:%s: device %s operational as raid disk %d\n",
-				mdname(mddev), bdevname(rdev->bdev, b), raid_disk);
+			pr_info("md/raid:%s: device %pg operational as raid disk %d\n",
+				mdname(mddev), rdev->bdev, raid_disk);
 		} else if (rdev->saved_raid_disk != raid_disk)
 			/* Cannot rely on bitmap to complete recovery */
 			conf->fullsync = 1;
@@ -7829,12 +7825,11 @@ static void print_raid5_conf (struct r5conf *conf)
 	       conf->raid_disks - conf->mddev->degraded);
 
 	for (i = 0; i < conf->raid_disks; i++) {
-		char b[BDEVNAME_SIZE];
 		tmp = conf->disks + i;
 		if (tmp->rdev)
-			pr_debug(" disk %d, o:%d, dev:%s\n",
-			       i, !test_bit(Faulty, &tmp->rdev->flags),
-			       bdevname(tmp->rdev->bdev, b));
+			pr_debug(" disk %d, o:%d, dev:%pg\n",
+				 i, !test_bit(Faulty, &tmp->rdev->flags),
+				 tmp->rdev->bdev);
 	}
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 04/10] dm: reduce stack footprint dealing with block device names
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
                         ` (2 preceding siblings ...)
  2021-06-22 17:44       ` [PATCH v2 03/10] raid-md: " Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 05/10] block: " Anton Suvorov
                         ` (4 subsequent siblings)
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./drivers/md/dm-cache-target.c	cache_ctr	392	328	-64
./drivers/md/dm-cache-target.c	cache_io_hints	208	72	-136
./drivers/md/dm-clone-target.c	clone_ctr	416	352	-64
./drivers/md/dm-clone-target.c	clone_io_hints	216	80	-136
./drivers/md/dm-crypt.c	crypt_convert_block_aead	408	272	-136
./drivers/md/dm-crypt.c	kcryptd_async_done	192	56	-136
./drivers/md/dm-integrity.c	integrity_metadata	872	808	-64
./drivers/md/dm-mpath.c	parse_priority_group	368	304	-64
./drivers/md/dm-table.c	device_area_is_invalid	216	80	-136
./drivers/md/dm-table.c	dm_set_device_limits	200	72	-128
./drivers/md/dm-thin.c	pool_io_hints	216	80	-136

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/md/dm-cache-target.c | 10 ++++------
 drivers/md/dm-clone-target.c | 10 ++++------
 drivers/md/dm-crypt.c        |  6 ++----
 drivers/md/dm-integrity.c    |  4 ++--
 drivers/md/dm-mpath.c        |  5 +----
 drivers/md/dm-table.c        | 34 ++++++++++++++++------------------
 drivers/md/dm-thin.c         |  8 +++-----
 7 files changed, 32 insertions(+), 45 deletions(-)

diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 6ab01ff25747..4c0230dcec71 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2093,7 +2093,6 @@ static int parse_metadata_dev(struct cache_args *ca, struct dm_arg_set *as,
 {
 	int r;
 	sector_t metadata_dev_size;
-	char b[BDEVNAME_SIZE];
 
 	if (!at_least_one_arg(as, error))
 		return -EINVAL;
@@ -2107,8 +2106,8 @@ static int parse_metadata_dev(struct cache_args *ca, struct dm_arg_set *as,
 
 	metadata_dev_size = get_dev_size(ca->metadata_dev);
 	if (metadata_dev_size > DM_CACHE_METADATA_MAX_SECTORS_WARNING)
-		DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
-		       bdevname(ca->metadata_dev->bdev, b), THIN_METADATA_MAX_SECTORS);
+		DMWARN("Metadata device %pg is larger than %u sectors: excess space will not be used.",
+		       ca->metadata_dev->bdev, THIN_METADATA_MAX_SECTORS);
 
 	return 0;
 }
@@ -3399,7 +3398,6 @@ static void disable_passdown_if_not_supported(struct cache *cache)
 	struct block_device *origin_bdev = cache->origin_dev->bdev;
 	struct queue_limits *origin_limits = &bdev_get_queue(origin_bdev)->limits;
 	const char *reason = NULL;
-	char buf[BDEVNAME_SIZE];
 
 	if (!cache->features.discard_passdown)
 		return;
@@ -3411,8 +3409,8 @@ static void disable_passdown_if_not_supported(struct cache *cache)
 		reason = "max discard sectors smaller than a block";
 
 	if (reason) {
-		DMWARN("Origin device (%s) %s: Disabling discard passdown.",
-		       bdevname(origin_bdev, buf), reason);
+		DMWARN("Origin device (%pg) %s: Disabling discard passdown.",
+		       origin_bdev, reason);
 		cache->features.discard_passdown = false;
 	}
 }
diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c
index a90bdf9b2ca6..10e2e8d8fbec 100644
--- a/drivers/md/dm-clone-target.c
+++ b/drivers/md/dm-clone-target.c
@@ -1677,7 +1677,6 @@ static int parse_metadata_dev(struct clone *clone, struct dm_arg_set *as, char *
 {
 	int r;
 	sector_t metadata_dev_size;
-	char b[BDEVNAME_SIZE];
 
 	r = dm_get_device(clone->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE,
 			  &clone->metadata_dev);
@@ -1688,8 +1687,8 @@ static int parse_metadata_dev(struct clone *clone, struct dm_arg_set *as, char *
 
 	metadata_dev_size = get_dev_size(clone->metadata_dev);
 	if (metadata_dev_size > DM_CLONE_METADATA_MAX_SECTORS_WARNING)
-		DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
-		       bdevname(clone->metadata_dev->bdev, b), DM_CLONE_METADATA_MAX_SECTORS);
+		DMWARN("Metadata device %pg is larger than %u sectors: excess space will not be used.",
+		       clone->metadata_dev->bdev, DM_CLONE_METADATA_MAX_SECTORS);
 
 	return 0;
 }
@@ -2028,7 +2027,6 @@ static void disable_passdown_if_not_supported(struct clone *clone)
 	struct block_device *dest_dev = clone->dest_dev->bdev;
 	struct queue_limits *dest_limits = &bdev_get_queue(dest_dev)->limits;
 	const char *reason = NULL;
-	char buf[BDEVNAME_SIZE];
 
 	if (!test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags))
 		return;
@@ -2039,8 +2037,8 @@ static void disable_passdown_if_not_supported(struct clone *clone)
 		reason = "max discard sectors smaller than a region";
 
 	if (reason) {
-		DMWARN("Destination device (%s) %s: Disabling discard passdown.",
-		       bdevname(dest_dev, buf), reason);
+		DMWARN("Destination device (%pg) %s: Disabling discard passdown.",
+		       dest_dev, reason);
 		clear_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags);
 	}
 }
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 50f4cbd600d5..719137d41f3d 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1361,8 +1361,7 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
 	}
 
 	if (r == -EBADMSG) {
-		char b[BDEVNAME_SIZE];
-		DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
+		DMERR_LIMIT("%pg: INTEGRITY AEAD ERROR, sector %llu", ctx->bio_in->bi_bdev,
 			    (unsigned long long)le64_to_cpu(*sector));
 	}
 
@@ -2172,8 +2171,7 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
 		error = cc->iv_gen_ops->post(cc, org_iv_of_dmreq(cc, dmreq), dmreq);
 
 	if (error == -EBADMSG) {
-		char b[BDEVNAME_SIZE];
-		DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
+		DMERR_LIMIT("%pg: INTEGRITY AEAD ERROR, sector %llu", ctx->bio_in->bi_bdev,
 			    (unsigned long long)le64_to_cpu(*org_sector_of_dmreq(cc, dmreq)));
 		io->error = BLK_STS_PROTECTION;
 	} else if (error < 0)
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 20f2510db1f6..d2fec41635ff 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -1781,8 +1781,8 @@ static void integrity_metadata(struct work_struct *w)
 						checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);
 			if (unlikely(r)) {
 				if (r > 0) {
-					char b[BDEVNAME_SIZE];
-					DMERR_LIMIT("%s: Checksum failed at sector 0x%llx", bio_devname(bio, b),
+					DMERR_LIMIT("%pg: Checksum failed at sector 0x%llx",
+						    bio->bi_bdev,
 						    (sector - ((r + ic->tag_size - 1) / ic->tag_size)));
 					r = -EILSEQ;
 					atomic64_inc(&ic->number_of_mismatches);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index bced42f082b0..8d3ec771bb64 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -900,10 +900,7 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
 	if (m->hw_handler_name) {
 		r = scsi_dh_attach(q, m->hw_handler_name);
 		if (r == -EBUSY) {
-			char b[BDEVNAME_SIZE];
-
-			printk(KERN_INFO "dm-mpath: retaining handler on device %s\n",
-			       bdevname(bdev, b));
+			pr_info("dm-mpath: retaining handler on device %pg\n", bdev);
 			goto retain;
 		}
 		if (r < 0) {
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 0543cdf89e92..a9ce74b75990 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -230,15 +230,14 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		i_size_read(bdev->bd_inode) >> SECTOR_SHIFT;
 	unsigned short logical_block_size_sectors =
 		limits->logical_block_size >> SECTOR_SHIFT;
-	char b[BDEVNAME_SIZE];
 
 	if (!dev_size)
 		return 0;
 
 	if ((start >= dev_size) || (start + len > dev_size)) {
-		DMWARN("%s: %s too small for target: "
+		DMWARN("%s: %pg too small for target: "
 		       "start=%llu, len=%llu, dev_size=%llu",
-		       dm_device_name(ti->table->md), bdevname(bdev, b),
+		       dm_device_name(ti->table->md), bdev,
 		       (unsigned long long)start,
 		       (unsigned long long)len,
 		       (unsigned long long)dev_size);
@@ -253,10 +252,10 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		unsigned int zone_sectors = bdev_zone_sectors(bdev);
 
 		if (start & (zone_sectors - 1)) {
-			DMWARN("%s: start=%llu not aligned to h/w zone size %u of %s",
+			DMWARN("%s: start=%llu not aligned to h/w zone size %u of %pg",
 			       dm_device_name(ti->table->md),
 			       (unsigned long long)start,
-			       zone_sectors, bdevname(bdev, b));
+			       zone_sectors, bdev);
 			return 1;
 		}
 
@@ -270,10 +269,10 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		 * the sector range.
 		 */
 		if (len & (zone_sectors - 1)) {
-			DMWARN("%s: len=%llu not aligned to h/w zone size %u of %s",
+			DMWARN("%s: len=%llu not aligned to h/w zone size %u of %pg",
 			       dm_device_name(ti->table->md),
 			       (unsigned long long)len,
-			       zone_sectors, bdevname(bdev, b));
+			       zone_sectors, bdev);
 			return 1;
 		}
 	}
@@ -282,20 +281,20 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		return 0;
 
 	if (start & (logical_block_size_sectors - 1)) {
-		DMWARN("%s: start=%llu not aligned to h/w "
-		       "logical block size %u of %s",
+		DMWARN("%s: start=%llu not aligned to h/w logical block size %u of %pg",
 		       dm_device_name(ti->table->md),
 		       (unsigned long long)start,
-		       limits->logical_block_size, bdevname(bdev, b));
+		       limits->logical_block_size,
+		       bdev);
 		return 1;
 	}
 
 	if (len & (logical_block_size_sectors - 1)) {
-		DMWARN("%s: len=%llu not aligned to h/w "
-		       "logical block size %u of %s",
+		DMWARN("%s: len=%llu not aligned to h/w logical block size %u of %pg",
 		       dm_device_name(ti->table->md),
 		       (unsigned long long)len,
-		       limits->logical_block_size, bdevname(bdev, b));
+		       limits->logical_block_size,
+		       bdev);
 		return 1;
 	}
 
@@ -400,20 +399,19 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
 	struct queue_limits *limits = data;
 	struct block_device *bdev = dev->bdev;
 	struct request_queue *q = bdev_get_queue(bdev);
-	char b[BDEVNAME_SIZE];
 
 	if (unlikely(!q)) {
-		DMWARN("%s: Cannot set limits for nonexistent device %s",
-		       dm_device_name(ti->table->md), bdevname(bdev, b));
+		DMWARN("%s: Cannot set limits for nonexistent device %pg",
+		       dm_device_name(ti->table->md), bdev);
 		return 0;
 	}
 
 	if (blk_stack_limits(limits, &q->limits,
 			get_start_sect(bdev) + start) < 0)
-		DMWARN("%s: adding target device %s caused an alignment inconsistency: "
+		DMWARN("%s: adding target device %pg caused an alignment inconsistency: "
 		       "physical_block_size=%u, logical_block_size=%u, "
 		       "alignment_offset=%u, start=%llu",
-		       dm_device_name(ti->table->md), bdevname(bdev, b),
+		       dm_device_name(ti->table->md), bdev,
 		       q->limits.physical_block_size,
 		       q->limits.logical_block_size,
 		       q->limits.alignment_offset,
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 985baee3a678..4ffe750341ad 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2834,7 +2834,6 @@ static void disable_passdown_if_not_supported(struct pool_c *pt)
 	struct block_device *data_bdev = pt->data_dev->bdev;
 	struct queue_limits *data_limits = &bdev_get_queue(data_bdev)->limits;
 	const char *reason = NULL;
-	char buf[BDEVNAME_SIZE];
 
 	if (!pt->adjusted_pf.discard_passdown)
 		return;
@@ -2846,7 +2845,7 @@ static void disable_passdown_if_not_supported(struct pool_c *pt)
 		reason = "max discard sectors smaller than a block";
 
 	if (reason) {
-		DMWARN("Data device (%s) %s: Disabling discard passdown.", bdevname(data_bdev, buf), reason);
+		DMWARN("Data device (%pg) %s: Disabling discard passdown.", data_bdev, reason);
 		pt->adjusted_pf.discard_passdown = false;
 	}
 }
@@ -3218,11 +3217,10 @@ static sector_t get_dev_size(struct block_device *bdev)
 static void warn_if_metadata_device_too_big(struct block_device *bdev)
 {
 	sector_t metadata_dev_size = get_dev_size(bdev);
-	char buffer[BDEVNAME_SIZE];
 
 	if (metadata_dev_size > THIN_METADATA_MAX_SECTORS_WARNING)
-		DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
-		       bdevname(bdev, buffer), THIN_METADATA_MAX_SECTORS);
+		DMWARN("Metadata device %pg is larger than %u sectors: excess space will not be used.",
+		       bdev, THIN_METADATA_MAX_SECTORS);
 }
 
 static sector_t get_metadata_dev_size(struct block_device *bdev)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 05/10] block: reduce stack footprint dealing with block device names
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
                         ` (3 preceding siblings ...)
  2021-06-22 17:44       ` [PATCH v2 04/10] dm: " Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-23  7:45         ` Christoph Hellwig
  2021-06-22 17:44       ` [PATCH v2 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params() Anton Suvorov
                         ` (3 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./block/blk-core.c	submit_bio_checks	248	112	-136
./block/blk-lib.c	__blkdev_issue_discard	240	104	-136
./block/blk-settings.c	disk_stack_limits	256	192	-64
./block/partitions/amiga.c	amiga_partition	424	368	-56
./block/partitions/sgi.c	sgi_partition	352	288	-64
./block/partitions/sun.c	sun_partition	392	328	-64
./drivers/block/drbd/drbd_req.c	drbd_report_io_error	200	72	-128
./drivers/block/pktcdvd.c	pkt_seq_show	288	224	-64
./drivers/block/pktcdvd.c	pkt_setup_dev	272	136	-136
./drivers/block/pktcdvd.c	pkt_submit_bio	288	224	-64

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 block/blk-core.c         | 12 ++++--------
 block/blk-lib.c          |  5 +----
 block/blk-settings.c     |  7 ++-----
 block/partitions/amiga.c | 10 +++-------
 block/partitions/sgi.c   |  4 +---
 block/partitions/sun.c   |  4 +---
 drivers/block/pktcdvd.c  | 13 ++++---------
 7 files changed, 16 insertions(+), 39 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 514838ccab2d..de71fa115078 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -649,11 +649,9 @@ EXPORT_SYMBOL(blk_put_request);
 
 static void handle_bad_sector(struct bio *bio, sector_t maxsector)
 {
-	char b[BDEVNAME_SIZE];
-
 	pr_info_ratelimited("attempt to access beyond end of device\n"
-			    "%s: rw=%d, want=%llu, limit=%llu\n",
-			    bio_devname(bio, b), bio->bi_opf,
+			    "%pg: rw=%d, want=%llu, limit=%llu\n",
+			    bio->bi_bdev, bio->bi_opf,
 			    bio_end_sector(bio), maxsector);
 }
 
@@ -695,14 +693,12 @@ static inline bool should_fail_request(struct block_device *part,
 static inline bool bio_check_ro(struct bio *bio)
 {
 	if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) {
-		char b[BDEVNAME_SIZE];
-
 		if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
 			return false;
 
 		WARN_ONCE(1,
-		       "Trying to write to read-only block-device %s (partno %d)\n",
-			bio_devname(bio, b), bio->bi_bdev->bd_partno);
+		       "Trying to write to read-only block-device %pg (partno %d)\n",
+			bio->bi_bdev, bio->bi_bdev->bd_partno);
 		/* Older lvm-tools actually trigger this */
 		return false;
 	}
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 7b256131b20b..6fe52f7f3f48 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -49,10 +49,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 
 	/* In case the discard granularity isn't set by buggy device driver */
 	if (WARN_ON_ONCE(!q->limits.discard_granularity)) {
-		char dev_name[BDEVNAME_SIZE];
-
-		bdevname(bdev, dev_name);
-		pr_err_ratelimited("%s: Error: discard_granularity is 0.\n", dev_name);
+		pr_err_ratelimited("%pg: Error: discard_granularity is 0.\n", bdev);
 		return -EOPNOTSUPP;
 	}
 
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 902c40d67120..01972174b1b9 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -662,13 +662,10 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
 
 	if (blk_stack_limits(&t->limits, &bdev_get_queue(bdev)->limits,
 			get_start_sect(bdev) + (offset >> 9)) < 0) {
-		char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE];
+		char top[BDEVNAME_SIZE];
 
 		disk_name(disk, 0, top);
-		bdevname(bdev, bottom);
-
-		printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",
-		       top, bottom);
+		pr_notice("%s: Warning: Device %pg is misaligned\n", top, bdev);
 	}
 
 	blk_queue_update_readahead(disk->queue);
diff --git a/block/partitions/amiga.c b/block/partitions/amiga.c
index 9526491d9aed..2fa9a10a8635 100644
--- a/block/partitions/amiga.c
+++ b/block/partitions/amiga.c
@@ -34,15 +34,13 @@ int amiga_partition(struct parsed_partitions *state)
 	int start_sect, nr_sects, blk, part, res = 0;
 	int blksize = 1;	/* Multiplier for disk block size */
 	int slot = 1;
-	char b[BDEVNAME_SIZE];
 
 	for (blk = 0; ; blk++, put_dev_sector(sect)) {
 		if (blk == RDB_ALLOCATION_LIMIT)
 			goto rdb_done;
 		data = read_part_sector(state, blk, &sect);
 		if (!data) {
-			pr_err("Dev %s: unable to read RDB block %d\n",
-			       bdevname(state->bdev, b), blk);
+			pr_err("Dev %pg: unable to read RDB block %d\n", state->bdev, blk);
 			res = -1;
 			goto rdb_done;
 		}
@@ -63,8 +61,7 @@ int amiga_partition(struct parsed_partitions *state)
 			break;
 		}
 
-		pr_err("Dev %s: RDB in block %d has bad checksum\n",
-		       bdevname(state->bdev, b), blk);
+		pr_err("Dev %pg: RDB in block %d has bad checksum\n", state->bdev, blk);
 	}
 
 	/* blksize is blocks per 512 byte standard block */
@@ -83,8 +80,7 @@ int amiga_partition(struct parsed_partitions *state)
 		blk *= blksize;	/* Read in terms partition table understands */
 		data = read_part_sector(state, blk, &sect);
 		if (!data) {
-			pr_err("Dev %s: unable to read partition block %d\n",
-			       bdevname(state->bdev, b), blk);
+			pr_err("Dev %pg: unable to read partition block %d\n", state->bdev, blk);
 			res = -1;
 			goto rdb_done;
 		}
diff --git a/block/partitions/sgi.c b/block/partitions/sgi.c
index 4273f1bb0515..9305e0e0bdd9 100644
--- a/block/partitions/sgi.c
+++ b/block/partitions/sgi.c
@@ -43,7 +43,6 @@ int sgi_partition(struct parsed_partitions *state)
 	Sector sect;
 	struct sgi_disklabel *label;
 	struct sgi_partition *p;
-	char b[BDEVNAME_SIZE];
 
 	label = read_part_sector(state, 0, &sect);
 	if (!label)
@@ -62,8 +61,7 @@ int sgi_partition(struct parsed_partitions *state)
 		csum += be32_to_cpu(cs);
 	}
 	if(csum) {
-		printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
-		       bdevname(state->bdev, b));
+		pr_warn("Dev %pg SGI disklabel: csum bad, label corrupted\n", state->bdev);
 		put_dev_sector(sect);
 		return 0;
 	}
diff --git a/block/partitions/sun.c b/block/partitions/sun.c
index 47dc53eccf77..2aaa86f95c9f 100644
--- a/block/partitions/sun.c
+++ b/block/partitions/sun.c
@@ -65,7 +65,6 @@ int sun_partition(struct parsed_partitions *state)
 	} * label;
 	struct sun_partition *p;
 	unsigned long spc;
-	char b[BDEVNAME_SIZE];
 	int use_vtoc;
 	int nparts;
 
@@ -85,8 +84,7 @@ int sun_partition(struct parsed_partitions *state)
 	for (csum = 0; ush >= ((__be16 *) label);)
 		csum ^= *ush--;
 	if (csum) {
-		printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
-		       bdevname(state->bdev, b));
+		pr_info("Dev %pg Sun disklabel: Csum bad, label corrupted\n", state->bdev);
 		put_dev_sector(sect);
 		return 0;
 	}
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index f69b5c69c2a6..6191dbf17fb2 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2405,14 +2405,13 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
 static blk_qc_t pkt_submit_bio(struct bio *bio)
 {
 	struct pktcdvd_device *pd;
-	char b[BDEVNAME_SIZE];
 	struct bio *split;
 
 	blk_queue_split(&bio);
 
 	pd = bio->bi_bdev->bd_disk->queue->queuedata;
 	if (!pd) {
-		pr_err("%s incorrect request queue\n", bio_devname(bio, b));
+		pr_err("%pg incorrect request queue\n", bio->bi_bdev);
 		goto end_io;
 	}
 
@@ -2476,11 +2475,9 @@ static int pkt_seq_show(struct seq_file *m, void *p)
 {
 	struct pktcdvd_device *pd = m->private;
 	char *msg;
-	char bdev_buf[BDEVNAME_SIZE];
 	int states[PACKET_NUM_STATES];
 
-	seq_printf(m, "Writer %s mapped to %s:\n", pd->name,
-		   bdevname(pd->bdev, bdev_buf));
+	seq_printf(m, "Writer %s mapped to %pg:\n", pd->name, pd->bdev);
 
 	seq_printf(m, "\nSettings:\n");
 	seq_printf(m, "\tpacket size:\t\t%dkB\n", pd->settings.size / 2);
@@ -2537,7 +2534,6 @@ static int pkt_seq_show(struct seq_file *m, void *p)
 static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 {
 	int i;
-	char b[BDEVNAME_SIZE];
 	struct block_device *bdev;
 
 	if (pd->pkt_dev == dev) {
@@ -2549,8 +2545,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 		if (!pd2)
 			continue;
 		if (pd2->bdev->bd_dev == dev) {
-			pkt_err(pd, "%s already setup\n",
-				bdevname(pd2->bdev, b));
+			pkt_err(pd, "%pg already setup\n", pd2->bdev);
 			return -EBUSY;
 		}
 		if (pd2->pkt_dev == dev) {
@@ -2583,7 +2578,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 	}
 
 	proc_create_single_data(pd->name, 0, pkt_proc, pkt_seq_show, pd);
-	pkt_dbg(1, pd, "writer mapped to %s\n", bdevname(bdev, b));
+	pkt_dbg(1, pd, "writer mapped to %pg\n", bdev);
 	return 0;
 
 out_mem:
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params()
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
                         ` (4 preceding siblings ...)
  2021-06-22 17:44       ` [PATCH v2 05/10] block: " Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 07/10] vfs: reduce stack footprint in __blkdev_put() Anton Suvorov
                         ` (2 subsequent siblings)
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./drivers/target/target_core_iblock.c   iblock_show_configfs_dev_params 192     56      -136

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 drivers/target/target_core_iblock.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 44d9d028f716..a95f0b9bccf8 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -634,12 +634,10 @@ static ssize_t iblock_show_configfs_dev_params(struct se_device *dev, char *b)
 {
 	struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
 	struct block_device *bd = ib_dev->ibd_bd;
-	char buf[BDEVNAME_SIZE];
 	ssize_t bl = 0;
 
 	if (bd)
-		bl += sprintf(b + bl, "iBlock device: %s",
-				bdevname(bd, buf));
+		bl += sprintf(b + bl, "iBlock device: %pg", bd);
 	if (ib_dev->ibd_flags & IBDF_HAS_UDEV_PATH)
 		bl += sprintf(b + bl, "  UDEV PATH: %s",
 				ib_dev->ibd_udev_path);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 07/10] vfs: reduce stack footprint in __blkdev_put()
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
                         ` (5 preceding siblings ...)
  2021-06-22 17:44       ` [PATCH v2 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params() Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 08/10] ext4: reduce stack footprint in ext4_end_bio() Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 09/10] security: reduce stack footprint in loadpin_read_file() Anton Suvorov
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./fs/block_dev.c        __blkdev_put    224     80      -144

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 fs/block_dev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 7dad51878dfc..3adadb981777 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -64,10 +64,8 @@ static void bdev_write_inode(struct block_device *bdev)
 		spin_unlock(&inode->i_lock);
 		ret = write_inode_now(inode, true);
 		if (ret) {
-			char name[BDEVNAME_SIZE];
-			pr_warn_ratelimited("VFS: Dirty inode writeback failed "
-					    "for block device %s (err=%d).\n",
-					    bdevname(bdev, name), ret);
+			pr_warn_ratelimited("VFS: Dirty inode writeback failed for block device %pg (err=%d).\n",
+					    bdev, ret);
 		}
 		spin_lock(&inode->i_lock);
 	}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 08/10] ext4: reduce stack footprint in ext4_end_bio()
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
                         ` (6 preceding siblings ...)
  2021-06-22 17:44       ` [PATCH v2 07/10] vfs: reduce stack footprint in __blkdev_put() Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  2021-06-22 17:44       ` [PATCH v2 09/10] security: reduce stack footprint in loadpin_read_file() Anton Suvorov
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./fs/ext4/page-io.c     ext4_end_bio    224     88      -136

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 fs/ext4/page-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index f038d578d8d8..56074f2f5e63 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -323,10 +323,9 @@ static void ext4_end_bio(struct bio *bio)
 {
 	ext4_io_end_t *io_end = bio->bi_private;
 	sector_t bi_sector = bio->bi_iter.bi_sector;
-	char b[BDEVNAME_SIZE];
 
-	if (WARN_ONCE(!io_end, "io_end is NULL: %s: sector %Lu len %u err %d\n",
-		      bio_devname(bio, b),
+	if (WARN_ONCE(!io_end, "io_end is NULL: %pg: sector %llu len %u err %d\n",
+		      bio->bi_bdev,
 		      (long long) bio->bi_iter.bi_sector,
 		      (unsigned) bio_sectors(bio),
 		      bio->bi_status)) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 09/10] security: reduce stack footprint in loadpin_read_file()
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
                         ` (7 preceding siblings ...)
  2021-06-22 17:44       ` [PATCH v2 08/10] ext4: reduce stack footprint in ext4_end_bio() Anton Suvorov
@ 2021-06-22 17:44       ` Anton Suvorov
  8 siblings, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:44 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

Stack usage reduced (measured with allyesconfig):

./security/loadpin/loadpin.c    loadpin_read_file       200     56      -144

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 security/loadpin/loadpin.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index b12f7d986b1e..ad4e6756c038 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -78,11 +78,8 @@ static void check_pinning_enforcement(struct super_block *mnt_sb)
 	 * device, allow sysctl to change modes for testing.
 	 */
 	if (mnt_sb->s_bdev) {
-		char bdev[BDEVNAME_SIZE];
-
 		ro = bdev_read_only(mnt_sb->s_bdev);
-		bdevname(mnt_sb->s_bdev, bdev);
-		pr_info("%s (%u:%u): %s\n", bdev,
+		pr_info("%pg (%u:%u): %s\n", mnt_sb->s_bdev,
 			MAJOR(mnt_sb->s_bdev->bd_dev),
 			MINOR(mnt_sb->s_bdev->bd_dev),
 			ro ? "read-only" : "writable");
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 10/10] block: remove unused symbol bio_devname()
  2021-06-02 17:18   ` Matthew Wilcox
  2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
@ 2021-06-22 17:45     ` Anton Suvorov
  1 sibling, 0 replies; 26+ messages in thread
From: Anton Suvorov @ 2021-06-22 17:45 UTC (permalink / raw)
  To: willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro, warwish

This patch removes not used any more bio_devname() symbol.
It should be only applied after all other patches in the series applied.

Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
---
 block/bio.c         | 6 ------
 include/linux/bio.h | 2 --
 2 files changed, 8 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 44205dfb6b60..8674f9a4e527 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -684,12 +684,6 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
 }
 EXPORT_SYMBOL(bio_clone_fast);
 
-const char *bio_devname(struct bio *bio, char *buf)
-{
-	return bdevname(bio->bi_bdev, buf);
-}
-EXPORT_SYMBOL(bio_devname);
-
 static inline bool page_is_mergeable(const struct bio_vec *bv,
 		struct page *page, unsigned int len, unsigned int off,
 		bool *same_page)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index d2b98efb5cc5..835933a175e0 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -484,8 +484,6 @@ void bio_truncate(struct bio *bio, unsigned new_size);
 void guard_bio_eod(struct bio *bio);
 void zero_fill_bio(struct bio *bio);
 
-extern const char *bio_devname(struct bio *bio, char *buffer);
-
 #define bio_set_dev(bio, bdev) 				\
 do {							\
 	bio_clear_flag(bio, BIO_REMAPPED);		\
-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 05/10] block: reduce stack footprint dealing with block device names
  2021-06-22 17:44       ` [PATCH v2 05/10] block: " Anton Suvorov
@ 2021-06-23  7:45         ` Christoph Hellwig
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2021-06-23  7:45 UTC (permalink / raw)
  To: Anton Suvorov
  Cc: willy, dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro

On Tue, Jun 22, 2021 at 08:44:19PM +0300, Anton Suvorov wrote:
> Stack usage reduced (measured with allyesconfig):

Not just stack footprint, but also a whole lot cleaner code in general.

> -			       bdevname(state->bdev, b), blk);
> +			pr_err("Dev %pg: unable to read RDB block %d\n", state->bdev, blk);

> -		       bdevname(state->bdev, b), blk);
> +		pr_err("Dev %pg: RDB in block %d has bad checksum\n", state->bdev, blk);

> -			pr_err("Dev %s: unable to read partition block %d\n",
> -			       bdevname(state->bdev, b), blk);
> +			pr_err("Dev %pg: unable to read partition block %d\n", state->bdev, blk);

[...]

Please keep the non-format string arguments on separate lines instead
of creating unreadable lines.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 03/10] raid-md: reduce stack footprint dealing with block device names
  2021-06-22 17:44       ` [PATCH v2 03/10] raid-md: " Anton Suvorov
@ 2021-06-23  8:26         ` Guoqing Jiang
  0 siblings, 0 replies; 26+ messages in thread
From: Guoqing Jiang @ 2021-06-23  8:26 UTC (permalink / raw)
  To: Anton Suvorov, willy
  Cc: dmtrmonakhov, linux-block, linux-fsdevel, linux-kernel, viro

Hi,

Maybe replace "raid-md" with "md/raid" or just "md".

On 6/23/21 1:44 AM, Anton Suvorov wrote:
> Stack usage reduced (measured with allyesconfig):
>
> ./drivers/md/md-linear.c	linear_make_request	248	112	-136
> ./drivers/md/md-multipath.c	multipath_end_request	232	96	-136
> ./drivers/md/md-multipath.c	multipath_error	208	72	-136
> ./drivers/md/md-multipath.c	multipathd	248	112	-136
> ./drivers/md/md-multipath.c	print_multipath_conf	208	64	-144
> ./drivers/md/md.c	autorun_devices	312	184	-128
> ./drivers/md/md.c	export_rdev	168	32	-136
> ./drivers/md/md.c	md_add_new_disk	280	80	-200
> ./drivers/md/md.c	md_import_device	200	56	-144
> ./drivers/md/md.c	md_integrity_add_rdev	192	56	-136
> ./drivers/md/md.c	md_ioctl	560	496	-64
> ./drivers/md/md.c	md_reload_sb	224	88	-136
> ./drivers/md/md.c	md_run	408	288	-120
> ./drivers/md/md.c	md_seq_show	232	96	-136
> ./drivers/md/md.c	md_update_sb	304	168	-136
> ./drivers/md/md.c	read_disk_sb	184	48	-136
> ./drivers/md/md.c	super_1_load	392	192	-200
> ./drivers/md/md.c	super_90_load	304	112	-192
> ./drivers/md/md.c	unbind_rdev_from_array	200	64	-136
> ./drivers/md/raid0.c	create_strip_zones	400	200	-200
> ./drivers/md/raid0.c	dump_zones	536	464	-72
> ./drivers/md/raid1.c	fix_read_error	352	288	-64
> ./drivers/md/raid1.c	print_conf	224	80	-144
> ./drivers/md/raid1.c	raid1_end_read_request	216	80	-136
> ./drivers/md/raid1.c	raid1_error	216	96	-120
> ./drivers/md/raid1.c	sync_request_write	344	208	-136
> ./drivers/md/raid10.c	fix_read_error	392	320	-72
> ./drivers/md/raid10.c	print_conf	216	72	-144
> ./drivers/md/raid10.c	raid10_end_read_request	216	80	-136
> ./drivers/md/raid10.c	raid10_error	216	80	-136
> ./drivers/md/raid5-cache.c	r5l_init_log	224	88	-136
> ./drivers/md/raid5-ppl.c	ppl_do_flush	256	136	-120
> ./drivers/md/raid5-ppl.c	ppl_flush_endio	192	56	-136
> ./drivers/md/raid5-ppl.c	ppl_modify_log	192	56	-136
> ./drivers/md/raid5-ppl.c	ppl_recover_entry	1296	1232	-64
> ./drivers/md/raid5-ppl.c	ppl_submit_iounit_bio	192	56	-136
> ./drivers/md/raid5-ppl.c	ppl_validate_rdev	184	48	-136
> ./drivers/md/raid5.c	print_raid5_conf	208	64	-144
> ./drivers/md/raid5.c	raid5_end_read_request	272	128	-144
> ./drivers/md/raid5.c	raid5_error	216	80	-136
> ./drivers/md/raid5.c	setup_conf	360	296	-64
>
> Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
> ---
>   drivers/md/md-linear.c    |   5 +-
>   drivers/md/md-multipath.c |  24 +++----
>   drivers/md/md.c           | 135 ++++++++++++++------------------------
>   drivers/md/raid0.c        |  28 ++++----
>   drivers/md/raid1.c        |  25 +++----
>   drivers/md/raid10.c       |  65 ++++++++----------
>   drivers/md/raid5-cache.c  |   5 +-
>   drivers/md/raid5-ppl.c    |  40 +++++------
>   drivers/md/raid5.c        |  39 +++++------
>   9 files changed, 144 insertions(+), 222 deletions(-)

Also a nice cleanup!  Acked-by: Guoqing Jiang <jiangguoqing@kylinos.cn>

Thanks,
Guoqing



^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 04/10] dm: reduce stack footprint dealing with block device names
  2021-06-02 15:28 ` [PATCH 04/10] dm: " Anton Suvorov
@ 2021-06-23 20:20   ` Mike Snitzer
  0 siblings, 0 replies; 26+ messages in thread
From: Mike Snitzer @ 2021-06-23 20:20 UTC (permalink / raw)
  To: Anton Suvorov
  Cc: linux-kernel, linux-fsdevel, dmtrmonakhov, linux-block, viro

On Wed, Jun 02 2021 at 11:28P -0400,
Anton Suvorov <warwish@yandex-team.ru> wrote:

> Stack usage reduced (measured with allyesconfig):
> 
> ./drivers/md/dm-cache-target.c	cache_ctr	392	328	-64
> ./drivers/md/dm-cache-target.c	cache_io_hints	208	72	-136
> ./drivers/md/dm-clone-target.c	clone_ctr	416	352	-64
> ./drivers/md/dm-clone-target.c	clone_io_hints	216	80	-136
> ./drivers/md/dm-crypt.c	crypt_convert_block_aead	408	272	-136
> ./drivers/md/dm-crypt.c	kcryptd_async_done	192	56	-136
> ./drivers/md/dm-integrity.c	integrity_metadata	872	808	-64
> ./drivers/md/dm-mpath.c	parse_priority_group	368	304	-64
> ./drivers/md/dm-table.c	device_area_is_invalid	216	80	-136
> ./drivers/md/dm-table.c	dm_set_device_limits	200	72	-128
> ./drivers/md/dm-thin.c	pool_io_hints	216	80	-136
> 
> Signed-off-by: Anton Suvorov <warwish@yandex-team.ru>
> ---
>  drivers/md/dm-cache-target.c | 10 ++++------
>  drivers/md/dm-clone-target.c | 10 ++++------
>  drivers/md/dm-crypt.c        |  6 ++----
>  drivers/md/dm-integrity.c    |  4 ++--
>  drivers/md/dm-mpath.c        |  6 ++----
>  drivers/md/dm-table.c        | 34 ++++++++++++++++------------------
>  drivers/md/dm-thin.c         |  8 +++-----
>  7 files changed, 33 insertions(+), 45 deletions(-)
> 

<snip>

> diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
> index 20f2510db1f6..d2fec41635ff 100644
> --- a/drivers/md/dm-integrity.c
> +++ b/drivers/md/dm-integrity.c
> @@ -1781,8 +1781,8 @@ static void integrity_metadata(struct work_struct *w)
>  						checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);
>  			if (unlikely(r)) {
>  				if (r > 0) {
> -					char b[BDEVNAME_SIZE];
> -					DMERR_LIMIT("%s: Checksum failed at sector 0x%llx", bio_devname(bio, b),
> +					DMERR_LIMIT("%pg: Checksum failed at sector 0x%llx",
> +						    bio->bi_bdev,
>  						    (sector - ((r + ic->tag_size - 1) / ic->tag_size)));
>  					r = -EILSEQ;
>  					atomic64_inc(&ic->number_of_mismatches);
> diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
> index bced42f082b0..678e5bb0fa5a 100644
> --- a/drivers/md/dm-mpath.c
> +++ b/drivers/md/dm-mpath.c
> @@ -900,10 +900,8 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
>  	if (m->hw_handler_name) {
>  		r = scsi_dh_attach(q, m->hw_handler_name);
>  		if (r == -EBUSY) {
> -			char b[BDEVNAME_SIZE];
> -
> -			printk(KERN_INFO "dm-mpath: retaining handler on device %s\n",
> -			       bdevname(bdev, b));
> +			pr_info("dm-mpath: retaining handler on device %pg\n",
> +				bdev);
>  			goto retain;
>  		}
>  		if (r < 0) {

Would appreciate it if you just left the arguments on the same line,
for this dm-mpath.c change and the dm-integrity.c change, don't worry
about 80 column.

Also, would prefer you use DMINFO() instead of pr_info().  DMINFO()
achieves the same but will add "device-mapper: multipath: " prefix for
you, also you then don't need to add the newline. So use:

     DMINFO("retaining handler on device %pg", bdev);


> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 7e88e5e06922..175b9c7b1c48 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -282,20 +281,20 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
>  		return 0;
>  
>  	if (start & (logical_block_size_sectors - 1)) {
> -		DMWARN("%s: start=%llu not aligned to h/w "
> -		       "logical block size %u of %s",
> +		DMWARN("%s: start=%llu not aligned to h/w logical block size %u of %pg",
>  		       dm_device_name(ti->table->md),
>  		       (unsigned long long)start,
> -		       limits->logical_block_size, bdevname(bdev, b));
> +		       limits->logical_block_size,
> +		       bdev);
>  		return 1;
>  	}
>  
>  	if (len & (logical_block_size_sectors - 1)) {
> -		DMWARN("%s: len=%llu not aligned to h/w "
> -		       "logical block size %u of %s",
> +		DMWARN("%s: len=%llu not aligned to h/w logical block size %u of %pg",
>  		       dm_device_name(ti->table->md),
>  		       (unsigned long long)len,
> -		       limits->logical_block_size, bdevname(bdev, b));
> +		       limits->logical_block_size,
> +		       bdev);
>  		return 1;
>  	}
>  

Again, please just leave 'bdev' on the previous lines.

If you make those few tweaks, please add:

Acked-by: Mike Snitzer <snitzer@redhat.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-06-23 20:20 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 15:28 [PATCH 00/10] reduce stack footprint printing bdev names Anton Suvorov
2021-06-02 15:28 ` [PATCH 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
2021-06-02 15:28 ` [PATCH 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
2021-06-02 17:18   ` Matthew Wilcox
2021-06-22 17:44     ` [PATCH v2 00/10] reduce stack footprint printing bdev names Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 01/10] drbd: reduce stack footprint in drbd_report_io_error() Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 02/10] dax: reduce stack footprint dealing with block device names Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 03/10] raid-md: " Anton Suvorov
2021-06-23  8:26         ` Guoqing Jiang
2021-06-22 17:44       ` [PATCH v2 04/10] dm: " Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 05/10] block: " Anton Suvorov
2021-06-23  7:45         ` Christoph Hellwig
2021-06-22 17:44       ` [PATCH v2 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params() Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 07/10] vfs: reduce stack footprint in __blkdev_put() Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 08/10] ext4: reduce stack footprint in ext4_end_bio() Anton Suvorov
2021-06-22 17:44       ` [PATCH v2 09/10] security: reduce stack footprint in loadpin_read_file() Anton Suvorov
2021-06-22 17:45     ` [PATCH v2 10/10] block: remove unused symbol bio_devname() Anton Suvorov
2021-06-02 15:28 ` [PATCH 03/10] raid-md: reduce stack footprint dealing with block device names Anton Suvorov
2021-06-02 15:28 ` [PATCH 04/10] dm: " Anton Suvorov
2021-06-23 20:20   ` Mike Snitzer
2021-06-02 15:28 ` [PATCH 05/10] block: " Anton Suvorov
2021-06-02 15:28 ` [PATCH 06/10] target: reduce stack footprint in iblock_show_configfs_dev_params() Anton Suvorov
2021-06-02 15:29 ` [PATCH 07/10] vfs: reduce stack footprint in __blkdev_put() Anton Suvorov
2021-06-02 15:29 ` [PATCH 08/10] ext4: reduce stack footprint in ext4_end_bio() Anton Suvorov
2021-06-02 15:29 ` [PATCH 09/10] security: reduce stack footprint in loadpin_read_file() Anton Suvorov
2021-06-02 15:29 ` [PATCH 10/10] block: remove unused symbol bio_devname() Anton Suvorov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).