Btrfs: wake up extent state waiters on unlock through clear_extent_bits
PATCH 1/1 Btrfs: wake up extent state waiters on unlock through clear_extent_bits
When we clear an extent state's EXTENT_LOCKED bit with clear_extent_bits() through free_io_failure(), we weren't waking up any tasks waiting for the extent's state EXTENT_LOCKED bit, leading to an hang.
So make sure clear_extent_bits() ends up waking up any waiters if the bit EXTENT_LOCKED is supplied by its callers.
Zygo Blaxell was experiencing such hangs at inode eviction time after file unlinks. Thanks to him for a set of scripts to reproduce the issue.
--- fs/btrfs/extent_io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/extent_io.c +6 -1
@@ -1277,7 +1277,12 @@ int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,int clear_extent_bits (struct extent_io_tree *tree,u64 start,u64 end,unsigned bits,gfp_t mask) { -return clear_extent_bit (tree, start, end, bits,0 ,0 ,NULL , mask); +int wake =0 ; + +if (bits &EXTENT_LOCKED ) + wake =1 ; + +return clear_extent_bit (tree, start, end, bits, wake,0 ,NULL , mask); } int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end,
Signature · 1 line
2.1.3
Quoted 9 lines · Filipe Manana
When we clear an extent state's
EXTENT_LOCKEDbit withclear_extent_bits()throughfree_io_failure(), we weren't waking up any tasks waiting for the extent's stateEXTENT_LOCKEDbit, leading to an hang.So make sure
clear_extent_bits()ends up waking up any waiters if the bitEXTENT_LOCKEDis supplied by its callers.Zygo Blaxell was experiencing such hangs at inode eviction time after file unlinks. Thanks to him for a set of scripts to reproduce the issue.
Good catch!
Thanks,
-liubo
Quoted 32 lines
Reported-by Zygo Blaxell <[email protected]>Signed-off-by Filipe Manana <[email protected]>--- fs/btrfs/extent_io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)fs/btrfs/extent_io.c +6
-1@@ -1277,7 +1277,12 @@ int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,int clear_extent_bits (struct extent_io_tree *tree,u64 start,u64 end,unsigned bits,gfp_t mask) { -return clear_extent_bit (tree, start, end, bits,0 ,0 ,NULL , mask); +int wake =0 ; + +if (bits &EXTENT_LOCKED ) + wake =1 ; + +return clear_extent_bit (tree, start, end, bits, wake,0 ,NULL , mask); } int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end,Signature · 6 lines
2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html