remove bdev->bd_super
Subsystems (5)
Hi all,
this series is against the vfs.super branch in the VFS tree and removes the bd_super field in struct block_device.
Diffstat:
fs/buffer.c | 11 +++-------- fs/ext4/ext4_jbd2.c | 3 +-- fs/ext4/super.c | 1 - fs/ocfs2/journal.c | 6 +++--- fs/romfs/super.c | 1 - fs/super.c | 3 --- include/linux/blk_types.h | 1 - 7 files changed, 7 insertions(+), 19 deletions(-)
PATCH 1/4 fs: stop using bdev->bd_super in mark_buffer_write_io_error
bdev->bd_super is a somewhat awkward backpointer from a block device to an owning file system with unclear rules.
For the buffer_head code we already have a good backpointer for the inode that the buffer_head is associated with, even if it lives on the block device mapping: b_assoc_map. It is used track dirty buffers associated with an inode but living on the block device mapping like directory buffers in ext4.
mark_buffer_write_io_error already uses it for the call to mapping_set_error, and should be doing the same for the per-sb error sequence.
--- fs/buffer.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
fs/buffer.c +3 -8
@@ -1225,19 +1225,14 @@ EXPORT_SYMBOL(mark_buffer_dirty);void mark_buffer_write_io_error (struct buffer_head *bh) { -struct super_block *sb; -set_buffer_write_io_error (bh);/* FIXME: do we need to set this in both places? */ if (bh->b_folio && bh->b_folio->mapping)mapping_set_error (bh->b_folio->mapping, -EIO ); -if (bh->b_assoc_map) +if (bh->b_assoc_map) {mapping_set_error (bh->b_assoc_map, -EIO ); -rcu_read_lock (); - sb =READ_ONCE (bh->b_bdev->bd_super); -if (sb) -errseq_set (&sb->s_wb_err, -EIO ); -rcu_read_unlock (); +errseq_set (&bh->b_assoc_map->host->i_sb->s_wb_err, -EIO ); + } }EXPORT_SYMBOL (mark_buffer_write_io_error);
Signature · 1 line
2.39.2
PATCH 2/4 ext4: don't use bdev->bd_super in __ext4_journal_get_write_access
In reply to Christoph Hellwig__ext4_journal_get_write_access already has a super_block available, and there is no need to go from that to the bdev to go back to the owning super_block.
--- fs/ext4/ext4_jbd2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/ext4_jbd2.c +1 -2
@@ -234,8 +234,7 @@ int __ext4_journal_get_write_access(const char *where, unsigned int line,might_sleep (); -if (bh->b_bdev->bd_super) -ext4_check_bdev_write_error (bh->b_bdev->bd_super); +ext4_check_bdev_write_error (sb);if (ext4_handle_valid (handle)) { err =jbd2_journal_get_write_access (handle, bh);
Signature · 1 line
2.39.2
Re: [PATCH 2/4] ext4: don't use bdev->bd_super in __ext4_journal_get_write_access
Quoted 5 lines · Christoph Hellwig
__ext4_journal_get_write_accessalready has asuper_blockavailable, and there is no need to go from that to the bdev to go back to the owningsuper_block.Signed-off-by Christoph Hellwig <[email protected]>
PATCH 3/4 ocfs2: stop using bdev->bd_super for journal error logging
In reply to Christoph HellwigAll ocfs2 journal error handling and logging is based on buffer_heads, and the owning inode and thus super_block can be retrieved through bh->b_assoc_map->host. Switch to using that to remove the last users of bdev->bd_super.
--- fs/ocfs2/journal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ocfs2/journal.c +3 -3
@@ -557,7 +557,7 @@ static void ocfs2_abort_trigger(struct jbd2_buffer_trigger_type *triggers, (unsigned long )bh, (unsigned long long)bh->b_blocknr); -ocfs2_error (bh->b_bdev->bd_super, +ocfs2_error (bh->b_assoc_map->host->i_sb,"JBD2 has aborted our journal, ocfs2 cannot continue\n" ); }
@@ -780,14 +780,14 @@ void ocfs2_journal_dirty(handle_t *handle, struct buffer_head *bh)mlog_errno (status);if (!is_handle_aborted (handle)) {journal_t *journal = handle->h_transaction->t_journal; -struct super_block *sb = bh->b_bdev->bd_super;mlog (ML_ERROR ,"jbd2_journal_dirty_metadata failed. " "Aborting transaction and journal.\n" ); handle->h_err = status;jbd2_journal_abort_handle (handle);jbd2_journal_abort (journal, status); -ocfs2_abort (sb,"Journal already aborted.\n" ); +ocfs2_abort (bh->b_assoc_map->host->i_sb, +"Journal already aborted.\n" ); } } }
Signature · 1 line
2.39.2
Re: [PATCH 3/4] ocfs2: stop using bdev->bd_super for journal error logging
Quoted 6 lines · Christoph Hellwig
All ocfs2 journal error handling and logging is based on
buffer_heads, and the owning inode and thussuper_blockcan be retrieved throughbh->b_assoc_map->host. Switch to using that to remove the last users ofbdev->bd_super.Signed-off-by Christoph Hellwig <[email protected]>
Looks fine.
Quoted 34 lines
--- fs/ocfs2/journal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/ocfs2/journal.c +3
-3@@ -557,7 +557,7 @@ static void ocfs2_abort_trigger(struct jbd2_buffer_trigger_type *triggers, (unsigned long )bh, (unsigned long long)bh->b_blocknr); -ocfs2_error (bh->b_bdev->bd_super, +ocfs2_error (bh->b_assoc_map->host->i_sb,"JBD2 has aborted our journal, ocfs2 cannot continue\n" ); }@@ -780,14 +780,14 @@ void ocfs2_journal_dirty(handle_t *handle, struct buffer_head *bh)mlog_errno (status);if (!is_handle_aborted (handle)) {journal_t *journal = handle->h_transaction->t_journal; -struct super_block *sb = bh->b_bdev->bd_super;mlog (ML_ERROR ,"jbd2_journal_dirty_metadata failed. " "Aborting transaction and journal.\n" ); handle->h_err = status;jbd2_journal_abort_handle (handle);jbd2_journal_abort (journal, status); -ocfs2_abort (sb,"Journal already aborted.\n" ); +ocfs2_abort (bh->b_assoc_map->host->i_sb, +"Journal already aborted.\n" ); } } }
PATCH 4/4 fs, block: remove bdev->bd_super
In reply to Christoph Hellwigbdev->bd_super is unused now, remove it.
--- fs/cramfs/inode.c | 1 - fs/ext4/super.c | 1 - fs/romfs/super.c | 1 - fs/super.c | 3 --- include/linux/blk_types.h | 1 - 5 files changed, 7 deletions(-)
fs/cramfs/inode.c +0 -1
@@ -493,7 +493,6 @@ static void cramfs_kill_sb(struct super_block *sb)put_mtd_device (sb->s_mtd); sb->s_mtd =NULL ; }else if (IS_ENABLED (CONFIG_CRAMFS_BLOCKDEV ) && sb->s_bdev) { - sb->s_bdev->bd_super =NULL ;sync_blockdev (sb->s_bdev);blkdev_put (sb->s_bdev, sb); }
fs/ext4/super.c +0 -1
@@ -5563,7 +5563,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)spin_lock_init (&sbi->s_bdev_wb_lock);errseq_check_and_advance (&sb->s_bdev->bd_inode->i_mapping->wb_err, &sbi->s_bdev_wb_err); - sb->s_bdev->bd_super = sb;EXT4_SB (sb)->s_mount_state |=EXT4_ORPHAN_FS ;ext4_orphan_cleanup (sb, es);EXT4_SB (sb)->s_mount_state &= ~EXT4_ORPHAN_FS ;
fs/romfs/super.c +0 -1
@@ -593,7 +593,6 @@ static void romfs_kill_sb(struct super_block *sb)#endif #ifdef CONFIG_ROMFS_ON_BLOCK if (sb->s_bdev) { - sb->s_bdev->bd_super =NULL ;sync_blockdev (sb->s_bdev);blkdev_put (sb->s_bdev, sb); }
fs/super.c +0 -3
@@ -1369,7 +1369,6 @@ int get_tree_bdev(struct fs_context *fc,return error; } s->s_flags |=SB_ACTIVE ; - s->s_bdev->bd_super = s; }BUG_ON (fc->root);
@@ -1423,7 +1422,6 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, } s->s_flags |=SB_ACTIVE ; - s->s_bdev->bd_super = s; }return dget (s->s_root);
@@ -1436,7 +1434,6 @@ void kill_block_super(struct super_block *sb)generic_shutdown_super (sb);if (bdev) { - bdev->bd_super =NULL ;sync_blockdev (bdev);blkdev_put (bdev, sb); }
include/linux/blk_types.h +0 -1
@@ -52,7 +52,6 @@ struct block_device {atomic_t bd_openers;spinlock_t bd_size_lock;/* for bd_inode->i_size updates */ struct inode * bd_inode;/* will die */ -struct super_block * bd_super;void * bd_claiming;void * bd_holder;const struct blk_holder_ops *bd_holder_ops;
Signature · 1 line
2.39.2
Re: [PATCH 4/4] fs, block: remove bdev->bd_super
Quoted 4 lines · Christoph Hellwig
bdev->bd_superis unused now, remove it.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good to me,
Quoted 13 lines · Christoph Hellwig
this series is against the vfs.super branch in the VFS tree and removes the
bd_superfield in structblock_device.Diffstat:
fs/buffer.c | 11 +++-------- fs/ext4/ext4_jbd2.c | 3 +-- fs/ext4/super.c | 1 - fs/ocfs2/journal.c | 6 +++--- fs/romfs/super.c | 1 - fs/super.c | 3 --- include/linux/blk_types.h | 1 - 7 files changed, 7 insertions(+), 19 deletions(-)
Quoted 1 line
[...]
Applied to the vfs.super branch of the vfs/vfs.git tree. Patches in the vfs.super branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.super
[1/4] fs: stop using bdev->bd_super in mark_buffer_write_io_error
https://git.kernel.org/vfs/vfs/c/0007ce9af88c [2/4] ext4: don't use bdev->bd_super in __ext4_journal_get_write_access https://git.kernel.org/vfs/vfs/c/a9572cf0e7d2 [3/4] ocfs2: stop using bdev->bd_super for journal error logging https://git.kernel.org/vfs/vfs/c/807c772f2a12 [4/4] fs, block: remove bdev->bd_super https://git.kernel.org/vfs/vfs/c/0a59ff894703