From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [RFC PATCH 1/2] block: embed bdevname in struct block_device Date: Wed, 22 Aug 2012 17:28:51 +0800 Message-ID: <20120822092851.GJ2570@yliu-dev.sh.intel.com> References: <1344854040-15334-1-git-send-email-yuanhan.liu@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, Alexander Viro , Jens Axboe , Andrew Morton To: linux-kernel@vger.kernel.org Return-path: Content-Disposition: inline In-Reply-To: <1344854040-15334-1-git-send-email-yuanhan.liu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Mon, Aug 13, 2012 at 06:33:59PM +0800, Yuanhan Liu wrote: > 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. ping... (though it's a trivial RFC patch) Thanks, Yuanhan Liu > > Cc: Alexander Viro > Cc: Jens Axboe > Cc: Andrew Morton > Signed-off-by: Yuanhan Liu > --- > 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