Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Message-Id: <20230807112625.652089-2-hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Christoph Hellwig and committed by
Christian Brauner
4b2201da 06c2afb8

+3 -8
+3 -8
fs/buffer.c
··· 1225 1225 1226 1226 void mark_buffer_write_io_error(struct buffer_head *bh) 1227 1227 { 1228 - struct super_block *sb; 1229 - 1230 1228 set_buffer_write_io_error(bh); 1231 1229 /* FIXME: do we need to set this in both places? */ 1232 1230 if (bh->b_folio && bh->b_folio->mapping) 1233 1231 mapping_set_error(bh->b_folio->mapping, -EIO); 1234 - if (bh->b_assoc_map) 1232 + if (bh->b_assoc_map) { 1235 1233 mapping_set_error(bh->b_assoc_map, -EIO); 1236 - rcu_read_lock(); 1237 - sb = READ_ONCE(bh->b_bdev->bd_super); 1238 - if (sb) 1239 - errseq_set(&sb->s_wb_err, -EIO); 1240 - rcu_read_unlock(); 1234 + errseq_set(&bh->b_assoc_map->host->i_sb->s_wb_err, -EIO); 1235 + } 1241 1236 } 1242 1237 EXPORT_SYMBOL(mark_buffer_write_io_error); 1243 1238