Open block devices as files
Subsystems (44)
Christian Brauner
maintainerQuoted 1 line · Christoph Hellwig
Do you have a git tree for this series?
b4/vfs-bdev-file on vfs.git
Christian Brauner
maintainercover fs & block: remove bd_inode
In reply to Christian BraunerHey Christoph,
Hey Jan,
This is an attempt to remove bdev->bd_inode and restrict direct access to the block layer, block drivers and few instances in fs/buffer.c where it's needed. Suggestions to do better welcome!
Thanks!
Christian
---
Christian Brauner (2):
fs & block: remove bdev->bd_inode
fs,drivers: remove bdev_inode() usage outside of block layer and drivers
block/bdev.c | 48 ++++++++++-------- block/blk-zoned.c | 4 +- block/fops.c | 4 +- block/genhd.c | 8 +-- block/ioctl.c | 8 +-- block/partitions/core.c | 11 ++-- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/md/bcache/super.c | 7 +-- drivers/md/md-bitmap.c | 2 +- drivers/mtd/devices/block2mtd.c | 4 +- drivers/s390/block/dasd_ioctl.c | 2 +- drivers/scsi/scsicam.c | 2 +- fs/affs/file.c | 2 +- fs/bcachefs/util.h | 5 -- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/disk-io.c | 17 ++++--- fs/btrfs/disk-io.h | 4 +- fs/btrfs/inode.c | 2 +- fs/btrfs/super.c | 2 +- fs/btrfs/volumes.c | 26 +++++----- fs/btrfs/volumes.h | 2 +- fs/btrfs/zoned.c | 18 ++++--- fs/btrfs/zoned.h | 4 +- fs/buffer.c | 95 +++++++++++++++++++---------------- fs/cramfs/inode.c | 2 +- fs/direct-io.c | 7 +-- fs/erofs/data.c | 5 +- fs/erofs/internal.h | 1 + fs/erofs/zmap.c | 2 +- fs/ext2/inode.c | 4 +- fs/ext2/xattr.c | 2 +- fs/ext4/inode.c | 8 +-- fs/ext4/mmp.c | 2 +- fs/ext4/page-io.c | 4 +- fs/ext4/super.c | 7 ++- fs/ext4/xattr.c | 2 +- fs/f2fs/data.c | 7 ++- fs/f2fs/f2fs.h | 1 + fs/fuse/dax.c | 2 +- fs/gfs2/aops.c | 2 +- fs/gfs2/bmap.c | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/ops_fstype.c | 2 +- fs/hpfs/file.c | 2 +- fs/iomap/buffered-io.c | 8 +-- fs/iomap/direct-io.c | 10 ++-- fs/iomap/swapfile.c | 2 +- fs/iomap/trace.h | 2 +- fs/jbd2/commit.c | 2 +- fs/jbd2/journal.c | 29 ++++++----- fs/jbd2/recovery.c | 6 +-- fs/jbd2/revoke.c | 10 ++-- fs/jbd2/transaction.c | 8 +-- fs/mpage.c | 26 ++++++---- fs/nilfs2/btnode.c | 4 +- fs/nilfs2/gcinode.c | 2 +- fs/nilfs2/mdt.c | 2 +- fs/nilfs2/page.c | 4 +- fs/nilfs2/recovery.c | 20 ++++---- fs/nilfs2/segment.c | 2 +- fs/nilfs2/the_nilfs.c | 1 + fs/nilfs2/the_nilfs.h | 1 + fs/ntfs/aops.c | 6 +-- fs/ntfs/file.c | 2 +- fs/ntfs/mft.c | 4 +- fs/ntfs3/fsntfs.c | 8 +-- fs/ntfs3/inode.c | 2 +- fs/ntfs3/super.c | 2 +- fs/ocfs2/aops.c | 2 +- fs/ocfs2/journal.c | 2 +- fs/reiserfs/fix_node.c | 2 +- fs/reiserfs/journal.c | 10 ++-- fs/reiserfs/prints.c | 4 +- fs/reiserfs/reiserfs.h | 6 +-- fs/reiserfs/stree.c | 2 +- fs/reiserfs/tail_conversion.c | 2 +- fs/xfs/xfs_iomap.c | 4 +- fs/zonefs/file.c | 4 +- include/linux/blk_types.h | 1 - include/linux/blkdev.h | 6 ++- include/linux/buffer_head.h | 68 ++++++++++++++++--------- include/linux/fs.h | 4 +- include/linux/iomap.h | 13 ++++- include/linux/jbd2.h | 10 ++-- include/trace/events/block.h | 2 +- 86 files changed, 363 insertions(+), 291 deletions(-)
---
base-commit: 0bd1bf95a554f5f877724c27dbe33d4db0af4d0c
change-id: 20240129-vfs-bdev-file-bd_inode-385a56c57a51
Christian Brauner
maintainerRFC PATCH 1/2 fs & block: remove bdev->bd_inode
In prior patches we introduced the ability to open block devices as files and made all filesystems stash the opened block device files. With this patch we remove bdev->bd_inode from struct block_device.
Using files allows us to stop passing struct block_device directly to almost all buffer_head helpers. Whenever access to the inode of the block device is needed bdev_file_inode(bdev_file) can be used instead of bdev->bd_inode.
The only user that doesn't rely on files is the block layer itself in block/fops.c where we only have access to the block device. As the bdev filesystem doesn't open block devices as files obviously.
This introduces a union into struct buffer_head and struct iomap. The union encompasses both struct block_device and struct file. In both cases a flag is used to differentiate whether a block device or a proper file was stashed. Simple accessors bh_bdev() and iomap_bdev() are used to return the block device in the really low-level functions where it's needed. These are overall just a few callsites.
The block layer itself continues to get direct access to the block device inode from the block device. But afaict, it isn't necessary to have bdev->bd_inode for this. Instead, the few places that need it can use the bdev_inode() helper which returns the vfs_inode stashed in struct bdev_inode.
That helper is currently exposed to a few non-block layer and block drivers such as btrfs. The next patch fixes this.
--- block/bdev.c | 48 ++++++++++-------- block/blk-zoned.c | 4 +- block/fops.c | 4 +- block/genhd.c | 8 +-- block/ioctl.c | 8 +-- block/partitions/core.c | 11 ++-- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/md/bcache/super.c | 2 +- drivers/md/md-bitmap.c | 2 +- drivers/mtd/devices/block2mtd.c | 4 +- drivers/s390/block/dasd_ioctl.c | 2 +- drivers/scsi/scsicam.c | 2 +- fs/affs/file.c | 2 +- fs/bcachefs/util.h | 2 +- fs/btrfs/disk-io.c | 6 +-- fs/btrfs/inode.c | 2 +- fs/btrfs/volumes.c | 2 +- fs/btrfs/zoned.c | 2 +- fs/buffer.c | 95 +++++++++++++++++++---------------- fs/cramfs/inode.c | 2 +- fs/direct-io.c | 7 +-- fs/erofs/data.c | 5 +- fs/erofs/internal.h | 1 + fs/erofs/zmap.c | 2 +- fs/ext2/inode.c | 4 +- fs/ext2/xattr.c | 2 +- fs/ext4/inode.c | 8 +-- fs/ext4/mmp.c | 2 +- fs/ext4/page-io.c | 4 +- fs/ext4/super.c | 7 ++- fs/ext4/xattr.c | 2 +- fs/f2fs/data.c | 7 ++- fs/f2fs/f2fs.h | 1 + fs/fuse/dax.c | 2 +- fs/gfs2/aops.c | 2 +- fs/gfs2/bmap.c | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/ops_fstype.c | 2 +- fs/hpfs/file.c | 2 +- fs/iomap/buffered-io.c | 8 +-- fs/iomap/direct-io.c | 10 ++-- fs/iomap/swapfile.c | 2 +- fs/iomap/trace.h | 2 +- fs/jbd2/commit.c | 2 +- fs/jbd2/journal.c | 29 ++++++----- fs/jbd2/recovery.c | 6 +-- fs/jbd2/revoke.c | 10 ++-- fs/jbd2/transaction.c | 8 +-- fs/mpage.c | 26 ++++++---- fs/nilfs2/btnode.c | 4 +- fs/nilfs2/gcinode.c | 2 +- fs/nilfs2/mdt.c | 2 +- fs/nilfs2/page.c | 4 +- fs/nilfs2/recovery.c | 20 ++++---- fs/nilfs2/segment.c | 2 +- fs/nilfs2/the_nilfs.c | 1 + fs/nilfs2/the_nilfs.h | 1 + fs/ntfs/aops.c | 6 +-- fs/ntfs/file.c | 2 +- fs/ntfs/mft.c | 4 +- fs/ntfs3/fsntfs.c | 8 +-- fs/ntfs3/inode.c | 2 +- fs/ntfs3/super.c | 2 +- fs/ocfs2/aops.c | 2 +- fs/ocfs2/journal.c | 2 +- fs/reiserfs/fix_node.c | 2 +- fs/reiserfs/journal.c | 10 ++-- fs/reiserfs/prints.c | 4 +- fs/reiserfs/reiserfs.h | 6 +-- fs/reiserfs/stree.c | 2 +- fs/reiserfs/tail_conversion.c | 2 +- fs/xfs/xfs_iomap.c | 4 +- fs/zonefs/file.c | 4 +- include/linux/blk_types.h | 1 - include/linux/blkdev.h | 6 ++- include/linux/buffer_head.h | 68 ++++++++++++++++--------- include/linux/fs.h | 4 +- include/linux/iomap.h | 13 ++++- include/linux/jbd2.h | 10 ++-- include/trace/events/block.h | 2 +- 81 files changed, 326 insertions(+), 255 deletions(-)
block/bdev.c +27 -21
@@ -43,6 +43,12 @@ static inline struct bdev_inode *BDEV_I(struct inode *inode) return container_of(inode, struct bdev_inode, vfs_inode); } +struct inode *bdev_inode (struct block_device *bdev) +{ + return &container_of(bdev, struct bdev_inode, bdev)->vfs_inode; +} +EXPORT_SYMBOL_GPL (bdev_inode); +struct block_device *I_BDEV (struct inode *inode) {return &BDEV_I (inode)->bdev;
@@ -57,7 +63,7 @@ EXPORT_SYMBOL(file_bdev);static void bdev_write_inode (struct block_device *bdev) { -struct inode *inode = bdev->bd_inode; +struct inode *inode =bdev_inode (bdev);int ret;spin_lock (&inode->i_lock);
@@ -76,7 +82,7 @@ static void bdev_write_inode(struct block_device *bdev)/* Kill _all_ buffers and pagecache , dirty or not.. */ static void kill_bdev (struct block_device *bdev) { -struct address_space *mapping = bdev->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (bdev)->i_mapping;if (mapping_empty (mapping))return ;
@@ -88,7 +94,7 @@ static void kill_bdev(struct block_device *bdev)/* Invalidate clean unused buffers and pagecache. */ void invalidate_bdev (struct block_device *bdev) { -struct address_space *mapping = bdev->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (bdev)->i_mapping;if (mapping->nrpages) {invalidate_bh_lrus ();
@@ -116,7 +122,7 @@ int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode, goto invalidate; } -truncate_inode_pages_range (bdev->bd_inode->i_mapping, lstart, lend); +truncate_inode_pages_range (bdev_inode (bdev)->i_mapping, lstart, lend);if (!(mode &BLK_OPEN_EXCL ))bd_abort_claiming (bdev, truncate_bdev_range);return 0 ;
@@ -126,7 +132,7 @@ int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode,* Someone else has handle exclusively open. Try invalidating instead. * The 'end' argument is inclusive so the rounding is safe. */ -return invalidate_inode_pages2_range (bdev->bd_inode->i_mapping, +return invalidate_inode_pages2_range (bdev_inode (bdev)->i_mapping, lstart >>PAGE_SHIFT , lend >>PAGE_SHIFT ); }
@@ -134,14 +140,14 @@ int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode,static void set_init_blocksize (struct block_device *bdev) {unsigned int bsize =bdev_logical_block_size (bdev); -loff_t size =i_size_read (bdev->bd_inode); +loff_t size =i_size_read (bdev_inode (bdev));while (bsize <PAGE_SIZE ) {if (size & bsize)break ; bsize <<=1 ; } - bdev->bd_inode->i_blkbits =blksize_bits (bsize); +bdev_inode (bdev)->i_blkbits =blksize_bits (bsize); }int set_blocksize (struct block_device *bdev,int size)
@@ -155,9 +161,9 @@ 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_inode->i_blkbits !=blksize_bits (size)) { +if (bdev_inode (bdev)->i_blkbits !=blksize_bits (size)) {sync_blockdev (bdev); - bdev->bd_inode->i_blkbits =blksize_bits (size); +bdev_inode (bdev)->i_blkbits =blksize_bits (size);kill_bdev (bdev); }return 0 ;
@@ -192,7 +198,7 @@ int sync_blockdev_nowait(struct block_device *bdev) {if (!bdev)return 0 ; -return filemap_flush (bdev->bd_inode->i_mapping); +return filemap_flush (bdev_inode (bdev)->i_mapping); }EXPORT_SYMBOL_GPL (sync_blockdev_nowait);
@@ -204,13 +210,13 @@ int sync_blockdev(struct block_device *bdev) {if (!bdev)return 0 ; -return filemap_write_and_wait (bdev->bd_inode->i_mapping); +return filemap_write_and_wait (bdev_inode (bdev)->i_mapping); }EXPORT_SYMBOL (sync_blockdev);int sync_blockdev_range (struct block_device *bdev,loff_t lstart,loff_t lend) { -return filemap_write_and_wait_range (bdev->bd_inode->i_mapping, +return filemap_write_and_wait_range (bdev_inode (bdev)->i_mapping, lstart, lend); }EXPORT_SYMBOL (sync_blockdev_range);
@@ -412,7 +418,6 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)spin_lock_init (&bdev->bd_size_lock);mutex_init (&bdev->bd_holder_lock); bdev->bd_partno = partno; - bdev->bd_inode = inode; bdev->bd_queue = disk->queue;if (partno) bdev->bd_has_submit_bio = disk->part0->bd_has_submit_bio;
@@ -430,19 +435,20 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)void bdev_set_nr_sectors (struct block_device *bdev,sector_t sectors) {spin_lock (&bdev->bd_size_lock); -i_size_write (bdev->bd_inode, (loff_t )sectors <<SECTOR_SHIFT ); +i_size_write (bdev_inode (bdev), (loff_t )sectors <<SECTOR_SHIFT ); bdev->bd_nr_sectors = sectors;spin_unlock (&bdev->bd_size_lock); }void bdev_add (struct block_device *bdev,dev_t dev) { +struct inode *inode =bdev_inode (bdev);if (bdev_stable_writes (bdev)) -mapping_set_stable_writes (bdev->bd_inode->i_mapping); +mapping_set_stable_writes (inode->i_mapping); bdev->bd_dev = dev; - bdev->bd_inode->i_rdev = dev; - bdev->bd_inode->i_ino = dev; -insert_inode_hash (bdev->bd_inode); + inode->i_rdev = dev; + inode->i_ino = dev; +insert_inode_hash (bdev_inode (bdev)); }long nr_blockdev_pages (void )
@@ -901,7 +907,7 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder, bdev_file->f_mode |=FMODE_BUF_RASYNC |FMODE_CAN_ODIRECT ;if (bdev_nowait (bdev)) bdev_file->f_mode |=FMODE_NOWAIT ; - bdev_file->f_mapping = bdev->bd_inode->i_mapping; + bdev_file->f_mapping =bdev_inode (bdev)->i_mapping; bdev_file->f_wb_err =filemap_sample_wb_err (bdev_file->f_mapping); bdev_file->private_data = holder;
@@ -971,7 +977,7 @@ struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder, blk_fops = &def_blk_fops_restricted; else blk_fops = &def_blk_fops; - bdev_file =alloc_file_pseudo_noaccount (bdev->bd_inode, + bdev_file =alloc_file_pseudo_noaccount (bdev_inode (bdev), blockdev_mnt,"" , flags |O_LARGEFILE , blk_fops);if (IS_ERR (bdev_file)) {blkdev_put_no_open (bdev);
@@ -979,7 +985,7 @@ struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder, } bdev_file->f_mode &= ~FMODE_OPENED ; -ihold (bdev->bd_inode); +ihold (bdev_inode (bdev)); ret =bdev_open (bdev, mode, holder, hops, bdev_file);if (ret) {fput (bdev_file);
block/blk-zoned.c +2 -2
@@ -401,7 +401,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, op =REQ_OP_ZONE_RESET ;/* Invalidate the page cache, including dirty pages. */ -filemap_invalidate_lock (bdev->bd_inode->i_mapping); +filemap_invalidate_lock (bdev_inode (bdev)->i_mapping); ret =blkdev_truncate_zone_range (bdev, mode, &zrange);if (ret) goto fail;
@@ -424,7 +424,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, fail:if (cmd ==BLKRESETZONE ) -filemap_invalidate_unlock (bdev->bd_inode->i_mapping); +filemap_invalidate_unlock (bdev_inode (bdev)->i_mapping);return ret; }
block/fops.c +3 -1
@@ -381,6 +381,7 @@ static int blkdev_iomap_begin(struct inode *inode, loff_t offset, loff_t length,loff_t isize =i_size_read (inode); iomap->bdev = bdev; + iomap->flags |=IOMAP_F_BDEV ; iomap->offset =ALIGN_DOWN (offset,bdev_logical_block_size (bdev));if (iomap->offset >= isize)return -EIO ;
@@ -402,6 +403,7 @@ static int blkdev_get_block(struct inode *inode, sector_t iblock, bh->b_bdev =I_BDEV (inode); bh->b_blocknr = iblock;set_buffer_mapped (bh); +set_buffer_bdev (bh);return 0 ; }
@@ -665,7 +667,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) {struct file *file = iocb->ki_filp;struct block_device *bdev =I_BDEV (file->f_mapping->host); -struct inode *bd_inode = bdev->bd_inode; +struct inode *bd_inode =bdev_inode (bdev);loff_t size =bdev_nr_bytes (bdev);size_t shorted =0 ;ssize_t ret;
block/genhd.c +4 -4
@@ -656,7 +656,7 @@ void del_gendisk(struct gendisk *disk)*/ mutex_lock (&disk->open_mutex);xa_for_each (&disk->part_tbl, idx, part) -remove_inode_hash (part->bd_inode); +remove_inode_hash (bdev_inode (part));mutex_unlock (&disk->open_mutex);/*
@@ -745,7 +745,7 @@ void invalidate_disk(struct gendisk *disk)struct block_device *bdev = disk->part0;invalidate_bdev (bdev); - bdev->bd_inode->i_mapping->wb_err =0 ; +bdev_inode (bdev)->i_mapping->wb_err =0 ;set_capacity (disk,0 ); }EXPORT_SYMBOL (invalidate_disk);
@@ -1191,7 +1191,7 @@ static void disk_release(struct device *dev)if (test_bit (GD_ADDED , &disk->state) && disk->fops->free_disk) disk->fops->free_disk (disk); -iput (disk->part0->bd_inode);/* frees the disk */ +iput (bdev_inode (disk->part0));/* frees the disk */ }static int block_uevent (const struct device *dev,struct kobj_uevent_env *env)
@@ -1381,7 +1381,7 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id, out_destroy_part_tbl:xa_destroy (&disk->part_tbl); disk->part0->bd_disk =NULL ; -iput (disk->part0->bd_inode); +iput (bdev_inode (disk->part0)); out_free_bdi:bdi_put (disk->bdi); out_free_bioset:
block/ioctl.c +4 -4
@@ -92,7 +92,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode, {uint64_t range[2 ];uint64_t start, len; -struct inode *inode = bdev->bd_inode; +struct inode *inode =bdev_inode (bdev);int err;if (!(mode &BLK_OPEN_WRITE ))
@@ -146,12 +146,12 @@ static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,if (start + len >bdev_nr_bytes (bdev))return -EINVAL ; -filemap_invalidate_lock (bdev->bd_inode->i_mapping); +filemap_invalidate_lock (bdev_inode (bdev)->i_mapping); err =truncate_bdev_range (bdev, mode, start, start + len -1 );if (!err) err =blkdev_issue_secure_erase (bdev, start >>9 , len >>9 ,GFP_KERNEL ); -filemap_invalidate_unlock (bdev->bd_inode->i_mapping); +filemap_invalidate_unlock (bdev_inode (bdev)->i_mapping);return err; }
@@ -161,7 +161,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode, {uint64_t range[2 ];uint64_t start, end, len; -struct inode *inode = bdev->bd_inode; +struct inode *inode =bdev_inode (bdev);int err;if (!(mode &BLK_OPEN_WRITE ))
block/partitions/core.c +6 -5
@@ -242,8 +242,9 @@ static const struct attribute_group *part_attr_groups[] = {static void part_release (struct device *dev) { -put_disk (dev_to_bdev (dev)->bd_disk); -iput (dev_to_bdev (dev)->bd_inode); +struct block_device *bdev =dev_to_bdev (dev); +put_disk (bdev->bd_disk); +iput (bdev_inode (bdev)); }static int part_uevent (const struct device *dev,struct kobj_uevent_env *env)
@@ -475,7 +476,7 @@ int bdev_del_partition(struct gendisk *disk, int partno)* Just delete the partition and invalidate it. */ -remove_inode_hash (part->bd_inode); +remove_inode_hash (bdev_inode (part));invalidate_bdev (part);drop_partition (part); ret =0 ;
@@ -661,7 +662,7 @@ int bdev_disk_changed(struct gendisk *disk, bool invalidate)* it cannot be looked up any more even when openers * still hold references. */ -remove_inode_hash (part->bd_inode); +remove_inode_hash (bdev_inode (part));/* * If @disk->open_partitions isn't elevated but there's
@@ -710,7 +711,7 @@ EXPORT_SYMBOL_GPL(bdev_disk_changed);void *read_part_sector (struct parsed_partitions *state,sector_t n,Sector *p) { -struct address_space *mapping = state->disk->part0->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (state->disk->part0)->i_mapping;struct folio *folio;if (n >=get_capacity (state->disk)) {
drivers/gpu/drm/drm_gem_vram_helper.c +1 -1
@@ -935,7 +935,7 @@ static int bo_driver_move(struct ttm_buffer_object *bo,static int bo_driver_io_mem_reserve (struct ttm_device *bdev,struct ttm_resource *mem) { -struct drm_vram_mm *vmm =drm_vram_mm_of_bdev (bdev); +struct drm_vram_mm *vmm =drm_vram_mm_obdev_file (bdev);switch (mem->mem_type) {case TTM_PL_SYSTEM :/* nothing to do */
drivers/md/bcache/super.c +1 -1
@@ -171,7 +171,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,struct page *page;unsigned int i; - page =read_cache_page_gfp (bdev->bd_inode->i_mapping, + page =read_cache_page_gfp (bdev_inode (bdev)->i_mapping,SB_OFFSET >>PAGE_SHIFT ,GFP_KERNEL );if (IS_ERR (page))return "IO error" ;
drivers/md/md-bitmap.c +1 -1
@@ -380,7 +380,7 @@ static int read_file_page(struct file *file, unsigned long index, } bh->b_blocknr = block; - bh->b_bdev = inode->i_sb->s_bdev; + bh->b_bdev_file = inode->i_sb->s_bdev_file;if (count < blocksize) count =0 ;else
drivers/mtd/devices/block2mtd.c +2 -2
@@ -291,7 +291,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, goto err_free_block2mtd; } -if ((long )bdev->bd_inode->i_size % erase_size) { +if ((long )bdev_inode (bdev)->i_size % erase_size) {pr_err ("erasesize must be a divisor of device size\n" ); goto err_free_block2mtd; }
@@ -309,7 +309,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, dev->mtd.name = name; - dev->mtd.size = bdev->bd_inode->i_size &PAGE_MASK ; + dev->mtd.size =bdev_inode (bdev)->i_size &PAGE_MASK ; dev->mtd.erasesize = erase_size; dev->mtd.writesize =1 ; dev->mtd.writebufsize =PAGE_SIZE ;
drivers/s390/block/dasd_ioctl.c +1 -1
@@ -221,7 +221,7 @@ dasd_format(struct dasd_block *block, struct format_data_t *fdata)* enabling the device later. */ if (fdata->start_unit ==0 ) { - block->gdp->part0->bd_inode->i_blkbits = +bdev_inode (block->gdp->part0)->i_blkbits =blksize_bits (fdata->blksize); }
drivers/scsi/scsicam.c +1 -1
@@ -32,7 +32,7 @@*/ unsigned char *scsi_bios_ptable (struct block_device *dev) { -struct address_space *mapping =bdev_whole (dev)->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (bdev_whole (dev))->i_mapping;unsigned char *res =NULL ;struct folio *folio;
fs/affs/file.c +1 -1
@@ -365,7 +365,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul err_alloc:brelse (ext_bh);clear_buffer_mapped (bh_result); - bh_result->b_bdev =NULL ; + bh_result->b_bdev_file =NULL ;// unlock cache affs_unlock_ext (inode);return -ENOSPC ;
fs/bcachefs/util.h +1 -1
@@ -554,7 +554,7 @@ int bch2_bio_alloc_pages(struct bio *, size_t, gfp_t);static inline sector_t bdev_sectors (struct block_device *bdev) { -return bdev->bd_inode->i_size >>9 ; +return bdev_inode (bdev)->i_size >>9 ; }#define closure_bio_submit (bio, cl) \
fs/btrfs/disk-io.c +3 -3
@@ -3639,7 +3639,7 @@ struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev,struct btrfs_super_block *super;struct page *page;u64 bytenr, bytenr_orig; -struct address_space *mapping = bdev->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (bdev)->i_mapping;int ret; bytenr_orig =btrfs_sb_offset (copy_num);
@@ -3726,7 +3726,7 @@ static int write_dev_supers(struct btrfs_device *device, struct btrfs_super_block *sb, int max_mirrors) {struct btrfs_fs_info *fs_info = device->fs_info; -struct address_space *mapping = device->bdev->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (device->bdev)->i_mapping;SHASH_DESC_ON_STACK (shash, fs_info->csum_shash);int i;int errors =0 ;
@@ -3843,7 +3843,7 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) device->commit_total_bytes)break ; - page =find_get_page (device->bdev->bd_inode->i_mapping, + page =find_get_page (bdev_inode (device->bdev)->i_mapping, bytenr >>PAGE_SHIFT );if (!page) { errors++;
fs/btrfs/inode.c +1 -1
@@ -7660,7 +7660,7 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start, iomap->type =IOMAP_MAPPED ; } iomap->offset = start; - iomap->bdev = fs_info->fs_devices->latest_dev->bdev; + iomap->bdev_file = fs_info->fs_devices->latest_dev->bdev_file; iomap->length = len;free_extent_map (em);
fs/btrfs/volumes.c +1 -1
@@ -1268,7 +1268,7 @@ static struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdevreturn ERR_PTR (-EINVAL );/* pull in the page with our super */ - page =read_cache_page_gfp (bdev->bd_inode->i_mapping, index,GFP_KERNEL ); + page =read_cache_page_gfp (bdev_inode (bdev)->i_mapping, index,GFP_KERNEL );if (IS_ERR (page))return ERR_CAST (page);
fs/btrfs/zoned.c +1 -1
@@ -120,7 +120,7 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,return -ENOENT ; }else if (full[0 ] && full[1 ]) {/* Compare two super blocks */ -struct address_space *mapping = bdev->bd_inode->i_mapping; +struct address_space *mapping =bdev_inode (bdev)->i_mapping;struct page *page[BTRFS_NR_SB_LOG_ZONES ];struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES ];int i;
fs/buffer.c +53 -42
290 lines not on this page · raw message
fs/cramfs/inode.c +1 -1
@@ -183,7 +183,7 @@ static int next_buffer;static void *cramfs_blkdev_read (struct super_block *sb,unsigned int offset,unsigned int len) { -struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; +struct address_space *mapping = sb->s_bdev_file->f_mapping;struct file_ra_state ra = {};struct page *pages[BLKS_PER_BUF ];unsigned i, blocknr, buffer;
fs/direct-io.c +4 -3
@@ -671,7 +671,7 @@ static inline int dio_new_bio(struct dio *dio, struct dio_submit *sdio, sector = start_sector << (sdio->blkbits -9 ); nr_pages =bio_max_segs (sdio->pages_in_io);BUG_ON (nr_pages <=0 ); -dio_bio_alloc (dio, sdio, map_bh->b_bdev, sector, nr_pages); +dio_bio_alloc (dio, sdio,bh_bdev (map_bh), sector, nr_pages); sdio->boundary =0 ; out:return ret;
@@ -946,7 +946,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio, map_bh->b_blocknr << sdio->blkfactor;if (buffer_new (map_bh)) {clean_bdev_aliases ( - map_bh->b_bdev, + map_bh->b_bdev_file, map_bh->b_blocknr, map_bh->b_size >> i_blkbits); }
@@ -1102,10 +1102,11 @@ static inline int drop_refcount(struct dio *dio)* for the whole file. */ ssize_t __blockdev_direct_IO (struct kiocb *iocb,struct inode *inode, -struct block_device *bdev,struct iov_iter *iter, +struct file *bdev_file,struct iov_iter *iter,get_block_t get_block,dio_iodone_t end_io,int flags) { +struct block_device *bdev =file_bdev (bdev_file);unsigned i_blkbits =READ_ONCE (inode->i_blkbits);unsigned blkbits = i_blkbits;unsigned blocksize_mask = (1 << blkbits) -1 ;
fs/erofs/data.c +3 -2
@@ -70,7 +70,7 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)if (erofs_is_fscache_mode (sb)) buf->inode =EROFS_SB (sb)->s_fscache->inode;else - buf->inode = sb->s_bdev->bd_inode; + buf->inode =bdev_file_inode (sb->s_bdev_file); } void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
@@ -204,6 +204,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)int id; map->m_bdev = sb->s_bdev; + map->f_m_bdev = sb->s_bdev_file; map->m_daxdev =EROFS_SB (sb)->dax_dev; map->m_dax_part_off =EROFS_SB (sb)->dax_part_off; map->m_fscache =EROFS_SB (sb)->s_fscache;
@@ -278,7 +279,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (flags &IOMAP_DAX ) iomap->dax_dev = mdev.m_daxdev;else - iomap->bdev = mdev.m_bdev; + iomap->bdev_file = mdev.f_m_bdev; iomap->length = map.m_llen; iomap->flags =0 ; iomap->private =NULL ;
fs/erofs/internal.h +1 -0
@@ -377,6 +377,7 @@ enum {struct erofs_map_dev {struct erofs_fscache *m_fscache; +struct file *f_m_bdev;struct block_device *m_bdev;struct dax_device *m_daxdev;u64 m_dax_part_off;
fs/erofs/zmap.c +1 -1
@@ -739,7 +739,7 @@ static int z_erofs_iomap_begin_report(struct inode *inode, loff_t offset,if (ret <0 )return ret; - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file; iomap->offset = map.m_la; iomap->length = map.m_llen;if (map.m_flags &EROFS_MAP_MAPPED ) {
fs/ext2/inode.c +2 -2
@@ -744,7 +744,7 @@ static int ext2_get_blocks(struct inode *inode,* We must unmap blocks before zeroing so that writeback cannot * overwrite zeros with stale data from block device page cache. */ -clean_bdev_aliases (inode->i_sb->s_bdev, +clean_bdev_aliases (inode->i_sb->s_bdev_file,le32_to_cpu (chain[depth-1 ].key), count);/*
@@ -842,7 +842,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (flags &IOMAP_DAX ) iomap->dax_dev = sbi->s_daxdev;else - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file;if (ret ==0 ) {/*
fs/ext2/xattr.c +1 -1
@@ -80,7 +80,7 @@ }while (0 ) # define ea_bdebug(bh, f...) do { \printk (KERN_DEBUG "block %pg:%lu: " , \ - bh->b_bdev, (unsigned long ) bh->b_blocknr); \ +bh_bdev (bh), (unsigned long ) bh->b_blocknr); \printk (f); \printk ("\n" ); \ }while (0 )
fs/ext4/inode.c +4 -4
@@ -1797,11 +1797,11 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,* reserve space for a single block. * * For delayed buffer_head we have BH_Mapped, BH_New, BH_Delay set. -* We also have b_blocknr = -1 and b_bdev initialized properly +* We also have b_blocknr = -1 and b_bdev_file initialized properly * * For unwritten buffer_head we have BH_Mapped, BH_New, BH_Unwritten set. -* We also have b_blocknr = physicalblock mapping unwritten extent and b_bdev -* initialized properly. +* We also have b_blocknr = physicalblock mapping unwritten extent and +* b_bdev_file initialized properly. */ int ext4_da_get_block_prep (struct inode *inode,sector_t iblock,struct buffer_head *bh,int create)
@@ -3241,7 +3241,7 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,if (flags &IOMAP_DAX ) iomap->dax_dev =EXT4_SB (inode->i_sb)->s_daxdev;else - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file; iomap->offset = (u64 ) map->m_lblk << blkbits; iomap->length = (u64 ) map->m_len << blkbits;
fs/ext4/mmp.c +1 -1
@@ -384,7 +384,7 @@ int ext4_multi_mount_protect(struct super_block *sb,BUILD_BUG_ON (sizeof (mmp->mmp_bdevname) <BDEVNAME_SIZE );snprintf (mmp->mmp_bdevname,sizeof (mmp->mmp_bdevname), -"%pg" , bh->b_bdev); +"%pg" ,bh_bdev (bh));/* * Start a kernel thread to update the MMP block periodically.
fs/ext4/page-io.c +2 -2
@@ -93,7 +93,7 @@ struct ext4_io_end_vec *ext4_last_io_end_vec(ext4_io_end_t *io_end)static void buffer_io_error (struct buffer_head *bh) {printk_ratelimited (KERN_ERR "Buffer I/O error on device %pg, logical block %llu\n" , - bh->b_bdev, +bh_bdev (bh), (unsigned long long )bh->b_blocknr); }
@@ -397,7 +397,7 @@ static void io_submit_init_bio(struct ext4_io_submit *io,* bio_alloc will _always_ be able to allocate a bio if * __GFP_DIRECT_RECLAIM is set, see comments for bio_alloc_bioset(). */ - bio =bio_alloc (bh->b_bdev,BIO_MAX_VECS ,REQ_OP_WRITE ,GFP_NOIO ); + bio =bio_alloc (bh_bdev (bh),BIO_MAX_VECS ,REQ_OP_WRITE ,GFP_NOIO );fscrypt_set_bio_crypt_ctx_bh (bio, bh,GFP_NOIO ); bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >>9 ); bio->bi_end_io = ext4_end_bio;
fs/ext4/super.c +3 -4
@@ -261,7 +261,7 @@ struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,void ext4_sb_breadahead_unmovable (struct super_block *sb,sector_t block) { -struct buffer_head *bh =bdev_getblk (file_bdev (sb->s_bdev_file), block, +struct buffer_head *bh =bdev_getblk (sb->s_bdev_file, block, sb->s_blocksize,GFP_NOWAIT | __GFP_NOWARN);if (likely (bh)) {
@@ -5878,7 +5878,7 @@ static struct file *ext4_get_journal_blkdev(struct super_block *sb, sb_block =EXT4_MIN_BLOCK_SIZE / blocksize; offset =EXT4_MIN_BLOCK_SIZE % blocksize;set_blocksize (bdev, blocksize); - bh =__bread (bdev, sb_block, blocksize); + bh =__bread (bdev_file, sb_block, blocksize);if (!bh) {ext4_msg (sb,KERN_ERR ,"couldn't read superblock of " "external journal" );
@@ -5934,8 +5934,7 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,if (IS_ERR (bdev_file))return ERR_CAST (bdev_file); - journal =jbd2_journal_init_dev (file_bdev (bdev_file), -file_bdev (sb->s_bdev_file), j_start, + journal =jbd2_journal_init_dev (bdev_file, sb->s_bdev_file, j_start, j_len, sb->s_blocksize);if (IS_ERR (journal)) {ext4_msg (sb,KERN_ERR ,"failed to create device journal" );
fs/ext4/xattr.c +1 -1
@@ -68,7 +68,7 @@ inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)# define ea_bdebug (bh, fmt, ...) \ printk(KERN_DEBUG "block %pg:%lu: " fmt "\n", \ - bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__) + bh_bdev(bh), (unsigned long)bh->b_blocknr, ##__VA_ARGS__)#else # define ea_idebug (inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)# define ea_bdebug (bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
fs/f2fs/data.c +5 -2
@@ -1605,6 +1605,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) goto out; map->m_bdev = inode->i_sb->s_bdev; + map->f_m_bdev = inode->i_sb->s_bdev_file; map->m_multidev_dio =f2fs_allow_multi_device_dio (F2FS_I_SB (inode), flag);
@@ -1723,8 +1724,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) map->m_pblk = blkaddr; map->m_len =1 ; -if (map->m_multidev_dio) +if (map->m_multidev_dio) { map->m_bdev =FDEV (bidx).bdev; + map->f_m_bdev =FDEV (bidx).bdev_file; + } } else if ((map->m_pblk != NEW_ADDR && blkaddr == (map->m_pblk + ofs)) || (map->m_pblk == NEW_ADDR && blkaddr == NEW_ADDR) ||
@@ -4248,7 +4251,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->length =blks_to_bytes (inode, map.m_len); iomap->type =IOMAP_MAPPED ; iomap->flags |=IOMAP_F_MERGED ; - iomap->bdev = map.m_bdev; + iomap->bdev_file = map.f_m_bdev; iomap->addr =blks_to_bytes (inode, map.m_pblk); }else {if (flags &IOMAP_WRITE )
fs/f2fs/f2fs.h +1 -0
@@ -691,6 +691,7 @@ struct extent_tree_info { F2FS_MAP_DELALLOC)struct f2fs_map_blocks { +struct file *f_m_bdev;/* for multi-device dio */ struct block_device *m_bdev;/* for multi-device dio */ block_t m_pblk;block_t m_lblk;
fs/fuse/dax.c +1 -1
@@ -575,7 +575,7 @@ static int fuse_iomap_begin(struct inode *inode, loff_t pos, loff_t length, iomap->offset = pos; iomap->flags =0 ; - iomap->bdev =NULL ; + iomap->bdev_file =NULL ; iomap->dax_dev = fc->dax->dev;/*
fs/gfs2/aops.c +1 -1
@@ -622,7 +622,7 @@ static void gfs2_discard(struct gfs2_sbd *sdp, struct buffer_head *bh)spin_unlock (&sdp->sd_ail_lock); } } - bh->b_bdev =NULL ; + bh->b_bdev_file =NULL ;clear_buffer_mapped (bh);clear_buffer_req (bh);clear_buffer_new (bh);
fs/gfs2/bmap.c +1 -1
@@ -926,7 +926,7 @@ static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, iomap->flags |=IOMAP_F_GFS2_BOUNDARY ; out: - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file; unlock:up_read (&ip->i_rw_mutex);return ret;
fs/gfs2/glock.c +1 -1
@@ -1227,7 +1227,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, mapping =gfs2_glock2aspace (gl);if (mapping) { mapping->a_ops = &gfs2_meta_aops; - mapping->host = s->s_bdev->bd_inode; + mapping->host =bdev_file_inode (s->s_bdev_file); mapping->flags =0 ;mapping_set_gfp_mask (mapping,GFP_NOFS ); mapping->i_private_data =NULL ;
fs/gfs2/meta_io.c +1 -1
@@ -218,7 +218,7 @@ static void gfs2_submit_bhs(blk_opf_t opf, struct buffer_head *bhs[], int num)struct buffer_head *bh = *bhs;struct bio *bio; - bio =bio_alloc (bh->b_bdev, num, opf,GFP_NOIO ); + bio =bio_alloc (bh_bdev (bh), num, opf,GFP_NOIO ); bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >>9 );while (num >0 ) { bh = *bhs;
fs/gfs2/ops_fstype.c +1 -1
@@ -114,7 +114,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)address_space_init_once (mapping); mapping->a_ops = &gfs2_rgrp_aops; - mapping->host = sb->s_bdev->bd_inode; + mapping->host =bdev_file_inode (sb->s_bdev_file); mapping->flags =0 ;mapping_set_gfp_mask (mapping,GFP_NOFS ); mapping->i_private_data =NULL ;
fs/hpfs/file.c +1 -1
@@ -128,7 +128,7 @@ static int hpfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (WARN_ON_ONCE (flags & (IOMAP_WRITE |IOMAP_ZERO )))return -EINVAL ; - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file; iomap->offset = offset;hpfs_lock (sb);
fs/iomap/buffered-io.c +4 -4
@@ -377,7 +377,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,if (ctx->rac)/* same as readahead_gfp_mask */ gfp |= __GFP_NORETRY | __GFP_NOWARN; - ctx->bio =bio_alloc (iomap->bdev,bio_max_segs (nr_vecs), + ctx->bio =bio_alloc (iomap_bdev (iomap),bio_max_segs (nr_vecs),REQ_OP_READ , gfp);/* * If the bio_alloc fails, try it again for a single page to
@@ -385,7 +385,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,* what do_mpage_read_folio does. */ if (!ctx->bio) { - ctx->bio =bio_alloc (iomap->bdev,1 ,REQ_OP_READ , + ctx->bio =bio_alloc (iomap_bdev (iomap),1 ,REQ_OP_READ , orig_gfp); }if (ctx->rac)
@@ -624,7 +624,7 @@ static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,struct bio_vec bvec;struct bio bio; -bio_init (&bio, iomap->bdev, &bvec,1 ,REQ_OP_READ ); +bio_init (&bio,iomap_bdev (iomap), &bvec,1 ,REQ_OP_READ ); bio.bi_iter.bi_sector =iomap_sector (iomap, block_start);bio_add_folio_nofail (&bio, folio, plen, poff);return submit_bio_wait (&bio);
@@ -1663,7 +1663,7 @@ iomap_alloc_ioend(struct inode *inode, struct iomap_writepage_ctx *wpc,struct iomap_ioend *ioend;struct bio *bio; - bio =bio_alloc_bioset (wpc->iomap.bdev,BIO_MAX_VECS , + bio =bio_alloc_bioset (iomap_bdev (&wpc->iomap),BIO_MAX_VECS ,REQ_OP_WRITE |wbc_to_write_flags (wbc),GFP_NOFS , &iomap_ioend_bioset); bio->bi_iter.bi_sector = sector;
fs/iomap/direct-io.c +5 -5
@@ -56,9 +56,9 @@ static struct bio *iomap_dio_alloc_bio(const struct iomap_iter *iter, struct iomap_dio *dio, unsigned short nr_vecs, blk_opf_t opf) { if (dio->dops && dio->dops->bio_set) - return bio_alloc_bioset(iter->iomap.bdev, nr_vecs, opf, + return bio_alloc_bioset(iomap_bdev(&iter->iomap), nr_vecs, opf, GFP_KERNEL, dio->dops->bio_set); -return bio_alloc (iter->iomap.bdev, nr_vecs, opf,GFP_KERNEL ); +return bio_alloc (iomap_bdev (&iter->iomap), nr_vecs, opf,GFP_KERNEL ); } static void iomap_dio_submit_bio(const struct iomap_iter *iter,
@@ -288,8 +288,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,size_t copied =0 ;size_t orig_count; -if ((pos | length) & (bdev_logical_block_size (iomap->bdev) -1 ) || - !bdev_iter_is_aligned (iomap->bdev, dio->submit.iter)) +if ((pos | length) & (bdev_logical_block_size (iomap_bdev (iomap)) -1 ) || + !bdev_iter_is_aligned (iomap_bdev (iomap), dio->submit.iter))return -EINVAL ;if (iomap->type ==IOMAP_UNWRITTEN ) {
@@ -316,7 +316,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,*/ if (!(iomap->flags & (IOMAP_F_SHARED |IOMAP_F_DIRTY )) && (dio->flags &IOMAP_DIO_WRITE_THROUGH ) && - (bdev_fua (iomap->bdev) || !bdev_write_cache (iomap->bdev))) + (bdev_fua (iomap_bdev (iomap)) || !bdev_write_cache (iomap_bdev (iomap)))) use_fua = true;else if (dio->flags &IOMAP_DIO_NEED_SYNC ) dio->flags &= ~IOMAP_DIO_CALLER_COMP ;
fs/iomap/swapfile.c +1 -1
@@ -116,7 +116,7 @@ static loff_t iomap_swapfile_iter(const struct iomap_iter *iter,return iomap_swapfile_fail (isi,"has shared extents" );/* Only one bdev per swap file. */ -if (iomap->bdev != isi->sis->bdev) +if (iomap_bdev (iomap) != isi->sis->bdev)return iomap_swapfile_fail (isi,"outside the main device" );if (isi->iomap.length ==0 ) {
fs/iomap/trace.h +1 -1
@@ -134,7 +134,7 @@ DECLARE_EVENT_CLASS(iomap_class, __entry->length = iomap->length; __entry->type = iomap->type; __entry->flags = iomap->flags; - __entry->bdev = iomap->bdev ? iomap->bdev->bd_dev :0 ; + __entry->bdev =iomap_bdev (iomap) ?iomap_bdev (iomap)->bd_dev :0 ; ), TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr 0x%llx offset 0x%llx " "length 0x%llx type %s flags %s",
fs/jbd2/commit.c +1 -1
@@ -1014,7 +1014,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)clear_buffer_mapped (bh);clear_buffer_new (bh);clear_buffer_req (bh); - bh->b_bdev =NULL ; + bh->b_bdev_file =NULL ; } }
fs/jbd2/journal.c +16 -13
@@ -434,7 +434,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,folio_set_bh (new_bh, new_folio, new_offset); new_bh->b_size = bh_in->b_size; - new_bh->b_bdev = journal->j_dev; + new_bh->b_bdev_file = journal->j_bdev_file; new_bh->b_blocknr = blocknr; new_bh->b_private = bh_in;set_buffer_mapped (new_bh);
@@ -880,7 +880,7 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out)if (ret)return ret; - bh =__getblk (journal->j_dev, pblock, journal->j_blocksize); + bh =__getblk (journal->j_bdev_file, pblock, journal->j_blocksize);if (!bh)return -ENOMEM ;
@@ -1007,7 +1007,7 @@ jbd2_journal_get_descriptor_buffer(transaction_t *transaction, int type)if (err)return NULL ; - bh =__getblk (journal->j_dev, blocknr, journal->j_blocksize); + bh =__getblk (journal->j_bdev_file, blocknr, journal->j_blocksize);if (!bh)return NULL ;atomic_dec (&transaction->t_outstanding_credits);
@@ -1461,7 +1461,7 @@ static int journal_load_superblock(journal_t *journal)struct buffer_head *bh;journal_superblock_t *sb; - bh =getblk_unmovable (journal->j_dev, journal->j_blk_offset, + bh =getblk_unmovable (journal->j_bdev_file, journal->j_blk_offset, journal->j_blocksize);if (bh) err =bh_read (bh,0 );
@@ -1516,11 +1516,12 @@ static int journal_load_superblock(journal_t *journal)* very few fields yet: that has to wait until we have created the * journal structures from from scratch, or loaded them from disk. */ -static journal_t *journal_init_common (struct block_device *bdev, -struct block_device *fs_dev, +static journal_t *journal_init_common (struct file *bdev_file, +struct file *fs_dev,unsigned long long start,int len,int blocksize) {static struct lock_class_key jbd2_trans_commit_key; +struct block_device *bdev =file_bdev (bdev_file);journal_t *journal;int err;int n;
@@ -1530,8 +1531,10 @@ static journal_t *journal_init_common(struct block_device *bdev,return ERR_PTR (-ENOMEM ); journal->j_blocksize = blocksize; - journal->j_dev = bdev; - journal->j_fs_dev = fs_dev; + journal->j_bdev_file = bdev_file; + journal->j_fs_bdev_file = fs_dev; + journal->j_dev =file_bdev (bdev_file); + journal->j_fs_dev =file_bdev (fs_dev); journal->j_blk_offset = start; journal->j_total_len = len;jbd2_init_fs_dev_write_error (journal);
@@ -1640,13 +1643,13 @@ static journal_t *journal_init_common(struct block_device *bdev,* range of blocks on an arbitrary block device. * */ -journal_t *jbd2_journal_init_dev (struct block_device *bdev, -struct block_device *fs_dev, +journal_t *jbd2_journal_init_dev (struct file *bdev_file, +struct file *fs_dev,unsigned long long start,int len,int blocksize) {journal_t *journal; - journal =journal_init_common (bdev, fs_dev, start, len, blocksize); + journal =journal_init_common (bdev_file, fs_dev, start, len, blocksize);if (IS_ERR (journal))return ERR_CAST (journal);
@@ -1683,7 +1686,7 @@ journal_t *jbd2_journal_init_inode(struct inode *inode) inode->i_sb->s_id, inode->i_ino, (long long ) inode->i_size, inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize); - journal =journal_init_common (inode->i_sb->s_bdev, inode->i_sb->s_bdev, + journal =journal_init_common (inode->i_sb->s_bdev_file, inode->i_sb->s_bdev_file, blocknr, inode->i_size >> inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);if (IS_ERR (journal))
@@ -2009,7 +2012,7 @@ static int __jbd2_journal_erase(journal_t *journal, unsigned int flags) byte_count = (block_stop - block_start +1 ) * journal->j_blocksize; -truncate_inode_pages_range (journal->j_dev->bd_inode->i_mapping, +truncate_inode_pages_range (journal->j_bdev_file->f_mapping, byte_start, byte_stop);if (flags &JBD2_JOURNAL_FLUSH_DISCARD ) {
fs/jbd2/recovery.c +3 -3
@@ -92,7 +92,7 @@ static int do_readahead(journal_t *journal, unsigned int start) goto failed; } - bh =__getblk (journal->j_dev, blocknr, journal->j_blocksize); + bh =__getblk (journal->j_bdev_file, blocknr, journal->j_blocksize);if (!bh) { err = -ENOMEM ; goto failed;
@@ -148,7 +148,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,return err; } - bh =__getblk (journal->j_dev, blocknr, journal->j_blocksize); + bh =__getblk (journal->j_bdev_file, blocknr, journal->j_blocksize);if (!bh)return -ENOMEM ;
@@ -672,7 +672,7 @@ static int do_one_pass(journal_t *journal,/* Find a buffer for the new * data being restored */ - nbh =__getblk (journal->j_fs_dev, + nbh =__getblk (journal->j_fs_bdev_file, blocknr, journal->j_blocksize);if (nbh ==NULL ) {
fs/jbd2/revoke.c +4 -6
@@ -328,7 +328,6 @@ int jbd2_journal_revoke(handle_t *handle, unsigned long long blocknr, {struct buffer_head *bh =NULL ;journal_t *journal; -struct block_device *bdev;int err;might_sleep ();
@@ -341,11 +340,10 @@ int jbd2_journal_revoke(handle_t *handle, unsigned long long blocknr,return -EINVAL ; } - bdev = journal->j_fs_dev; bh = bh_in;if (!bh) { - bh =__find_get_block (bdev, blocknr, journal->j_blocksize); + bh =__find_get_block (journal->j_fs_bdev_file, blocknr, journal->j_blocksize);if (bh)BUFFER_TRACE (bh,"found on hash" ); }
@@ -355,7 +353,7 @@ int jbd2_journal_revoke(handle_t *handle, unsigned long long blocknr,/* If there is a different buffer_head lying around in * memory anywhere... */ - bh2 =__find_get_block (bdev, blocknr, journal->j_blocksize); + bh2 =__find_get_block (journal->j_fs_bdev_file, blocknr, journal->j_blocksize);if (bh2) {/* ... and it has RevokeValid status... */ if (bh2 != bh &&buffer_revokevalid (bh2))
@@ -466,7 +464,7 @@ int jbd2_journal_cancel_revoke(handle_t *handle, struct journal_head *jh)* state machine will get very upset later on. */ if (need_cancel) {struct buffer_head *bh2; - bh2 =__find_get_block (bh->b_bdev, bh->b_blocknr, bh->b_size); + bh2 =__find_get_block (bh->b_bdev_file, bh->b_blocknr, bh->b_size);if (bh2) {if (bh2 != bh)clear_buffer_revoked (bh2);
@@ -495,7 +493,7 @@ void jbd2_clear_buffer_revoked_flags(journal_t *journal)struct jbd2_revoke_record_s *record;struct buffer_head *bh; record = (struct jbd2_revoke_record_s *)list_entry; - bh =__find_get_block (journal->j_fs_dev, + bh =__find_get_block (journal->j_fs_bdev_file, record->blocknr, journal->j_blocksize);if (bh) {
fs/jbd2/transaction.c +4 -4
@@ -929,7 +929,7 @@ static void warn_dirty_buffer(struct buffer_head *bh)"JBD2: Spotted dirty metadata buffer (dev = %pg, blocknr = %llu). " "There's a risk of filesystem corruption in case of system " "crash.\n" , - bh->b_bdev, (unsigned long long)bh->b_blocknr); + bh_bdev(bh), (unsigned long long)bh->b_blocknr); }/* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */
@@ -990,7 +990,7 @@ do_get_write_access(handle_t *handle, struct journal_head *jh,/* If it takes too long to lock the buffer, trace it */ time_lock =jbd2_time_diff (start_lock, jiffies);if (time_lock >HZ /10 ) -trace_jbd2_lock_buffer_stall (bh->b_bdev->bd_dev, +trace_jbd2_lock_buffer_stall (bh_bdev (bh)->bd_dev,jiffies_to_msecs (time_lock));/* We now hold the buffer lock so it is safe to query the buffer
@@ -2374,7 +2374,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,write_unlock (&journal->j_state_lock);jbd2_journal_put_journal_head (jh);/* Already zapped buffer? Nothing to do... */ -if (!bh->b_bdev) +if (!bh_bdev (bh))return 0 ;return -EBUSY ; }
@@ -2428,7 +2428,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,clear_buffer_new (bh);clear_buffer_delay (bh);clear_buffer_unwritten (bh); - bh->b_bdev =NULL ; + bh->b_bdev_file =NULL ;return may_free; }
fs/mpage.c +17 -9
@@ -126,7 +126,12 @@ static void map_buffer_to_folio(struct folio *folio, struct buffer_head *bh, do { if (block == page_block) { page_bh->b_state = bh->b_state; - page_bh->b_bdev = bh->b_bdev; + if (buffer_bdev(bh)) { + page_bh->b_bdev = bh->b_bdev; + set_buffer_bdev(page_bh); + } else { + page_bh->b_bdev_file = bh->b_bdev_file; + } page_bh->b_blocknr = bh->b_blocknr; break; }
@@ -216,7 +221,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) page_block++; block_in_file++; } - bdev = map_bh->b_bdev; + bdev =bh_bdev (map_bh); }/*
@@ -272,7 +277,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) page_block++; block_in_file++; } - bdev = map_bh->b_bdev; + bdev =bh_bdev (map_bh); }if (first_hole != blocks_per_page) {
@@ -472,7 +477,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,struct block_device *bdev =NULL ;int boundary =0 ;sector_t boundary_block =0 ; -struct block_device *boundary_bdev =NULL ; +struct file *f_boundary_bdev =NULL ;size_t length;struct buffer_head map_bh;loff_t i_size =i_size_read (inode);
@@ -513,9 +518,9 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, boundary =buffer_boundary (bh);if (boundary) { boundary_block = bh->b_blocknr; - boundary_bdev = bh->b_bdev; + f_boundary_bdev = bh->b_bdev_file; } - bdev = bh->b_bdev; + bdev =bh_bdev (bh); }while ((bh = bh->b_this_page) != head);if (first_unmapped)
@@ -549,13 +554,16 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, map_bh.b_size =1 << blkbits;if (mpd->get_block (inode, block_in_file, &map_bh,1 )) goto confused; +/* This helper cannot be used from the block layer directly. */ +if (WARN_ON_ONCE (buffer_bdev (&map_bh))) + goto confused;if (!buffer_mapped (&map_bh)) goto confused;if (buffer_new (&map_bh))clean_bdev_bh_alias (&map_bh);if (buffer_boundary (&map_bh)) { boundary_block = map_bh.b_blocknr; - boundary_bdev = map_bh.b_bdev; + f_boundary_bdev = map_bh.b_bdev_file; }if (page_block) {if (map_bh.b_blocknr != first_block + page_block)
@@ -565,7 +573,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, } page_block++; boundary =buffer_boundary (&map_bh); - bdev = map_bh.b_bdev; + bdev =bh_bdev (&map_bh);if (block_in_file == last_block)break ; block_in_file++;
@@ -627,7 +635,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,if (boundary || (first_unmapped != blocks_per_page)) { bio =mpage_bio_submit_write (bio);if (boundary_block) { -write_boundary_block (boundary_bdev, +write_boundary_block (f_boundary_bdev, boundary_block,1 << blkbits); } }else {
fs/nilfs2/btnode.c +2 -2
@@ -59,7 +59,7 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr)BUG (); }memset (bh->b_data,0 ,i_blocksize (inode)); - bh->b_bdev = inode->i_sb->s_bdev; + bh->b_bdev_file = inode->i_sb->s_bdev_file; bh->b_blocknr = blocknr;set_buffer_mapped (bh);set_buffer_uptodate (bh);
@@ -118,7 +118,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, goto found; }set_buffer_mapped (bh); - bh->b_bdev = inode->i_sb->s_bdev; + bh->b_bdev_file = inode->i_sb->s_bdev_file; bh->b_blocknr = pblocknr;/* set block address for read */ bh->b_end_io = end_buffer_read_sync;get_bh (bh);
fs/nilfs2/gcinode.c +1 -1
@@ -84,7 +84,7 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, }if (!buffer_mapped (bh)) { - bh->b_bdev = inode->i_sb->s_bdev; + bh->b_bdev_file = inode->i_sb->s_bdev_file;set_buffer_mapped (bh); } bh->b_blocknr = pbn;
fs/nilfs2/mdt.c +1 -1
@@ -89,7 +89,7 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,if (buffer_uptodate (bh)) goto failed_bh; - bh->b_bdev = sb->s_bdev; + bh->b_bdev_file = sb->s_bdev_file; err =nilfs_mdt_insert_new_block (inode, block, bh, init_block);if (likely (!err)) {get_bh (bh);
fs/nilfs2/page.c +2 -2
@@ -111,7 +111,7 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh) dbh->b_state = sbh->b_state &NILFS_BUFFER_INHERENT_BITS ; dbh->b_blocknr = sbh->b_blocknr; - dbh->b_bdev = sbh->b_bdev; + dbh->b_bdev_file = sbh->b_bdev_file; bh = dbh; bits = sbh->b_state & (BIT (BH_Uptodate) |BIT (BH_Mapped));
@@ -216,7 +216,7 @@ static void nilfs_copy_folio(struct folio *dst, struct folio *src,lock_buffer (dbh); dbh->b_state = sbh->b_state & mask; dbh->b_blocknr = sbh->b_blocknr; - dbh->b_bdev = sbh->b_bdev; + dbh->b_bdev_file = sbh->b_bdev_file; sbh = sbh->b_this_page; dbh = dbh->b_this_page; }while (dbh != dbufs);
fs/nilfs2/recovery.c +10 -10
@@ -107,7 +107,7 @@ static int nilfs_compute_checksum(struct the_nilfs *nilfs, do { struct buffer_head *bh; - bh = __bread(nilfs->ns_bdev, ++start, blocksize); + bh = __bread(nilfs->ns_bdev_file, ++start, blocksize); if (!bh) return -EIO; check_bytes -= size;
@@ -136,7 +136,7 @@ int nilfs_read_super_root_block(struct the_nilfs *nilfs, sector_t sr_block,int ret; *pbh =NULL ; - bh_sr =__bread (nilfs->ns_bdev, sr_block, nilfs->ns_blocksize); + bh_sr =__bread (nilfs->ns_bdev_file, sr_block, nilfs->ns_blocksize);if (unlikely (!bh_sr)) { ret =NILFS_SEG_FAIL_IO ; goto failed;
@@ -183,7 +183,7 @@ nilfs_read_log_header(struct the_nilfs *nilfs, sector_t start_blocknr, {struct buffer_head *bh_sum; - bh_sum =__bread (nilfs->ns_bdev, start_blocknr, nilfs->ns_blocksize); + bh_sum =__bread (nilfs->ns_bdev_file, start_blocknr, nilfs->ns_blocksize);if (bh_sum) *sum = (struct nilfs_segment_summary *)bh_sum->b_data;return bh_sum;
@@ -250,7 +250,7 @@ static void *nilfs_read_summary_info(struct the_nilfs *nilfs,if (bytes > (*pbh)->b_size - *offset) { blocknr = (*pbh)->b_blocknr;brelse (*pbh); - *pbh =__bread (nilfs->ns_bdev, blocknr +1 , + *pbh =__bread (nilfs->ns_bdev_file, blocknr +1 , nilfs->ns_blocksize);if (unlikely (!*pbh))return NULL ;
@@ -289,7 +289,7 @@ static void nilfs_skip_summary_info(struct the_nilfs *nilfs, *offset = bytes * (count - (bcnt -1 ) * nitem_per_block);brelse (*pbh); - *pbh =__bread (nilfs->ns_bdev, blocknr + bcnt, + *pbh =__bread (nilfs->ns_bdev_file, blocknr + bcnt, nilfs->ns_blocksize); } }
@@ -318,7 +318,7 @@ static int nilfs_scan_dsync_log(struct the_nilfs *nilfs, sector_t start_blocknr, sumbytes =le32_to_cpu (sum->ss_sumbytes); blocknr = start_blocknr +DIV_ROUND_UP (sumbytes, nilfs->ns_blocksize); - bh =__bread (nilfs->ns_bdev, start_blocknr, nilfs->ns_blocksize); + bh =__bread (nilfs->ns_bdev_file, start_blocknr, nilfs->ns_blocksize);if (unlikely (!bh)) goto out;
@@ -477,7 +477,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,struct buffer_head *bh_org;void *kaddr; - bh_org =__bread (nilfs->ns_bdev, rb->blocknr, nilfs->ns_blocksize); + bh_org =__bread (nilfs->ns_bdev_file, rb->blocknr, nilfs->ns_blocksize);if (unlikely (!bh_org))return -EIO ;
@@ -696,7 +696,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, nilfs_get_segnum_of_block(nilfs, ri->ri_super_root)) return; - bh =__getblk (nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize); + bh =__getblk (nilfs->ns_bdev_file, ri->ri_lsegs_start, nilfs->ns_blocksize);BUG_ON (!bh);memset (bh->b_data,0 , bh->b_size);set_buffer_dirty (bh);
@@ -822,7 +822,7 @@ int nilfs_search_super_root(struct the_nilfs *nilfs,/* Read ahead segment */ b = seg_start;while (b <= seg_end) -__breadahead (nilfs->ns_bdev, b++, nilfs->ns_blocksize); +__breadahead (nilfs->ns_bdev_file, b++, nilfs->ns_blocksize);for (;;) {brelse (bh_sum);
@@ -868,7 +868,7 @@ int nilfs_search_super_root(struct the_nilfs *nilfs,if (pseg_start == seg_start) {nilfs_get_segment_range (nilfs, nextnum, &b, &end);while (b <= end) -__breadahead (nilfs->ns_bdev, b++, +__breadahead (nilfs->ns_bdev_file, b++, nilfs->ns_blocksize); }if (!(flags &NILFS_SS_SR )) {
fs/nilfs2/segment.c +1 -1
@@ -2825,7 +2825,7 @@ int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root)if (!nilfs->ns_writer)return -ENOMEM ; -inode_attach_wb (nilfs->ns_bdev->bd_inode,NULL ); +inode_attach_wb (bdev_file_inode (nilfs->ns_bdev_file),NULL ); err =nilfs_segctor_start_thread (nilfs->ns_writer);if (unlikely (err))
fs/nilfs2/the_nilfs.c +1 -0
@@ -63,6 +63,7 @@ struct the_nilfs *alloc_nilfs(struct super_block *sb) nilfs->ns_sb = sb; nilfs->ns_bdev = sb->s_bdev; + nilfs->ns_bdev_file = sb->s_bdev_file;atomic_set (&nilfs->ns_ndirtyblks,0 );init_rwsem (&nilfs->ns_sem);mutex_init (&nilfs->ns_snapshot_mount_mutex);
fs/nilfs2/the_nilfs.h +1 -0
@@ -97,6 +97,7 @@ struct the_nilfs {int ns_flushed_device;struct super_block *ns_sb; +struct file *ns_bdev_file;struct block_device *ns_bdev;struct rw_semaphore ns_sem;struct mutex ns_snapshot_mount_mutex;
fs/ntfs/aops.c +3 -3
@@ -227,7 +227,7 @@ static int ntfs_read_block(struct folio *folio) arr[nr++] = bh;continue ; } - bh->b_bdev = vol->sb->s_bdev; + bh->b_bdev_file = vol->sb->s_bdev_file;/* Is the block within the allowed limits? */ if (iblock < lblock) {bool is_retry = false;
@@ -678,7 +678,7 @@ static int ntfs_write_block(struct folio *folio, struct writeback_control *wbc)continue ;/* Unmapped, dirty buffer. Need to map it. */ - bh->b_bdev = vol->sb->s_bdev; + bh->b_bdev_file = vol->sb->s_bdev_file;/* Convert block into corresponding vcn and offset. */ vcn = (VCN )block << blocksize_bits;
@@ -988,7 +988,7 @@ static int ntfs_write_mst_block(struct page *page,LCN lcn;unsigned int vcn_ofs; - bh->b_bdev = vol->sb->s_bdev; + bh->b_bdev_file = vol->sb->s_bdev_file;/* Obtain the vcn and offset of the current block. */ vcn = (VCN )block << bh_size_bits; vcn_ofs = vcn & vol->cluster_size_mask;
fs/ntfs/file.c +1 -1
@@ -680,7 +680,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,continue ; }/* Unmapped buffer. Need to map it. */ - bh->b_bdev = vol->sb->s_bdev; + bh->b_bdev_file = vol->sb->s_bdev_file;/* * If the current buffer is in the same clusters as the map * cache, there is no need to check the runlist again. The
fs/ntfs/mft.c +2 -2
@@ -526,7 +526,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,LCN lcn;unsigned int vcn_ofs; - bh->b_bdev = vol->sb->s_bdev; + bh->b_bdev_file = vol->sb->s_bdev_file;/* Obtain the vcn and offset of the current block. */ vcn = ((VCN )mft_no << vol->mft_record_size_bits) + (block_start - m_start);
@@ -719,7 +719,7 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync)LCN lcn;unsigned int vcn_ofs; - bh->b_bdev = vol->sb->s_bdev; + bh->b_bdev_file = vol->sb->s_bdev_file;/* Obtain the vcn and offset of the current block. */ vcn = ((VCN )ni->mft_no << vol->mft_record_size_bits) + (block_start - m_start);
fs/ntfs3/fsntfs.c +4 -4
@@ -1015,7 +1015,7 @@ int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer)u32 op = blocksize - off;for (; bytes; block +=1 , off =0 , op = blocksize) { -struct buffer_head *bh =__bread (bdev, block, blocksize); +struct buffer_head *bh =__bread (sb->s_bdev_file, block, blocksize);if (!bh)return -EIO ;
@@ -1052,14 +1052,14 @@ int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes, op = bytes;if (op < blocksize) { - bh =__bread (bdev, block, blocksize); + bh =__bread (sb->s_bdev_file, block, blocksize);if (!bh) {ntfs_err (sb,"failed to read block %llx" , (u64 )block);return -EIO ; } }else { - bh =__getblk (bdev, block, blocksize); + bh =__getblk (sb->s_bdev_file, block, blocksize);if (!bh)return -ENOMEM ; }
@@ -2673,4 +2673,4 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len) out:__putname (uni);return err; -} +}
fs/ntfs3/inode.c +1 -1
@@ -611,7 +611,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, lbo = ((u64 )lcn << cluster_bits) + off;set_buffer_mapped (bh); - bh->b_bdev = sb->s_bdev; + bh->b_bdev_file = sb->s_bdev_file; bh->b_blocknr = lbo >> sb->s_blocksize_bits; valid = ni->i_valid;
fs/ntfs3/super.c +1 -1
@@ -1632,7 +1632,7 @@ void ntfs_unmap_meta(struct super_block *sb, CLST lcn, CLST len) limit >>=1 ;while (blocks--) { -clean_bdev_aliases (bdev, devblock++,1 ); +clean_bdev_aliases (sb->s_bdev_file, devblock++,1 );if (cnt++ >= limit) {sync_blockdev (bdev); cnt =0 ;
fs/ocfs2/aops.c +1 -1
@@ -2459,7 +2459,7 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)else get_block = ocfs2_dio_wr_get_block; -return __blockdev_direct_IO (iocb, inode, inode->i_sb->s_bdev, +return __blockdev_direct_IO (iocb, inode, inode->i_sb->s_bdev_file, iter, get_block, ocfs2_dio_end_io,0 ); }
fs/ocfs2/journal.c +1 -1
@@ -1209,7 +1209,7 @@ static int ocfs2_force_read_journal(struct inode *inode) }for (i =0 ; i < p_blocks; i++, p_blkno++) { - bh =__find_get_block (osb->sb->s_bdev, p_blkno, + bh =__find_get_block (osb->sb->s_bdev_file, p_blkno, osb->sb->s_blocksize);/* block not cached. */ if (!bh)
fs/reiserfs/fix_node.c +1 -1
@@ -2332,7 +2332,7 @@ static void tb_buffer_sanity_check(struct super_block *sb,"in tree %s[%d] (%b)" , descr, level, bh); -if (bh->b_bdev != sb->s_bdev) +if (bh_bdev (bh) != sb->s_bdev)reiserfs_panic (sb,"jmacd-4" ,"buffer has wrong " "device %s[%d] (%b)" , descr, level, bh);
fs/reiserfs/journal.c +5 -5
@@ -618,7 +618,7 @@ static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate)if (buffer_journaled (bh)) {reiserfs_warning (NULL ,"clm-2084" ,"pinned buffer %lu:%pg sent to disk" , - bh->b_blocknr, bh->b_bdev); + bh->b_blocknr,bh_bdev (bh)); }if (uptodate)set_buffer_uptodate (bh);
@@ -2315,7 +2315,7 @@ static int journal_read_transaction(struct super_block *sb,* from other places. * Note: Do not use journal_getblk/sb_getblk functions here! */ -static struct buffer_head *reiserfs_breada (struct block_device *dev, +static struct buffer_head *reiserfs_breada (struct file *f_dev,b_blocknr_t block,int bufsize,b_blocknr_t max_block) {
@@ -2324,7 +2324,7 @@ static struct buffer_head *reiserfs_breada(struct block_device *dev,struct buffer_head *bh;int i, j; - bh =__getblk (dev, block, bufsize); + bh =__getblk (f_dev, block, bufsize);if (!bh ||buffer_uptodate (bh))return (bh);
@@ -2334,7 +2334,7 @@ static struct buffer_head *reiserfs_breada(struct block_device *dev, bhlist[0 ] = bh; j =1 ;for (i =1 ; i < blocks; i++) { - bh =__getblk (dev, block + i, bufsize); + bh =__getblk (f_dev, block + i, bufsize);if (!bh)break ;if (buffer_uptodate (bh)) {
@@ -2447,7 +2447,7 @@ static int journal_read(struct super_block *sb)* device and journal device to be the same */ d_bh = -reiserfs_breada (file_bdev (journal->j_bdev_file), cur_dblock, +reiserfs_breada (journal->j_bdev_file, cur_dblock, sb->s_blocksize,SB_ONDISK_JOURNAL_1st_BLOCK (sb) +SB_ONDISK_JOURNAL_SIZE (sb));
fs/reiserfs/prints.c +2 -2
@@ -156,7 +156,7 @@ static int scnprintf_buffer_head(char *buf, size_t size, struct buffer_head *bh) { return scnprintf(buf, size, "dev %pg, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)", - bh->b_bdev, bh->b_size, + bh_bdev(bh), bh->b_size, (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)), bh->b_state, bh->b_page,
@@ -561,7 +561,7 @@ static int print_super_block(struct buffer_head *bh)return 1 ; } -printk ("%pg\'s super block is in block %llu\n" , bh->b_bdev, +printk ("%pg\'s super block is in block %llu\n" ,bh_bdev (bh), (unsigned long long )bh->b_blocknr);printk ("Reiserfs version %s\n" , version);printk ("Block count %u\n" ,sb_block_count (rs));
fs/reiserfs/reiserfs.h +3 -3
@@ -2810,10 +2810,10 @@ struct reiserfs_journal_header {/* We need these to make journal.c code more readable */ #define journal_find_get_block (s, block) __find_get_block(\ - file_bdev(SB_JOURNAL(s)->j_bdev_file), block, s->s_blocksize) -#define journal_getblk (s, block) __getblk(file_bdev(SB_JOURNAL(s)->j_bdev_file),\ + SB_JOURNAL(s)->j_bdev_file, block, s->s_blocksize) +#define journal_getblk (s, block) __getblk(SB_JOURNAL(s)->j_bdev_file,\ block, s->s_blocksize) -#define journal_bread (s, block) __bread(file_bdev(SB_JOURNAL(s)->j_bdev_file),\ +#define journal_bread (s, block) __bread(SB_JOURNAL(s)->j_bdev_file,\ block, s->s_blocksize)enum reiserfs_bh_state_bits {
fs/reiserfs/stree.c +1 -1
@@ -331,7 +331,7 @@ static inline int key_in_buffer( || chk_path->path_length > MAX_HEIGHT,"PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)" , key, chk_path->path_length); -RFALSE (!PATH_PLAST_BUFFER (chk_path)->b_bdev, +RFALSE (!bh_bdev (PATH_PLAST_BUFFER (chk_path)),"PAP-5060: device must not be NODEV" );if (comp_keys (get_lkey (chk_path, sb), key) ==1 )
fs/reiserfs/tail_conversion.c +1 -1
@@ -187,7 +187,7 @@ void reiserfs_unmap_buffer(struct buffer_head *bh)clear_buffer_mapped (bh);clear_buffer_req (bh);clear_buffer_new (bh); - bh->b_bdev =NULL ; + bh->b_bdev_file =NULL ;unlock_buffer (bh); }
fs/xfs/xfs_iomap.c +2 -2
@@ -125,7 +125,7 @@ xfs_bmbt_to_iomap(if (mapping_flags &IOMAP_DAX ) iomap->dax_dev = target->bt_daxdev;else - iomap->bdev = target->bt_bdev; + iomap->bdev_file = target->bt_bdev_file; iomap->flags = iomap_flags; if (xfs_ipincount(ip) &&
@@ -150,7 +150,7 @@ xfs_hole_to_iomap( iomap->type =IOMAP_HOLE ; iomap->offset =XFS_FSB_TO_B (ip->i_mount, offset_fsb); iomap->length =XFS_FSB_TO_B (ip->i_mount, end_fsb - offset_fsb); - iomap->bdev = target->bt_bdev; + iomap->bdev_file = target->bt_bdev_file; iomap->dax_dev = target->bt_daxdev; }
fs/zonefs/file.c +2 -2
@@ -38,7 +38,7 @@ static int zonefs_read_iomap_begin(struct inode *inode, loff_t offset,* act as if there is a hole up to the file maximum size. */ mutex_lock (&zi->i_truncate_mutex); - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file; iomap->offset =ALIGN_DOWN (offset, sb->s_blocksize); isize =i_size_read (inode);if (iomap->offset >= isize) {
@@ -88,7 +88,7 @@ static int zonefs_write_iomap_begin(struct inode *inode, loff_t offset,* write pointer) and unwriten beyond. */ mutex_lock (&zi->i_truncate_mutex); - iomap->bdev = inode->i_sb->s_bdev; + iomap->bdev_file = inode->i_sb->s_bdev_file; iomap->offset =ALIGN_DOWN (offset, sb->s_blocksize); iomap->addr = (z->z_sector <<SECTOR_SHIFT ) + iomap->offset; isize =i_size_read (inode);
include/linux/blk_types.h +0 -1
@@ -49,7 +49,6 @@ struct block_device {bool bd_write_holder;bool bd_has_submit_bio;dev_t bd_dev; -struct inode *bd_inode;/* will die */ atomic_t bd_openers;spinlock_t bd_size_lock;/* for bd_inode->i_size updates */
include/linux/blkdev.h +4 -2
@@ -212,9 +212,11 @@ struct gendisk {struct blk_independent_access_ranges *ia_ranges; }; +struct inode *bdev_inode (struct block_device *bdev); +static inline bool disk_live (struct gendisk *disk) { -return !inode_unhashed (disk->part0->bd_inode); +return !inode_unhashed (bdev_inode (disk->part0)); }/**
@@ -1319,7 +1321,7 @@ static inline unsigned int blksize_bits(unsigned int size)static inline unsigned int block_size (struct block_device *bdev) { -return 1 << bdev->bd_inode->i_blkbits; +return 1 <<bdev_inode (bdev)->i_blkbits; }int kblockd_schedule_work (struct work_struct *work);
include/linux/buffer_head.h +44 -24
175 lines not on this page · raw message
include/linux/fs.h +2 -2
@@ -3105,7 +3105,7 @@ enum { };ssize_t __blockdev_direct_IO (struct kiocb *iocb,struct inode *inode, -struct block_device *bdev,struct iov_iter *iter, +struct file *bdev_file,struct iov_iter *iter,get_block_t get_block,dio_iodone_t end_io,int flags);
@@ -3115,7 +3115,7 @@ static inline ssize_t blockdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, get_block_t get_block) { -return __blockdev_direct_IO (iocb, inode, inode->i_sb->s_bdev, iter, +return __blockdev_direct_IO (iocb, inode, inode->i_sb->s_bdev_file, iter, get_block,NULL ,DIO_LOCKING |DIO_SKIP_HOLES ); }#endif
include/linux/iomap.h +12 -1
@@ -77,6 +77,7 @@ struct vm_fault;*/ #define IOMAP_F_SIZE_CHANGED (1U << 8)#define IOMAP_F_STALE (1U << 9) +#define IOMAP_F_BDEV (1U << 10)/* * Flags from 0x1000 up are for file system specific usage:
@@ -97,7 +98,10 @@ struct iomap {u64 length;/* length of mapping, bytes */ u16 type;/* type of mapping */ u16 flags;/* flags for mapping */ -struct block_device *bdev;/* block device for I/O */ +union { +struct file *bdev_file; +struct block_device *bdev; + };struct dax_device *dax_dev;/* dax_dev for dax operations */ void *inline_data;void *private;/* filesystem private */
@@ -105,6 +109,13 @@ struct iomap {u64 validity_cookie;/* used with .iomap_valid() */ }; +static inline struct block_device *iomap_bdev (const struct iomap *iomap) +{ +if (iomap->flags &IOMAP_F_BDEV ) +return iomap->bdev; +return file_bdev (iomap->bdev_file); +} +static inline sector_t iomap_sector (const struct iomap *iomap,loff_t pos) {return (iomap->addr + pos - iomap->offset) >>SECTOR_SHIFT ;
include/linux/jbd2.h +6 -4
@@ -967,6 +967,7 @@ struct journal_s* @j_dev: Device where we store the journal. */ struct block_device *j_dev; +struct file *j_bdev_file;/** * @j_blocksize: Block size for the location where we store the journal.
@@ -992,6 +993,7 @@ struct journal_s* equal to j_dev. */ struct block_device *j_fs_dev; +struct file *j_fs_bdev_file;/** * @j_fs_dev_wb_err:
@@ -1533,8 +1535,8 @@ extern void jbd2_journal_unlock_updates (journal_t *);void jbd2_journal_wait_updates (journal_t *); -extern journal_t *jbd2_journal_init_dev (struct block_device *bdev, -struct block_device *fs_dev, +extern journal_t *jbd2_journal_init_dev (struct file *bdev_file, +struct file *fs_dev,unsigned long long start,int len,int bsize);extern journal_t *jbd2_journal_init_inode (struct inode *);extern int jbd2_journal_update_format (journal_t *);
@@ -1696,7 +1698,7 @@ static inline void jbd2_journal_abort_handle(handle_t *handle)static inline void jbd2_init_fs_dev_write_error (journal_t *journal) { -struct address_space *mapping = journal->j_fs_dev->bd_inode->i_mapping; +struct address_space *mapping = journal->j_fs_bdev_file->f_mapping;/* * Save the original wb_err value of client fs's bdev mapping which
@@ -1707,7 +1709,7 @@ static inline void jbd2_init_fs_dev_write_error(journal_t *journal)static inline int jbd2_check_fs_dev_write_error (journal_t *journal) { -struct address_space *mapping = journal->j_fs_dev->bd_inode->i_mapping; +struct address_space *mapping = journal->j_fs_bdev_file->f_mapping;return errseq_check (&mapping->wb_err,READ_ONCE (journal->j_fs_dev_wb_err));
include/trace/events/block.h +1 -1
@@ -26,7 +26,7 @@ DECLARE_EVENT_CLASS(block_buffer, ), TP_fast_assign( - __entry->dev = bh->b_bdev->bd_dev; + __entry->dev = bh_bdev(bh)->bd_dev; __entry->sector = bh->b_blocknr; __entry->size = bh->b_size; ),
Signature · 1 line
2.43.0
Re: [PATCH RFC 1/2] fs & block: remove bdev->bd_inode
Hi, Christian
Quoted 10 lines · Christian Brauner
The only user that doesn't rely on files is the block layer itself in
block/fops.cwhere we only have access to the block device. As the bdev filesystem doesn't open block devices as files obviously.This introduces a union into struct
buffer_headand struct iomap. The union encompasses both structblock_deviceand struct file. In both cases a flag is used to differentiate whether a block device or a proper file was stashed. Simple accessorsbh_bdev()andiomap_bdev()are used to return the block device in the really low-level functions where it's needed. These are overall just a few callsites.
I just realize that your implementation for iomap and buffer_head is better, if you don't mind. I'll split related changes into a seperate patch, and send out together.
Thanks,
Kuai
Christian Brauner
maintainerRe: [PATCH RFC 1/2] fs & block: remove bdev->bd_inode
Quoted 14 lines · Yu Kuai
Hi, Christian
Quoted 10 lines · Christian Brauner
The only user that doesn't rely on files is the block layer itself in
block/fops.cwhere we only have access to the block device. As the bdev filesystem doesn't open block devices as files obviously.This introduces a union into struct
buffer_headand struct iomap. The union encompasses both structblock_deviceand struct file. In both cases a flag is used to differentiate whether a block device or a proper file was stashed. Simple accessorsbh_bdev()andiomap_bdev()are used to return the block device in the really low-level functions where it's needed. These are overall just a few callsites.
Quoted 3 lines
I just realize that your implementation for iomap and
buffer_headis better, if you don't mind. I'll split related changes into a seperate patch, and send out together.
Sure!
Christian Brauner
maintainerRFC PATCH 2/2 fs,drivers: remove bdev_inode() usage outside of block layer and drivers
In reply to Christian BraunerThere are a few places that use bdev->bd_inode. They don't need to anymore as they can use the bdev file and bdev_file_inode().
--- drivers/md/bcache/super.c | 7 ++++--- drivers/mtd/devices/block2mtd.c | 4 ++-- fs/bcachefs/util.h | 5 ----- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/disk-io.c | 17 +++++++++-------- fs/btrfs/disk-io.h | 4 ++-- fs/btrfs/super.c | 2 +- fs/btrfs/volumes.c | 26 ++++++++++++++------------ fs/btrfs/volumes.h | 2 +- fs/btrfs/zoned.c | 18 ++++++++++-------- fs/btrfs/zoned.h | 4 ++-- 11 files changed, 46 insertions(+), 45 deletions(-)
drivers/md/bcache/super.c +4 -3
@@ -163,15 +163,16 @@ static const char *read_super_common(struct cache_sb *sb, struct block_device * } -static const char *read_super (struct cache_sb *sb,struct block_device *bdev, +static const char *read_super (struct cache_sb *sb,struct bdev_file *bdev_file,struct cache_sb_disk **res) {const char *err;struct cache_sb_disk *s;struct page *page;unsigned int i; +struct block_device *bdev =file_bdev (bdev_file); - page =read_cache_page_gfp (bdev_inode (bdev)->i_mapping, + page =read_cache_page_gfp (bdev_file->f_mapping,SB_OFFSET >>PAGE_SHIFT ,GFP_KERNEL );if (IS_ERR (page))return "IO error" ;
@@ -2557,7 +2558,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,if (set_blocksize (file_bdev (bdev_file),4096 )) goto out_blkdev_put; - err =read_super (sb,file_bdev (bdev_file), &sb_disk); + err =read_super (sb, bdev_file, &sb_disk);if (err) goto out_blkdev_put;
drivers/mtd/devices/block2mtd.c +2 -2
@@ -291,7 +291,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, goto err_free_block2mtd; } -if ((long )bdev_inode (bdev)->i_size % erase_size) { +if ((long )bdev_file_inode (bdev_file)->i_size % erase_size) {pr_err ("erasesize must be a divisor of device size\n" ); goto err_free_block2mtd; }
@@ -309,7 +309,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, dev->mtd.name = name; - dev->mtd.size =bdev_inode (bdev)->i_size &PAGE_MASK ; + dev->mtd.size =bdev_file_inode (bdev_file)->i_size &PAGE_MASK ; dev->mtd.erasesize = erase_size; dev->mtd.writesize =1 ; dev->mtd.writebufsize =PAGE_SIZE ;
fs/bcachefs/util.h +0 -5
@@ -552,11 +552,6 @@ static inline unsigned fract_exp_two(unsigned x, unsigned fract_bits)void bch2_bio_map (struct bio *bio,void *base,size_t );int bch2_bio_alloc_pages (struct bio *,size_t ,gfp_t ); -static inline sector_t bdev_sectors (struct block_device *bdev) -{ -return bdev_inode (bdev)->i_size >>9 ; -} -#define closure_bio_submit (bio, cl) \ do { \ closure_get(cl); \
fs/btrfs/dev-replace.c +1 -1
@@ -984,7 +984,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,btrfs_sysfs_remove_device (src_device);btrfs_sysfs_update_devid (tgt_device);if (test_bit (BTRFS_DEV_STATE_WRITEABLE , &src_device->dev_state)) -btrfs_scratch_superblocks (fs_info, src_device->bdev, +btrfs_scratch_superblocks (fs_info, src_device->bdev_file, src_device->name->str);/* write back the superblocks */
fs/btrfs/disk-io.c +9 -8
@@ -3222,7 +3222,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device/* * Read super block and check the signature bytes only */ - disk_super =btrfs_read_dev_super (fs_devices->latest_dev->bdev); + disk_super =btrfs_read_dev_super (fs_devices->latest_dev->bdev_file);if (IS_ERR (disk_super)) { ret =PTR_ERR (disk_super); goto fail_alloc;
@@ -3633,17 +3633,18 @@ static void btrfs_end_super_write(struct bio *bio)bio_put (bio); } -struct btrfs_super_block *btrfs_read_dev_one_super (struct block_device *bdev, +struct btrfs_super_block *btrfs_read_dev_one_super (struct file *bdev_file,int copy_num,bool drop_cache) {struct btrfs_super_block *super; +struct block_device *bdev =file_bdev (bdev_file);struct page *page;u64 bytenr, bytenr_orig; -struct address_space *mapping =bdev_inode (bdev)->i_mapping; +struct address_space *mapping = bdev_file->f_mapping;int ret; bytenr_orig =btrfs_sb_offset (copy_num); - ret =btrfs_sb_log_location_bdev (bdev, copy_num,READ , &bytenr); + ret =btrfs_sb_log_location_bdev (bdev_file, copy_num,READ , &bytenr);if (ret == -ENOENT )return ERR_PTR (-EINVAL );else if (ret)
@@ -3684,7 +3685,7 @@ struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev, } -struct btrfs_super_block *btrfs_read_dev_super (struct block_device *bdev) +struct btrfs_super_block *btrfs_read_dev_super (struct file *bdev_file) {struct btrfs_super_block *super, *latest =NULL ;int i;
@@ -3696,7 +3697,7 @@ struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev)* later supers, using BTRFS_SUPER_MIRROR_MAX instead */ for (i =0 ; i <1 ; i++) { - super =btrfs_read_dev_one_super (bdev, i, false); + super =btrfs_read_dev_one_super (bdev_file, i, false);if (IS_ERR (super))continue ;
@@ -3726,7 +3727,7 @@ static int write_dev_supers(struct btrfs_device *device, struct btrfs_super_block *sb, int max_mirrors) {struct btrfs_fs_info *fs_info = device->fs_info; -struct address_space *mapping =bdev_inode (device->bdev)->i_mapping; +struct address_space *mapping = device->bdev_file->f_mapping;SHASH_DESC_ON_STACK (shash, fs_info->csum_shash);int i;int errors =0 ;
@@ -3843,7 +3844,7 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) device->commit_total_bytes)break ; - page =find_get_page (bdev_inode (device->bdev)->i_mapping, + page =find_get_page (device->bdev_file->f_mapping, bytenr >>PAGE_SHIFT );if (!page) { errors++;
fs/btrfs/disk-io.h +2 -2
@@ -48,8 +48,8 @@ int btrfs_validate_super(struct btrfs_fs_info *fs_info, struct btrfs_super_block *sb, int mirror_num);int btrfs_check_features (struct btrfs_fs_info *fs_info,bool is_rw_mount);int write_all_supers (struct btrfs_fs_info *fs_info,int max_mirrors); -struct btrfs_super_block *btrfs_read_dev_super (struct block_device *bdev); -struct btrfs_super_block *btrfs_read_dev_one_super (struct block_device *bdev, +struct btrfs_super_block *btrfs_read_dev_super (struct file *bdev_file); +struct btrfs_super_block *btrfs_read_dev_one_super (struct file *bdev_file,int copy_num,bool drop_cache);int btrfs_commit_super (struct btrfs_fs_info *fs_info); struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
fs/btrfs/super.c +1 -1
@@ -2280,7 +2280,7 @@ static int check_dev_super(struct btrfs_device *dev)return 0 ;/* Only need to check the primary super block. */ - sb =btrfs_read_dev_one_super (dev->bdev,0 , true); + sb =btrfs_read_dev_one_super (dev->bdev_file,0 , true);if (IS_ERR (sb))return PTR_ERR (sb);
fs/btrfs/volumes.c +14 -12
@@ -490,7 +490,7 @@ btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, goto error; }invalidate_bdev (bdev); - *disk_super =btrfs_read_dev_super (bdev); + *disk_super =btrfs_read_dev_super (*bdev_file);if (IS_ERR (*disk_super)) { ret =PTR_ERR (*disk_super);fput (*bdev_file);
@@ -1246,10 +1246,11 @@ void btrfs_release_disk_super(struct btrfs_super_block *super)put_page (page); } -static struct btrfs_super_block *btrfs_read_disk_super (struct block_device *bdev, +static struct btrfs_super_block *btrfs_read_disk_super (struct file *bdev_file,u64 bytenr,u64 bytenr_orig) {struct btrfs_super_block *disk_super; +struct block_device *bdev =file_bdev (bdev_file);struct page *page;void *p;pgoff_t index;
@@ -1268,7 +1269,7 @@ static struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdevreturn ERR_PTR (-EINVAL );/* pull in the page with our super */ - page =read_cache_page_gfp (bdev_inode (bdev)->i_mapping, index,GFP_KERNEL ); + page =read_cache_page_gfp (bdev_file->f_mapping, index,GFP_KERNEL );if (IS_ERR (page))return ERR_CAST (page);
@@ -1344,14 +1345,13 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,return ERR_CAST (bdev_file); bytenr_orig =btrfs_sb_offset (0 ); - ret =btrfs_sb_log_location_bdev (file_bdev (bdev_file),0 ,READ , &bytenr); + ret =btrfs_sb_log_location_bdev (bdev_file,0 ,READ , &bytenr);if (ret) { device =ERR_PTR (ret); goto error_bdev_put; } - disk_super =btrfs_read_disk_super (file_bdev (bdev_file), bytenr, - bytenr_orig); + disk_super =btrfs_read_disk_super (bdev_file, bytenr, bytenr_orig);if (IS_ERR (disk_super)) { device =ERR_CAST (disk_super); goto error_bdev_put;
@@ -2011,14 +2011,15 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info) }static void btrfs_scratch_superblock (struct btrfs_fs_info *fs_info, -struct block_device *bdev,int copy_num) +struct file *bdev_file,int copy_num) { +struct block_device *bdev =file_bdev (bdev_file);struct btrfs_super_block *disk_super;const size_t len =sizeof (disk_super->magic);const u64 bytenr =btrfs_sb_offset (copy_num);int ret; - disk_super =btrfs_read_disk_super (bdev, bytenr, bytenr); + disk_super =btrfs_read_disk_super (bdev_file, bytenr, bytenr);if (IS_ERR (disk_super))return ;
@@ -2033,10 +2034,11 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info, }void btrfs_scratch_superblocks (struct btrfs_fs_info *fs_info, -struct block_device *bdev, +struct file *bdev_file,const char *device_path) {int copy_num; +struct block_device *bdev =file_bdev (bdev_file);if (!bdev)return ;
@@ -2045,7 +2047,7 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,if (bdev_is_zoned (bdev))btrfs_reset_sb_log_zones (bdev, copy_num);else -btrfs_scratch_superblock (fs_info, bdev, copy_num); +btrfs_scratch_superblock (fs_info, bdev_file, copy_num); }/* Notify udev that device has changed */
@@ -2187,7 +2189,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,* just flush the device and let the caller do the final bdev_release. */ if (test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state)) { -btrfs_scratch_superblocks (fs_info, device->bdev, +btrfs_scratch_superblocks (fs_info, device->bdev_file, device->name->str);if (device->bdev) {sync_blockdev (device->bdev);
@@ -2301,7 +2303,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev)mutex_unlock (&fs_devices->device_list_mutex); -btrfs_scratch_superblocks (tgtdev->fs_info, tgtdev->bdev, +btrfs_scratch_superblocks (tgtdev->fs_info, tgtdev->bdev_file, tgtdev->name->str);btrfs_close_bdev (tgtdev);
fs/btrfs/volumes.h +1 -1
@@ -781,7 +781,7 @@ struct list_head * __attribute_const__ btrfs_get_fs_uuids(void);bool btrfs_check_rw_degradable (struct btrfs_fs_info *fs_info,struct btrfs_device *failing_dev);void btrfs_scratch_superblocks (struct btrfs_fs_info *fs_info, -struct block_device *bdev, +struct file *bdev_file,const char *device_path); enum btrfs_raid_types __attribute_const__ btrfs_bg_flags_to_raid_index(u64 flags);
fs/btrfs/zoned.c +10 -8
@@ -83,7 +83,7 @@ static int copy_zone_info_cb(struct blk_zone *zone, unsigned int idx, void *datareturn 0 ; } -static int sb_write_pointer (struct block_device *bdev,struct blk_zone *zones, +static int sb_write_pointer (struct file *bdev_file,struct blk_zone *zones,u64 *wp_ret) {bool empty[BTRFS_NR_SB_LOG_ZONES ];
@@ -120,7 +120,7 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,return -ENOENT ; }else if (full[0 ] && full[1 ]) {/* Compare two super blocks */ -struct address_space *mapping =bdev_inode (bdev)->i_mapping; +struct address_space *mapping = bdev_file->f_mapping;struct page *page[BTRFS_NR_SB_LOG_ZONES ];struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES ];int i;
@@ -564,7 +564,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) BLK_ZONE_TYPE_CONVENTIONAL)continue ; - ret =sb_write_pointer (device->bdev, + ret =sb_write_pointer (device->bdev_file, &zone_info->sb_zones[sb_pos], &sb_wp);if (ret != -ENOENT && ret) { btrfs_err_in_rcu(device->fs_info,
@@ -800,18 +800,19 @@ int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info, unsigned long *mountreturn 0 ; } -static int sb_log_location (struct block_device *bdev,struct blk_zone *zones, +static int sb_log_location (struct file *bdev_file,struct blk_zone *zones,int rw,u64 *bytenr_ret) {u64 wp;int ret; +struct block_device *bdev =file_bdev (bdev_file);if (zones[0 ].type ==BLK_ZONE_TYPE_CONVENTIONAL ) { *bytenr_ret = zones[0 ].start <<SECTOR_SHIFT ;return 0 ; } - ret =sb_write_pointer (bdev, zones, &wp); + ret =sb_write_pointer (bdev_file, zones, &wp);if (ret != -ENOENT && ret <0 )return ret;
@@ -858,10 +859,11 @@ static int sb_log_location(struct block_device *bdev, struct blk_zone *zones, } -int btrfs_sb_log_location_bdev (struct block_device *bdev,int mirror,int rw, +int btrfs_sb_log_location_bdev (struct file *bdev_file,int mirror,int rw,u64 *bytenr_ret) {struct blk_zone zones[BTRFS_NR_SB_LOG_ZONES ]; +struct block_device *bdev =file_bdev (bdev_file);sector_t zone_sectors;u32 sb_zone;int ret;
@@ -895,7 +897,7 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,if (ret !=BTRFS_NR_SB_LOG_ZONES )return -EIO ; -return sb_log_location (bdev, zones, rw, bytenr_ret); +return sb_log_location (bdev_file, zones, rw, bytenr_ret); } int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
@@ -919,7 +921,7 @@ int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,if (zone_num +1 >= zinfo->nr_zones)return -ENOENT ; -return sb_log_location (device->bdev, +return sb_log_location (device->bdev_file, &zinfo->sb_zones[BTRFS_NR_SB_LOG_ZONES * mirror], rw, bytenr_ret); }
fs/btrfs/zoned.h +2 -2
@@ -46,7 +46,7 @@ void btrfs_destroy_dev_zone_info(struct btrfs_device *device);struct btrfs_zoned_device_info *btrfs_clone_dev_zone_info (struct btrfs_device *orig_dev);int btrfs_check_zoned_mode (struct btrfs_fs_info *fs_info);int btrfs_check_mountopts_zoned (struct btrfs_fs_info *info,unsigned long *mount_opt); -int btrfs_sb_log_location_bdev (struct block_device *bdev,int mirror,int rw, +int btrfs_sb_log_location_bdev (struct file *bdev_file,int mirror,int rw,u64 *bytenr_ret);int btrfs_sb_log_location (struct btrfs_device *device,int mirror,int rw,u64 *bytenr_ret);
@@ -127,7 +127,7 @@ static inline int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info,return 0 ; } -static inline int btrfs_sb_log_location_bdev (struct block_device *bdev, +static inline int btrfs_sb_log_location_bdev (struct file *bdev_file,int mirror,int rw,u64 *bytenr_ret) { *bytenr_ret =btrfs_sb_offset (mirror);
Signature · 1 line
2.43.0
Christoph Hellwig
maintainerRe: [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers
Most of these really should be using proper high level APIs. The last round of work on this is here:
Christian Brauner
maintainerRe: [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers
Quoted 4 lines · Christoph Hellwig
Most of these really should be using proper high level APIs. The last round of work on this is here:
Are you saying that I should just drop this patch here?
Christoph Hellwig
maintainerRe: [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers
Quoted 7 lines · Christian Brauner
Quoted 4 lines · Christoph Hellwig
Most of these really should be using proper high level APIs. The last round of work on this is here:
Are you saying that I should just drop this patch here?
I think we need to order the work:
- get your use struct file as bdev handle series in
- rebase the above series on top of that, including some bigger changes like block2mtd which can then use normal file read/write APIs
- rebase what is left of this series on top of that, and hopefully not much of this patch and a lot less of patch 1 will be left at that point.
Re: [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers
Hi,
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Christian Brauner
Quoted 4 lines · Christoph Hellwig
Most of these really should be using proper high level APIs. The last round of work on this is here:
Quoted 7 lines
Quoted 1 line
Are you saying that I should just drop this patch here?
I think we need to order the work:
- get your use struct file as bdev handle series in
- rebase the above series on top of that, including some bigger changes like block2mtd which can then use normal file read/write APIs
I'm working on that now, mostly convert to use bdev_file, and file_inode or f_mapingo
Quoted 6 lines
- rebase what is left of this series on top of that, and hopefully not much of this patch and a lot less of patch 1 will be left at that point.
.
Re: [PATCH RFC 2/2] fs,drivers: remove bdev_inode() usage outside of block layer and drivers
In reply to Christoph HellwigHi,
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Christian Brauner
Quoted 4 lines · Christoph Hellwig
Most of these really should be using proper high level APIs. The last round of work on this is here:
Quoted 7 lines
Quoted 1 line
Are you saying that I should just drop this patch here?
I think we need to order the work:
- get your use struct file as bdev handle series in
- rebase the above series on top of that, including some bigger changes like block2mtd which can then use normal file read/write APIs
I'm working on that now, mostly convert to use bdev_file, and file_inode to get 'bd_inode' or f_mapping to get 'bd_inode->f_mapping', and now that all fs and all drivers can avoid to access 'bd_inode' now.
Quoted 3 lines
- rebase what is left of this series on top of that, and hopefully not much of this patch and a lot less of patch 1 will be left at that point.
This is done by a huge patch for now, and there really is nothing left of this set. I'm still testing and spliting into a patchset. I'll post a RFC version soon.
Thanks,
Kuai
Quoted 3 lines
.
Christian Brauner
maintainerQuoted 29 lines · Christian Brauner
Hey Christoph,
Hey Jan,
Hey Jens,This opens block devices as files. Instead of introducing a separate indirection into bdev_open_by_*() vis struct
bdev_handlewe can just make bdev_file_open_by_*() return a struct file. Opening and closing a block device fromsetup_bdev_super()and in all other places just becomes equivalent to opening and closing a file.This has held up in xfstests and in blktests so far and it seems stable and clean. The equivalence of opening and closing block devices to regular files is a win in and of itself imho. Added to that is the ability to do away with struct
bdev_handlecompletely and make various low-level helpers private to the block layer.All places were we currently stash a struct
bdev_handlewe just stash a file and use an accessor such asfile_bdev()akin toI_BDEV()to get to the block device.It's now also possible to use
file->f_mappingas a replacement forbdev->bd_inode->i_mappingandfile->f_inodeorfile->f_mapping->hostas an alternative tobdev->bd_inodeallowing us to significantly reduce or even fully removebdev->bd_inodein follow-up patches.In addition, we could get rid of
sb->s_bdevand various other places that stash the block device directly and instead stash the block device file. Again, this is follow-up work.
Quoted 5 lines
Thanks!
ChristianSigned-off-by Christian Brauner <[email protected]>---
With all fixes applied I've moved this into vfs.super on vfs/vfs.git so this gets some exposure in -next asap. Please let me know if you have quarrels with that.
Hi!
Quoted 33 lines · Christian Brauner
Quoted 32 lines · Christian Brauner
Hey Christoph,
Hey Jan,
Hey Jens,This opens block devices as files. Instead of introducing a separate indirection into bdev_open_by_*() vis struct
bdev_handlewe can just make bdev_file_open_by_*() return a struct file. Opening and closing a block device fromsetup_bdev_super()and in all other places just becomes equivalent to opening and closing a file.This has held up in xfstests and in blktests so far and it seems stable and clean. The equivalence of opening and closing block devices to regular files is a win in and of itself imho. Added to that is the ability to do away with struct
bdev_handlecompletely and make various low-level helpers private to the block layer.All places were we currently stash a struct
bdev_handlewe just stash a file and use an accessor such asfile_bdev()akin toI_BDEV()to get to the block device.It's now also possible to use
file->f_mappingas a replacement forbdev->bd_inode->i_mappingandfile->f_inodeorfile->f_mapping->hostas an alternative tobdev->bd_inodeallowing us to significantly reduce or even fully removebdev->bd_inodein follow-up patches.In addition, we could get rid of
sb->s_bdevand various other places that stash the block device directly and instead stash the block device file. Again, this is follow-up work.Thanks!
Christian
Quoted 6 lines
Quoted 2 lines
Signed-off-by Christian Brauner <[email protected]>---
With all fixes applied I've moved this into vfs.super on vfs/vfs.git so this gets some exposure in -next asap. Please let me know if you have quarrels with that.
No quarrels really. I went through the patches and all of them look fine to me to feel free to add:
I have just noticed that in "bdev: make struct bdev_handle private to the block layer" in bdev_open() we are still leaking the handle in case of error. This is however temporary (until the end of the series when we get rid of handles altogether) so whatever.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Christian Brauner
maintainerQuoted 46 lines · Jan Kara
Hi!
Quoted 33 lines · Christian Brauner
Quoted 32 lines · Christian Brauner
Hey Christoph,
Hey Jan,
Hey Jens,This opens block devices as files. Instead of introducing a separate indirection into bdev_open_by_*() vis struct
bdev_handlewe can just make bdev_file_open_by_*() return a struct file. Opening and closing a block device fromsetup_bdev_super()and in all other places just becomes equivalent to opening and closing a file.This has held up in xfstests and in blktests so far and it seems stable and clean. The equivalence of opening and closing block devices to regular files is a win in and of itself imho. Added to that is the ability to do away with struct
bdev_handlecompletely and make various low-level helpers private to the block layer.All places were we currently stash a struct
bdev_handlewe just stash a file and use an accessor such asfile_bdev()akin toI_BDEV()to get to the block device.It's now also possible to use
file->f_mappingas a replacement forbdev->bd_inode->i_mappingandfile->f_inodeorfile->f_mapping->hostas an alternative tobdev->bd_inodeallowing us to significantly reduce or even fully removebdev->bd_inodein follow-up patches.In addition, we could get rid of
sb->s_bdevand various other places that stash the block device directly and instead stash the block device file. Again, this is follow-up work.Thanks!
ChristianQuoted 6 lines
Quoted 2 lines
Signed-off-by Christian Brauner <[email protected]>---
With all fixes applied I've moved this into vfs.super on vfs/vfs.git so this gets some exposure in -next asap. Please let me know if you have quarrels with that.
No quarrels really. I went through the patches and all of them look fine to me to feel free to add:
Quoted 6 lines
Reviewed-by Jan Kara <[email protected]>I have just noticed that in "bdev: make struct
bdev_handleprivate to the block layer" inbdev_open()we are still leaking the handle in case of error. This is however temporary (until the end of the series when we get rid of handles altogether) so whatever.
Can you double-check what's in vfs.super right now? I thought I fixed this up. I'll check too!
Jan Kara
reviewerQuoted 49 lines · Christian Brauner
Quoted 48 lines · Jan Kara
Hi!
Quoted 33 lines · Christian Brauner
Quoted 32 lines · Christian Brauner
Hey Christoph,
Hey Jan,
Hey Jens,This opens block devices as files. Instead of introducing a separate indirection into bdev_open_by_*() vis struct
bdev_handlewe can just make bdev_file_open_by_*() return a struct file. Opening and closing a block device fromsetup_bdev_super()and in all other places just becomes equivalent to opening and closing a file.This has held up in xfstests and in blktests so far and it seems stable and clean. The equivalence of opening and closing block devices to regular files is a win in and of itself imho. Added to that is the ability to do away with struct
bdev_handlecompletely and make various low-level helpers private to the block layer.All places were we currently stash a struct
bdev_handlewe just stash a file and use an accessor such asfile_bdev()akin toI_BDEV()to get to the block device.It's now also possible to use
file->f_mappingas a replacement forbdev->bd_inode->i_mappingandfile->f_inodeorfile->f_mapping->hostas an alternative tobdev->bd_inodeallowing us to significantly reduce or even fully removebdev->bd_inodein follow-up patches.In addition, we could get rid of
sb->s_bdevand various other places that stash the block device directly and instead stash the block device file. Again, this is follow-up work.Thanks!
ChristianQuoted 6 lines
Quoted 2 lines
Signed-off-by Christian Brauner <[email protected]>---
With all fixes applied I've moved this into vfs.super on vfs/vfs.git so this gets some exposure in -next asap. Please let me know if you have quarrels with that.
No quarrels really. I went through the patches and all of them look fine to me to feel free to add:
Reviewed-by Jan Kara <[email protected]>
Quoted 7 lines
Quoted 4 lines
I have just noticed that in "bdev: make struct
bdev_handleprivate to the block layer" inbdev_open()we are still leaking the handle in case of error. This is however temporary (until the end of the series when we get rid of handles altogether) so whatever.Can you double-check what's in vfs.super right now? I thought I fixed this up. I'll check too!
Well, you've fixed the "double allocation" issue but there's still a problem that you do:
int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
const struct blk_holder_ops *hops, struct file *bdev_file)
{
...
handle = kmalloc(sizeof(struct bdev_handle), GFP_KERNEL);
if (!handle)
return -ENOMEM;
if (holder) {
mode |= BLK_OPEN_EXCL;
ret = bd_prepare_to_claim(bdev, holder, hops);
if (ret)
return ret; } else {
...
So in case bd_prepare_to_claim() fails we forget to free the allocated handle.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Christian Brauner
maintainerQuoted 18 lines
Quoted 2 lines
Can you double-check what's in vfs.super right now? I thought I fixed this up. I'll check too!
Well, you've fixed the "double allocation" issue but there's still a problem that you do:
int bdev_open(struct
block_device*bdev,blk_mode_tmode, void *holder,
const structblk_holder_ops*hops, struct file*bdev_file)
{
...handle = kmalloc(sizeof(struct bdev_handle), GFP_KERNEL); if (!handle) return -ENOMEM;(quoted diff) +0
-0if (holder) { mode |= BLK_OPEN_EXCL; ret = bd_prepare_to_claim(bdev, holder, hops); if (ret)return ret;
Quoted 6 lines
} else {
...So in case
bd_prepare_to_claim()fails we forget to free the allocated handle.
Grumble grumble grumble, thank you! Fixing.
Quoted 11 lines · Christian Brauner
This opens block devices as files. Instead of introducing a separate indirection into bdev_open_by_*() vis struct
bdev_handlewe can just make bdev_file_open_by_*() return a struct file. Opening and closing a block device fromsetup_bdev_super()and in all other places just becomes equivalent to opening and closing a file.This has held up in xfstests and in blktests so far and it seems stable and clean. The equivalence of opening and closing block devices to regular files is a win in and of itself imho. Added to that is the ability to do away with struct
bdev_handlecompletely and make various low-level helpers private to the block layer.
It fails to hold up in xfstests for me.
git bisect leads to:
commit 321de651fa565dcf76c017b257bdf15ec7fff45d
Author: Christian Brauner <[email protected]> Date: Tue Jan 23 14:26:48 2024 +0100
block: don't rely on BLK_OPEN_RESTRICT_WRITES when yielding write access
QA output created by 015
mkfs failed
(see /ktest-out/xfstests/generic/015.full for details)
umount: /dev/vdc: not mounted.
** mkfs failed with extra mkfs options added to "-m reflink=1,rmapbt=1 -i sparse=1,nrext64=1" by test 015 ** ** attempting to mkfs using only test 015 options: -d size=268435456 -b size=4096 ** mkfs.xfs: cannot open /dev/vdc: Device or resource busy
mkfs failed
About half the xfstests fail this way (722 of 1387 tests)
Kent Overstreet
maintainerQuoted 28 lines · Matthew Wilcox
Quoted 11 lines · Christian Brauner
This opens block devices as files. Instead of introducing a separate indirection into bdev_open_by_*() vis struct
bdev_handlewe can just make bdev_file_open_by_*() return a struct file. Opening and closing a block device fromsetup_bdev_super()and in all other places just becomes equivalent to opening and closing a file.This has held up in xfstests and in blktests so far and it seems stable and clean. The equivalence of opening and closing block devices to regular files is a win in and of itself imho. Added to that is the ability to do away with struct
bdev_handlecompletely and make various low-level helpers private to the block layer.It fails to hold up in xfstests for me.
git bisect leads to:
commit
321de651fa565dcf76c017b257bdf15ec7fff45dAuthor: Christian Brauner <[email protected]> Date: Tue Jan 23 14:26:48 2024 +0100block: don't rely on
BLK_OPEN_RESTRICT_WRITESwhen yielding write accessQA output created by 015
mkfs failed
(see /ktest-out/xfstests/generic/015.full for details)
umount:/dev/vdc: not mounted.
Quoted 6 lines
** mkfs failed with extra mkfs options added to "-m reflink=1,rmapbt=1 -i sparse=1,nrext64=1" by test 015 ** ** attempting to mkfs using only test 015 options: -d size=268435456 -b size=4096 ** mkfs.xfs: cannot open
/dev/vdc: Device or resource busy
mkfs failedAbout half the xfstests fail this way (722 of 1387 tests)
Christain, let's chat about testing at LSF - I was looking at this too because we thought it was a ktest update that broke at first, but if we can get you using the automated test infrastructure I built this could get caught before hitting -next
Christian Brauner
maintainerQuoted 4 lines
Christain, let's chat about testing at LSF - I was looking at this too because we thought it was a ktest update that broke at first, but if we can get you using the automated test infrastructure I built this could get caught before hitting -next
I already do automated testing. This specific error depends on a new config option CONFIG_BLK_DEV_WRITE_MOUNTED which wasn't reflected in my test matrix. I've fixed that now. But I'm always happy to have the tree integrated with other automated testing as well!
Christian Brauner
maintainerQuoted 6 lines
** mkfs failed with extra mkfs options added to "-m reflink=1,rmapbt=1 -i sparse=1,nrext64=1" by test 015 ** ** attempting to mkfs using only test 015 options: -d size=268435456 -b size=4096 ** mkfs.xfs: cannot open
/dev/vdc: Device or resource busy
mkfs failedAbout half the xfstests fail this way (722 of 1387 tests)
Thanks for the report. Can you please show me the kernel config and the xfstests config that was used for this?
Quoted 9 lines · Christian Brauner
Quoted 6 lines
** mkfs failed with extra mkfs options added to "-m reflink=1,rmapbt=1 -i sparse=1,nrext64=1" by test 015 ** ** attempting to mkfs using only test 015 options: -d size=268435456 -b size=4096 ** mkfs.xfs: cannot open
/dev/vdc: Device or resource busy
mkfs failedAbout half the xfstests fail this way (722 of 1387 tests)
Thanks for the report. Can you please show me the kernel config and the xfstests config that was used for this?
Kernel config attached.
I'll have to defer to Kent on the xfstests config that's used. It might be this:
cat << EOF > /ktest/tests/xfstests/local.config
TEST_DEV=${ktest_scratch_dev[0]} TEST_DIR=$TEST_DIR SCRATCH_DEV=${ktest_scratch_dev[1]} SCRATCH_MNT=/mnt/scratch LOGWRITES_DEV=${ktest_scratch_dev[2]} RESULT_BASE=/ktest-out/xfstests LOGGER_PROG=true
EOF
Also, while generic/015 is the first to fail, you can't just run generic/015. You can't even just run 012, 013, 014, 015. I haven't bisected to exactly how many predecessor tests are necessary to get a failure.
Christian Brauner
maintainerQuoted 27 lines · Matthew Wilcox
Quoted 9 lines · Christian Brauner
Quoted 6 lines
** mkfs failed with extra mkfs options added to "-m reflink=1,rmapbt=1 -i sparse=1,nrext64=1" by test 015 ** ** attempting to mkfs using only test 015 options: -d size=268435456 -b size=4096 ** mkfs.xfs: cannot open
/dev/vdc: Device or resource busy
mkfs failedAbout half the xfstests fail this way (722 of 1387 tests)
Thanks for the report. Can you please show me the kernel config and the xfstests config that was used for this?
Kernel config attached.
I'll have to defer to Kent on the xfstests config that's used. It might be this:
cat << EOF > /ktest/tests/xfstests/local.config
TEST_DEV=${ktest_scratch_dev[0]} TEST_DIR=$TEST_DIR SCRATCH_DEV=${ktest_scratch_dev[1]} SCRATCH_MNT=/mnt/scratch LOGWRITES_DEV=${ktest_scratch_dev[2]} RESULT_BASE=/ktest-out/xfstests LOGGER_PROG=true
EOF
Quoted 4 lines
Also, while generic/015 is the first to fail, you can't just run generic/015. You can't even just run 012, 013, 014, 015. I haven't bisected to exactly how many predecessor tests are necessary to get a failure.
Thanks for the info. So it's as I suspected. The config that was used has
# CONFIG_BLK_DEV_WRITE_MOUNTED is not set
That means it isn't possible to write to mounted block devices. The default is CONFIG_BLK_DEV_WRITE_MOUNTED=y.
I go through all block-based filesystems with xfstests for such changes wit various config options. My test matrix hasn't been updated to specifically unset CONFIG_BLK_DEV_WRITE_MOUNTED which is why this escaped. I'll send a fix shortly.