ext4: add missing down_write_data_sem in mext_move_extent().
PATCH 1/1 ext4: add missing down_write_data_sem in mext_move_extent().
Commit 962e8a01eab9 ("ext4: introduce mext_move_extent()") attempts to call ext4_swap_extents() on the failure path to recover the swapped extents, but fails to acquire locks for the two inode->i_data_sem, triggering the BUG_ON statement in ext4_swap_extents().
This issue can be fixed by calling ext4_double_down_write_data_sem() before ext4_swap_extents().
--- fs/ext4/move_extent.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/move_extent.c +2 -0
@@ -393,9 +393,11 @@ static int mext_move_extent(struct mext_data *mext, u64 *m_len) repair_branches: ret2 =0 ; +ext4_double_down_write_data_sem (orig_inode, donor_inode); r_len =ext4_swap_extents (handle, donor_inode, orig_inode, mext->donor_lblk, orig_map->m_lblk, *m_len,0 , &ret2); +ext4_double_up_write_data_sem (orig_inode, donor_inode);if (ret2 || r_len != *m_len) {ext4_error_inode_block (orig_inode, (sector_t)(orig_map->m_lblk),EIO ,"Unable to copy data block, data will be lost!" );
Signature · 1 line
2.39.5
Quoted 5 lines · Julian Sun
Commit
962e8a01eab9("ext4: introducemext_move_extent()") attempts to callext4_swap_extents()on the failure path to recover the swapped extents, but fails to acquire locks for the twoinode->i_data_sem, triggering theBUG_ONstatement inext4_swap_extents().
Quoted 7 lines
This issue can be fixed by calling
ext4_double_down_write_data_sem()beforeext4_swap_extents().Signed-off-by Julian Sun <[email protected]>Reported-by [email protected]Fixes 962e8a01eab9 ("ext4: introduce mext_move_extent()")
Makes sense to me. Thanks for the fix.
Quoted 20 lines
--- fs/ext4/move_extent.c | 2 ++ 1 file changed, 2 insertions(+)fs/ext4/move_extent.c +2
-0@@ -393,9 +393,11 @@ static int mext_move_extent(struct mext_data *mext, u64 *m_len) repair_branches: ret2 =0 ; +ext4_double_down_write_data_sem (orig_inode, donor_inode); r_len =ext4_swap_extents (handle, donor_inode, orig_inode, mext->donor_lblk, orig_map->m_lblk, *m_len,0 , &ret2); +ext4_double_up_write_data_sem (orig_inode, donor_inode);if (ret2 || r_len != *m_len) {ext4_error_inode_block (orig_inode, (sector_t)(orig_map->m_lblk),EIO ,"Unable to copy data block, data will be lost!" );
Quoted 5 lines · Julian Sun
Commit
962e8a01eab9("ext4: introducemext_move_extent()") attempts to callext4_swap_extents()on the failure path to recover the swapped extents, but fails to acquire locks for the twoinode->i_data_sem, triggering theBUG_ONstatement inext4_swap_extents().
Quoted 7 lines
This issue can be fixed by calling
ext4_double_down_write_data_sem()beforeext4_swap_extents().Signed-off-by Julian Sun <[email protected]>Reported-by [email protected]Fixes 962e8a01eab9 ("ext4: introduce mext_move_extent()")
Indeed. Feel free to add:
Honza
Quoted 23 lines
--- fs/ext4/move_extent.c | 2 ++ 1 file changed, 2 insertions(+)fs/ext4/move_extent.c +2
-0@@ -393,9 +393,11 @@ static int mext_move_extent(struct mext_data *mext, u64 *m_len) repair_branches: ret2 =0 ; +ext4_double_down_write_data_sem (orig_inode, donor_inode); r_len =ext4_swap_extents (handle, donor_inode, orig_inode, mext->donor_lblk, orig_map->m_lblk, *m_len,0 , &ret2); +ext4_double_up_write_data_sem (orig_inode, donor_inode);if (ret2 || r_len != *m_len) {ext4_error_inode_block (orig_inode, (sector_t)(orig_map->m_lblk),EIO ,"Unable to copy data block, data will be lost!" );Signature · 1 line
2.39.5
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 5 lines · Julian Sun
Commit
962e8a01eab9("ext4: introducemext_move_extent()") attempts to callext4_swap_extents()on the failure path to recover the swapped extents, but fails to acquire locks for the twoinode->i_data_sem, triggering theBUG_ONstatement inext4_swap_extents().
Quoted 7 lines
This issue can be fixed by calling
ext4_double_down_write_data_sem()beforeext4_swap_extents().Signed-off-by Julian Sun <[email protected]>Reported-by [email protected]Fixes 962e8a01eab9 ("ext4: introduce mext_move_extent()")
Usually, tags like Reported-by, Closes, and Fixes are placed before Signed-off-by. Otherwise looks good. Feel free to add:
Quoted 20 lines
--- fs/ext4/move_extent.c | 2 ++ 1 file changed, 2 insertions(+)fs/ext4/move_extent.c +2
-0@@ -393,9 +393,11 @@ static int mext_move_extent(struct mext_data *mext, u64 *m_len) repair_branches: ret2 =0 ; +ext4_double_down_write_data_sem (orig_inode, donor_inode); r_len =ext4_swap_extents (handle, donor_inode, orig_inode, mext->donor_lblk, orig_map->m_lblk, *m_len,0 , &ret2); +ext4_double_up_write_data_sem (orig_inode, donor_inode);if (ret2 || r_len != *m_len) {ext4_error_inode_block (orig_inode, (sector_t)(orig_map->m_lblk),EIO ,"Unable to copy data block, data will be lost!" );
Quoted 9 lines · Julian Sun
Commit
962e8a01eab9("ext4: introducemext_move_extent()") attempts to callext4_swap_extents()on the failure path to recover the swapped extents, but fails to acquire locks for the twoinode->i_data_sem, triggering theBUG_ONstatement inext4_swap_extents().This issue can be fixed by calling
ext4_double_down_write_data_sem()beforeext4_swap_extents().[...]
Applied, thanks!
[1/1] ext4: add missing down_write_data_sem in mext_move_extent().
(no commit info)
Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>