remove not needed fields from struct block_device
Subsystems (10)
Christoph Hellwig
maintainerHi Jens,
this series put struct block_device on a bit of a diet by removing fields that are unused or rather pointless.
Christoph Hellwig
maintainerPATCH 1/7 floppy: use block_size
Use the block_size helper instead of open coding it. Also remove the check for a 0 block size, as that can't happen.
--- drivers/block/floppy.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/block/floppy.c +1 -6
@@ -4205,7 +4205,6 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)struct bio_vec bio_vec;struct page *page;struct rb0_cbdata cbdata; -size_t size; page =alloc_page (GFP_NOIO );if (!page) {
@@ -4213,15 +4212,11 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)return -ENOMEM ; } - size = bdev->bd_block_size; -if (!size) - size =1024 ; - cbdata.drive = drive;bio_init (&bio, &bio_vec,1 );bio_set_dev (&bio, bdev); -bio_add_page (&bio, page, size,0 ); +bio_add_page (&bio, page,block_size (bdev),0 ); bio.bi_iter.bi_sector =0 ; bio.bi_flags |= (1 <<BIO_QUIET );
Signature · 1 line
2.26.2
Re: [PATCH 1/7] floppy: use block_size
drivers/block/floppy.c static int __floppy_read_block_0(struct block_device *bdev, int drive) · line 4219
Quoted 4 lines · Christoph Hellwig
drivers/block/floppy.c +0
-4- size = bdev->bd_block_size; -if (!size) - size =1024 ; -
Why is this correct? block_size() only returns 'bdev->bd_block_size' but I cannot see where it's made sure bd_block_size is not 0. At least no calls to set_blocksize()
Johannes Thumshirn
Reviewed-byRe: [PATCH 1/7] floppy: use block_size
Quoted 10 lines · Johannes Thumshirn
drivers/block/floppy.c static int __floppy_read_block_0(struct block_device *bdev, int drive) · line 4219
Quoted 4 lines · Christoph Hellwig
drivers/block/floppy.c +0
-4- size = bdev->bd_block_size; -if (!size) - size =1024 ; -Why is this correct?
block_size()only returns 'bdev->bd_block_size' but I cannot see where it's made surebd_block_sizeis not 0. At least no calls toset_blocksize()
OK answered the question myself.
Christoph Hellwig
maintainerPATCH 2/7 dcssblk: don't set bd_block_size in ->open
In reply to Christoph Hellwigbd_block_size contains a value that matches the logic block size when opening, so the statement is redundant. Even if it wasn't the dumb assignment would cause a a mismatch with bd_inode->i_blkbits.
--- drivers/s390/block/dcssblk.c | 1 - 1 file changed, 1 deletion(-)
drivers/s390/block/dcssblk.c +0 -1
@@ -833,7 +833,6 @@ dcssblk_open(struct block_device *bdev, fmode_t mode) goto out; }atomic_inc (&dev_info->use_count); - bdev->bd_block_size =4096 ; rc =0 ; out:return rc;
Signature · 1 line
2.26.2
Re: [PATCH 2/7] dcssblk: don't set bd_block_size in ->open
Looks good,
Christoph Hellwig
maintainerPATCH 3/7 block: simplify set_init_blocksize
In reply to Christoph HellwigThe loop to increase the initial block size doesn't really make any sense, as the AND operation won't match for powers of two if it didn't for the initial block size.
--- fs/block_dev.c | 6 ------ 1 file changed, 6 deletions(-)
fs/block_dev.c +0 -6
@@ -106,13 +106,7 @@ EXPORT_SYMBOL(invalidate_bdev);static void set_init_blocksize (struct block_device *bdev) {unsigned bsize =bdev_logical_block_size (bdev); -loff_t size =i_size_read (bdev->bd_inode); -while (bsize <PAGE_SIZE ) { -if (size & bsize) -break ; - bsize <<=1 ; - } bdev->bd_block_size = bsize; bdev->bd_inode->i_blkbits =blksize_bits (bsize); }
Signature · 1 line
2.26.2
Christoph Hellwig
maintainerPATCH 4/7 block: remove the bd_block_size field from struct block_device
In reply to Christoph HellwigWe can trivially calculate the block size from the inodes i_blkbits variable. Use that instead of keeping two redundant copies of the information in slightly different formats.
--- fs/block_dev.c | 9 ++------- include/linux/blk_types.h | 1 - include/linux/blkdev.h | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-)
fs/block_dev.c +2 -7
@@ -105,10 +105,7 @@ EXPORT_SYMBOL(invalidate_bdev);static void set_init_blocksize (struct block_device *bdev) { -unsigned bsize =bdev_logical_block_size (bdev); - - bdev->bd_block_size = bsize; - bdev->bd_inode->i_blkbits =blksize_bits (bsize); + bdev->bd_inode->i_blkbits =blksize_bits (bdev_logical_block_size (bdev)); }int set_blocksize (struct block_device *bdev,int size)
@@ -122,9 +119,8 @@ int set_blocksize(struct block_device *bdev, int size)return -EINVAL ;/* Don't change the size if it is same as current */ -if (bdev->bd_block_size != size) { +if (bdev->bd_inode->i_blkbits !=blksize_bits (size)) {sync_blockdev (bdev); - bdev->bd_block_size = size; bdev->bd_inode->i_blkbits =blksize_bits (size);kill_bdev (bdev); }
@@ -889,7 +885,6 @@ struct block_device *bdget(dev_t dev) bdev->bd_contains =NULL ; bdev->bd_super =NULL ; bdev->bd_inode = inode; - bdev->bd_block_size =i_blocksize (inode); bdev->bd_part_count =0 ; bdev->bd_invalidated =0 ; inode->i_mode =S_IFBLK ;
include/linux/blk_types.h +0 -1
@@ -33,7 +33,6 @@ struct block_device {struct list_head bd_holder_disks;#endif struct block_device * bd_contains; -unsigned bd_block_size;u8 bd_partno;struct hd_struct * bd_part;/* number of times partitions within this device have been opened. */
include/linux/blkdev.h +1 -1
@@ -1548,7 +1548,7 @@ static inline unsigned int blksize_bits(unsigned int size)static inline unsigned int block_size (struct block_device *bdev) { -return bdev->bd_block_size; +return 1 << bdev->bd_inode->i_blkbits; }int kblockd_schedule_work (struct work_struct *work);
Signature · 1 line
2.26.2
Re: [PATCH 4/7] block: remove the bd_block_size field from struct block_device
Looks good,
Christoph Hellwig
maintainerPATCH 5/7 block: remove the bd_queue field from struct block_device
In reply to Christoph HellwigJust use bd_disk->queue instead.
--- drivers/dax/super.c | 2 +- drivers/md/md.c | 2 +- drivers/nvme/target/core.c | 2 +- fs/block_dev.c | 11 ++++------- fs/direct-io.c | 4 ++-- fs/xfs/xfs_pwork.c | 2 +- include/linux/blk_types.h | 1 - mm/swapfile.c | 2 +- 8 files changed, 11 insertions(+), 15 deletions(-)
drivers/dax/super.c +1 -1
@@ -59,7 +59,7 @@ EXPORT_SYMBOL(bdev_dax_pgoff);#if IS_ENABLED (CONFIG_FS_DAX )struct dax_device *fs_dax_get_by_bdev (struct block_device *bdev) { -if (!blk_queue_dax (bdev->bd_queue)) +if (!blk_queue_dax (bdev->bd_disk->queue))return NULL ;return dax_get_by_host (bdev->bd_disk->disk_name); }
drivers/md/md.c +1 -1
@@ -199,7 +199,7 @@ static int rdevs_init_serial(struct mddev *mddev)static int rdev_need_serial (struct md_rdev *rdev) {return (rdev && rdev->mddev->bitmap_info.max_write_behind >0 && - rdev->bdev->bd_queue->nr_hw_queues !=1 && + rdev->bdev->bd_disk->queue->nr_hw_queues !=1 &&test_bit (WriteMostly, &rdev->flags)); }
drivers/nvme/target/core.c +1 -1
@@ -467,7 +467,7 @@ static int nvmet_p2pmem_ns_enable(struct nvmet_ns *ns)return -EINVAL ; } -if (!blk_queue_pci_p2pdma (ns->bdev->bd_queue)) { +if (!blk_queue_pci_p2pdma (ns->bdev->bd_disk->queue)) {pr_err ("peer-to-peer DMA is not supported by the driver of %s\n" , ns->device_path);return -EINVAL ;
fs/block_dev.c +4 -7
@@ -693,12 +693,12 @@ int bdev_read_page(struct block_device *bdev, sector_t sector,if (!ops->rw_page ||bdev_get_integrity (bdev))return result; - result =blk_queue_enter (bdev->bd_queue,0 ); + result =blk_queue_enter (bdev->bd_disk->queue,0 );if (result)return result; result = ops->rw_page (bdev, sector +get_start_sect (bdev), page,REQ_OP_READ ); -blk_queue_exit (bdev->bd_queue); +blk_queue_exit (bdev->bd_disk->queue);return result; }
@@ -729,7 +729,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector,if (!ops->rw_page ||bdev_get_integrity (bdev))return -EOPNOTSUPP ; - result =blk_queue_enter (bdev->bd_queue,0 ); + result =blk_queue_enter (bdev->bd_disk->queue,0 );if (result)return result;
@@ -742,7 +742,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector,clean_page_buffers (page);unlock_page (page); } -blk_queue_exit (bdev->bd_queue); +blk_queue_exit (bdev->bd_disk->queue);return result; }
@@ -1568,7 +1568,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)if (!bdev->bd_openers) { first_open = true; bdev->bd_disk = disk; - bdev->bd_queue = disk->queue; bdev->bd_contains = bdev; bdev->bd_partno = partno;
@@ -1589,7 +1588,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)disk_put_part (bdev->bd_part); bdev->bd_part =NULL ; bdev->bd_disk =NULL ; - bdev->bd_queue =NULL ;mutex_unlock (&bdev->bd_mutex);disk_unblock_events (disk);put_disk_and_module (disk);
@@ -1666,7 +1664,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)disk_put_part (bdev->bd_part); bdev->bd_disk =NULL ; bdev->bd_part =NULL ; - bdev->bd_queue =NULL ;if (bdev != bdev->bd_contains)__blkdev_put (bdev->bd_contains, mode,1 ); bdev->bd_contains =NULL ;
fs/direct-io.c +2 -2
@@ -1387,8 +1387,8 @@ ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,* Attempt to prefetch the pieces we likely need later. */ prefetch (&bdev->bd_disk->part_tbl); -prefetch (bdev->bd_queue); -prefetch ((char *)bdev->bd_queue +SMP_CACHE_BYTES ); +prefetch (bdev->bd_disk->queue); +prefetch ((char *)bdev->bd_disk->queue +SMP_CACHE_BYTES );return do_blockdev_direct_IO (iocb, inode, bdev, iter, get_block, end_io, submit_io, flags);
fs/xfs/xfs_pwork.c +1 -1
@@ -132,5 +132,5 @@ xfs_pwork_guess_datadev_parallelism(* For now we'll go with the most conservative setting possible, * which is two threads for an SSD and 1 thread everywhere else. */ -return blk_queue_nonrot (btp->bt_bdev->bd_queue) ?2 :1 ; +return blk_queue_nonrot (btp->bt_bdev->bd_disk->queue) ?2 :1 ; }
include/linux/blk_types.h +0 -1
@@ -39,7 +39,6 @@ struct block_device {unsigned bd_part_count;int bd_invalidated;struct gendisk * bd_disk; -struct request_queue * bd_queue;struct backing_dev_info *bd_bdi;struct list_head bd_list;/*
mm/swapfile.c +1 -1
@@ -2929,7 +2929,7 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)* write only restriction. Hence zoned block devices are not * suitable for swapping. Disallow them here. */ -if (blk_queue_is_zoned (p->bdev->bd_queue)) +if (blk_queue_is_zoned (p->bdev->bd_disk->queue))return -EINVAL ; p->flags |=SWP_BLKDEV ; }else if (S_ISREG (inode->i_mode)) {
Signature · 1 line
2.26.2
Re: [PATCH 5/7] block: remove the bd_queue field from struct block_device
Looks good,
Christoph Hellwig
maintainerPATCH 6/7 block: remove the unused bd_private field from struct block_device
In reply to Christoph Hellwig--- include/linux/blk_types.h | 7 ------- 1 file changed, 7 deletions(-)
include/linux/blk_types.h +0 -7
@@ -41,13 +41,6 @@ struct block_device {struct gendisk * bd_disk;struct backing_dev_info *bd_bdi;struct list_head bd_list; -/* -* Private data. You must have bd_claim'ed the block_device -* to use this. NOTE: bd_claim allows an owner to claim -* the same device multiple times, the owner must take special -* care to not mess up bd_private for that case. -*/ -unsigned long bd_private;/* The counter of freeze processes */ int bd_fsfreeze_count;
Signature · 1 line
2.26.2
Re: [PATCH 6/7] block: remove the unused bd_private field from struct block_device
Looks good,
Christoph Hellwig
maintainerPATCH 7/7 block: remove the all_bdevs list
In reply to Christoph HellwigInstead just iterate over the inodes for the block device superblock.
--- fs/block_dev.c | 22 +++++++--------------- include/linux/blk_types.h | 1 - 2 files changed, 7 insertions(+), 16 deletions(-)
fs/block_dev.c +7 -15
@@ -773,7 +773,6 @@ static void init_once(void *foo)memset (bdev,0 ,sizeof (*bdev));mutex_init (&bdev->bd_mutex); -INIT_LIST_HEAD (&bdev->bd_list);#ifdef CONFIG_SYSFS INIT_LIST_HEAD (&bdev->bd_holder_disks);#endif
@@ -789,9 +788,6 @@ static void bdev_evict_inode(struct inode *inode)truncate_inode_pages_final (&inode->i_data);invalidate_inode_buffers (inode);/* is it needed here? */ clear_inode (inode); -spin_lock (&bdev_lock); -list_del_init (&bdev->bd_list); -spin_unlock (&bdev_lock);/* Detach inode from wb early as bdi_put() may free bdi->wb */ inode_detach_wb (inode);if (bdev->bd_bdi != &noop_backing_dev_info) {
@@ -866,8 +862,6 @@ static int bdev_set(struct inode *inode, void *data)return 0 ; } -static LIST_HEAD (all_bdevs); -struct block_device *bdget (dev_t dev) {struct block_device *bdev;
@@ -892,9 +886,6 @@ struct block_device *bdget(dev_t dev) inode->i_bdev = bdev; inode->i_data.a_ops = &def_blk_aops;mapping_set_gfp_mask (&inode->i_data,GFP_USER ); -spin_lock (&bdev_lock); -list_add (&bdev->bd_list, &all_bdevs); -spin_unlock (&bdev_lock);unlock_new_inode (inode); }return bdev;
@@ -915,13 +906,14 @@ EXPORT_SYMBOL(bdgrab);long nr_blockdev_pages (void ) { -struct block_device *bdev; +struct inode *inode;long ret =0 ; -spin_lock (&bdev_lock); -list_for_each_entry (bdev, &all_bdevs, bd_list) { - ret += bdev->bd_inode->i_mapping->nrpages; - } -spin_unlock (&bdev_lock); + +spin_lock (&blockdev_superblock->s_inode_list_lock); +list_for_each_entry (inode, &blockdev_superblock->s_inodes, i_sb_list) + ret += inode->i_mapping->nrpages; +spin_unlock (&blockdev_superblock->s_inode_list_lock); +return ret; }
include/linux/blk_types.h +0 -1
@@ -40,7 +40,6 @@ struct block_device {int bd_invalidated;struct gendisk * bd_disk;struct backing_dev_info *bd_bdi; -struct list_head bd_list;/* The counter of freeze processes */ int bd_fsfreeze_count;
Signature · 1 line
2.26.2
Re: [PATCH 7/7] block: remove the all_bdevs list
Looks good,
Christoph Hellwig
maintainerAny more comments on this series?
Quoted 4 lines · Christoph Hellwig
Hi Jens,
this series put struct
block_deviceon a bit of a diet by removing fields that are unused or rather pointless.
---end quoted text---
Quoted 4 lines · Christoph Hellwig
Hi Jens,
this series put struct
block_deviceon a bit of a diet by removing fields that are unused or rather pointless.
Applied, thanks.
Signature · 1 line
Jens Axboe