diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 1001438e6a32..4f4b41c454f2 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1063,6 +1063,16 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, goto out; } + /* + * If this extent already has all the bits we want set, then + * skip it, not necessary to split it or do anything with it. + */ + if ((state->state & bits) == bits) { + start = state->end + 1; + cache_state(state, cached_state); + goto search_again; + } + prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); err = split_state(tree, state, prealloc, start);