btrfs: consolidate the error handling in run_delalloc_nocow
authorChristoph Hellwig <hch@lst.de>
Mon, 24 Jul 2023 14:22:40 +0000 (07:22 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Aug 2023 12:54:47 +0000 (14:54 +0200)
Share the calls to extent_clear_unlock_delalloc for btrfs_path allocation
failure handling and the normal exit path.

This relies on btrfs_free_path ignoring a NULL pointer, and the
initialization of cur_offset to start at the beginning of the function.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 1fb1e4a..8d0dd26 100644 (file)
@@ -1978,13 +1978,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
 
        path = btrfs_alloc_path();
        if (!path) {
-               extent_clear_unlock_delalloc(inode, start, end, locked_page,
-                                            EXTENT_LOCKED | EXTENT_DELALLOC |
-                                            EXTENT_DO_ACCOUNTING |
-                                            EXTENT_DEFRAG, PAGE_UNLOCK |
-                                            PAGE_START_WRITEBACK |
-                                            PAGE_END_WRITEBACK);
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto error;
        }
 
        nocow_args.end = end;