diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/btrfs/inode.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0808f483dafa..38cda78de5e4 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -5992,11 +5992,27 @@ unlock: | |||
| 5992 | * in the case of read we need to unlock only the end area that we | 5992 | * in the case of read we need to unlock only the end area that we |
| 5993 | * aren't using if there is any left over space. | 5993 | * aren't using if there is any left over space. |
| 5994 | */ | 5994 | */ |
| 5995 | if (lockstart < lockend) | 5995 | if (lockstart < lockend) { |
| 5996 | clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, | 5996 | if (create && len < lockend - lockstart) { |
| 5997 | unlock_bits, 1, 0, &cached_state, GFP_NOFS); | 5997 | clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, |
| 5998 | else | 5998 | lockstart + len - 1, unlock_bits, 1, 0, |
| 5999 | &cached_state, GFP_NOFS); | ||
| 6000 | /* | ||
| 6001 | * Beside unlock, we also need to cleanup reserved space | ||
| 6002 | * for the left range by attaching EXTENT_DO_ACCOUNTING. | ||
| 6003 | */ | ||
| 6004 | clear_extent_bit(&BTRFS_I(inode)->io_tree, | ||
| 6005 | lockstart + len, lockend, | ||
| 6006 | unlock_bits | EXTENT_DO_ACCOUNTING, | ||
| 6007 | 1, 0, NULL, GFP_NOFS); | ||
| 6008 | } else { | ||
| 6009 | clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, | ||
| 6010 | lockend, unlock_bits, 1, 0, | ||
| 6011 | &cached_state, GFP_NOFS); | ||
| 6012 | } | ||
| 6013 | } else { | ||
| 5999 | free_extent_state(cached_state); | 6014 | free_extent_state(cached_state); |
| 6015 | } | ||
| 6000 | 6016 | ||
| 6001 | free_extent_map(em); | 6017 | free_extent_map(em); |
| 6002 | 6018 | ||
