Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Btrfs: reset to appropriate block rsv after orphan operations

While truncating free space cache, we forget to change trans->block_rsv
back to the original one, but leave it with the orphan_block_rsv, and
then with option inode_cache enable, it leads to countless warnings of
btrfs_alloc_free_block and btrfs_orphan_commit_root:

WARNING: at fs/btrfs/extent-tree.c:5711 btrfs_alloc_free_block+0x180/0x350 [btrfs]()
...
WARNING: at fs/btrfs/inode.c:2193 btrfs_orphan_commit_root+0xb0/0xc0 [btrfs]()

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>

authored by

Liu Bo and committed by
Chris Mason
65450aa6 ddf23b3f

+4
+4
fs/btrfs/free-space-cache.c
··· 190 190 struct btrfs_path *path, 191 191 struct inode *inode) 192 192 { 193 + struct btrfs_block_rsv *rsv; 193 194 loff_t oldsize; 194 195 int ret = 0; 195 196 197 + rsv = trans->block_rsv; 196 198 trans->block_rsv = root->orphan_block_rsv; 197 199 ret = btrfs_block_rsv_check(trans, root, 198 200 root->orphan_block_rsv, ··· 212 210 */ 213 211 ret = btrfs_truncate_inode_items(trans, root, inode, 214 212 0, BTRFS_EXTENT_DATA_KEY); 213 + 214 + trans->block_rsv = rsv; 215 215 if (ret) { 216 216 WARN_ON(1); 217 217 return ret;