]> Git Repo - linux.git/commitdiff
btrfs: fix inode reserve space leak due to nowait buffered write
authorFilipe Manana <[email protected]>
Wed, 2 Nov 2022 12:46:36 +0000 (12:46 +0000)
committerDavid Sterba <[email protected]>
Wed, 2 Nov 2022 16:44:45 +0000 (17:44 +0100)
During a nowait buffered write, if we fail to balance dirty pages we exit
btrfs_buffered_write() without releasing the delalloc space reserved for
an extent, resulting in leaking space from the inode's block reserve.

So fix that by releasing the delalloc space for the extent when balancing
dirty pages fails.

Reported-by: kernel test robot <[email protected]>
Link: https://lore.kernel.org/all/[email protected]
Fixes: 965f47aeb5de ("btrfs: make btrfs_buffered_write nowait compatible")
Reviewed-by: Josef Bacik <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Signed-off-by: David Sterba <[email protected]>
fs/btrfs/file.c

index 5ce2ae9d4f72348ebf9691f9a9db90fcd1263af8..d01631d478067e788264a6bc3dcc8a3e94302748 100644 (file)
@@ -1607,8 +1607,10 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
                release_bytes = reserve_bytes;
 again:
                ret = balance_dirty_pages_ratelimited_flags(inode->i_mapping, bdp_flags);
-               if (ret)
+               if (ret) {
+                       btrfs_delalloc_release_extents(BTRFS_I(inode), reserve_bytes);
                        break;
+               }
 
                /*
                 * This is going to setup the pages array with the number of
This page took 0.054034 seconds and 4 git commands to generate.