Btrfs: fix balancing oops when invalidate_inode_pages2 returns EBUSY

invalidate_inode_pages2_range may return -EBUSY occasionally
which results Oops. This patch fixes the issue by moving
invalidate_inode_pages2_range into a loop and keeping calling
it until the return value is not -EBUSY.

The EBUSY return is temporary, and can happen when the btrfs release page
function is unable to release a page because the EXTENT_LOCK
bit is set.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>

authored by Yan Zheng and committed by Chris Mason ceab36ed 60f2e8f8

+7 -2
+7 -2
fs/btrfs/relocation.c
··· 2553 2553 last_index = (start + len - 1) >> PAGE_CACHE_SHIFT; 2554 2554 2555 2555 /* make sure the dirty trick played by the caller work */ 2556 - ret = invalidate_inode_pages2_range(inode->i_mapping, 2557 - first_index, last_index); 2556 + while (1) { 2557 + ret = invalidate_inode_pages2_range(inode->i_mapping, 2558 + first_index, last_index); 2559 + if (ret != -EBUSY) 2560 + break; 2561 + schedule_timeout(HZ/10); 2562 + } 2558 2563 if (ret) 2559 2564 goto out_unlock; 2560 2565