linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org,
	Yuanhan Liu <yuanhan.liu@linux.intel.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Jens Axboe <axboe@kernel.dk>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [RFC PATCH 1/2] block: embed bdevname in struct block_device
Date: Mon, 13 Aug 2012 18:33:59 +0800	[thread overview]
Message-ID: <1344854040-15334-1-git-send-email-yuanhan.liu@linux.intel.com> (raw)

Embed block device name in struct block_device, thus we can replace
the following code:
	char b[BDEVNAME_SIZE];
	printk(KERN_XXX "...%s..\n", bdevname(bdev, b);

with a much simpler and less stack usage version:
	printk(KERN_XXX "...%s..\n", bdev->bd_name);

This is a RFC version, which I just included one sample with this change
appiled. If this patch makes sense to you, I will file more patches to
apply this change.

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 fs/block_dev.c     |    2 ++
 include/linux/fs.h |    3 ++-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1e51919..5e796e58 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1213,6 +1213,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 			}
 			bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9);
 		}
+
+		disk_name(bdev->bd_disk, bdev->bd_part->partno, bdev->bd_name);
 	} else {
 		if (bdev->bd_contains == bdev) {
 			ret = 0;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index aa11047..98ea89d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -689,6 +689,7 @@ struct address_space {
 	 */
 struct request_queue;
 
+#define BDEVNAME_SIZE	32	/* Largest string for a blockdev identifier */
 struct block_device {
 	dev_t			bd_dev;  /* not a kdev_t - it's a search key */
 	int			bd_openers;
@@ -724,6 +725,7 @@ struct block_device {
 	int			bd_fsfreeze_count;
 	/* Mutex for freeze */
 	struct mutex		bd_fsfreeze_mutex;
+	char 			bd_name[BDEVNAME_SIZE];
 };
 
 /*
@@ -2323,7 +2325,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name)
 }
 
 /* fs/block_dev.c */
-#define BDEVNAME_SIZE	32	/* Largest string for a blockdev identifier */
 #define BDEVT_SIZE	10	/* Largest string for MAJ:MIN for blkdev */
 
 #ifdef CONFIG_BLOCK
-- 
1.7.7.6


             reply	other threads:[~2012-08-13 10:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-13 10:33 Yuanhan Liu [this message]
2012-08-13 10:34 ` [RFC PATCH 2/2] vfs: replace bdevname(bdev, b) with bdev->bd_name Yuanhan Liu
2012-08-22  9:28 ` [RFC PATCH 1/2] block: embed bdevname in struct block_device Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1344854040-15334-1-git-send-email-yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).