diff options
author | Josef Bacik <josef@toxicpanda.com> | 2022-09-09 17:53:17 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-09-26 12:28:02 +0200 |
commit | cdca85b092fbf4ce6f209b174ac3e7ef2b80bebf (patch) | |
tree | 3fd34bed404283eea8b8dacbe9c1cfe6843fb874 | |
parent | 87c11705cc94d6b822551e88d8d4579fe0370051 (diff) |
btrfs: use find_first_extent_bit in btrfs_clean_io_failure
Currently we're using find_first_extent_bit_state to check if our state
contains the given failrec range, however this is more of an internal
extent_io_tree helper, and is technically unsafe to use because we're
accessing the state outside of the extent_io_tree lock.
Instead use the normal helper find_first_extent_bit which returns the
range of the extent state we find in find_first_extent_bit_state and use
that to do our sanity checking.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/extent_io.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 1ab14fa7f837..f4481c2212dd 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2394,9 +2394,10 @@ int btrfs_clean_io_failure(struct btrfs_inode *inode, u64 start, struct btrfs_fs_info *fs_info = inode->root->fs_info; struct extent_io_tree *io_tree = &inode->io_tree; u64 ino = btrfs_ino(inode); + u64 locked_start, locked_end; struct io_failure_record *failrec; - struct extent_state *state; int mirror; + int ret; failrec = get_failrec(inode, start); if (IS_ERR(failrec)) @@ -2407,14 +2408,10 @@ int btrfs_clean_io_failure(struct btrfs_inode *inode, u64 start, if (sb_rdonly(fs_info->sb)) goto out; - spin_lock(&io_tree->lock); - state = find_first_extent_bit_state(io_tree, - failrec->bytenr, - EXTENT_LOCKED); - spin_unlock(&io_tree->lock); - - if (!state || state->start > failrec->bytenr || - state->end < failrec->bytenr + failrec->len - 1) + ret = find_first_extent_bit(io_tree, failrec->bytenr, &locked_start, + &locked_end, EXTENT_LOCKED, NULL); + if (ret || locked_start > failrec->bytenr || + locked_end < failrec->bytenr + failrec->len - 1) goto out; mirror = failrec->this_mirror; |