Unverified Commit a7d98ce7 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11494 ext4: Fix race in buffer_head read fault injection

parents 2d070f50 cee9e16c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -541,7 +541,8 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group,
	trace_ext4_read_block_bitmap_load(sb, block_group, ignore_locked);
	ext4_read_bh_nowait(bh, REQ_META | REQ_PRIO |
			    (ignore_locked ? REQ_RAHEAD : 0),
			    ext4_end_bitmap_read);
			    ext4_end_bitmap_read,
			    ext4_simulate_fail(sb, EXT4_SIM_BBITMAP_EIO));
	return bh;
verify:
	err = ext4_validate_block_bitmap(sb, desc, block_group, bh);
@@ -565,7 +566,6 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group,
	if (!desc)
		return -EFSCORRUPTED;
	wait_on_buffer(bh);
	ext4_simulate_fail_bh(sb, bh, EXT4_SIM_BBITMAP_EIO);
	if (!buffer_uptodate(bh)) {
		ext4_error_err(sb, EIO, "Cannot read block bitmap - "
			       "block_group = %u, block_bitmap = %llu",
+2 −10
Original line number Diff line number Diff line
@@ -1779,14 +1779,6 @@ static inline bool ext4_simulate_fail(struct super_block *sb,
	return false;
}

static inline void ext4_simulate_fail_bh(struct super_block *sb,
					 struct buffer_head *bh,
					 unsigned long code)
{
	if (!IS_ERR(bh) && ext4_simulate_fail(sb, code))
		clear_buffer_uptodate(bh);
}

/*
 * Error number codes for s_{first,last}_error_errno
 *
@@ -2995,9 +2987,9 @@ extern struct buffer_head *ext4_sb_bread(struct super_block *sb,
extern struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
						   sector_t block);
extern void ext4_read_bh_nowait(struct buffer_head *bh, int op_flags,
				bh_end_io_t *end_io);
				bh_end_io_t *end_io, bool simu_fail);
extern int ext4_read_bh(struct buffer_head *bh, int op_flags,
			bh_end_io_t *end_io);
			bh_end_io_t *end_io, bool simu_fail);
extern int ext4_read_bh_lock(struct buffer_head *bh, int op_flags, bool wait);
extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block);
extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
+1 −1
Original line number Diff line number Diff line
@@ -544,7 +544,7 @@ __read_extent_tree_block(const char *function, unsigned int line,

	if (!bh_uptodate_or_lock(bh)) {
		trace_ext4_ext_load_extent(inode, pblk, _RET_IP_);
		err = ext4_read_bh(bh, 0, NULL);
		err = ext4_read_bh(bh, 0, NULL, false);
		if (err < 0)
			goto errout;
	}
+3 −2
Original line number Diff line number Diff line
@@ -194,8 +194,9 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
	 * submit the buffer_head for reading
	 */
	trace_ext4_load_inode_bitmap(sb, block_group);
	ext4_read_bh(bh, REQ_META | REQ_PRIO, ext4_end_bitmap_read);
	ext4_simulate_fail_bh(sb, bh, EXT4_SIM_IBITMAP_EIO);
	ext4_read_bh(bh, REQ_META | REQ_PRIO,
		     ext4_end_bitmap_read,
		     ext4_simulate_fail(sb, EXT4_SIM_IBITMAP_EIO));
	if (!buffer_uptodate(bh)) {
		put_bh(bh);
		ext4_error_err(sb, EIO, "Cannot read inode bitmap - "
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
		}

		if (!bh_uptodate_or_lock(bh)) {
			if (ext4_read_bh(bh, 0, NULL) < 0) {
			if (ext4_read_bh(bh, 0, NULL, false) < 0) {
				put_bh(bh);
				goto failure;
			}
Loading