summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-06-28 17:31:38 +0200
committerDavid Sterba <dsterba@suse.com>2023-08-21 14:52:15 +0200
commit184aa1ffa5fdf77853488c7d7fddb113cf2e33fe (patch)
tree1174f8cf3e9e1822d02aed35980c4a094959b363 /fs/btrfs/inode.c
parentbtrfs: further simplify the compress or not logic in compress_file_range (diff)
downloadlinux-184aa1ffa5fdf77853488c7d7fddb113cf2e33fe.tar.xz
linux-184aa1ffa5fdf77853488c7d7fddb113cf2e33fe.zip
btrfs: use a separate label for the incompressible case in compress_file_range
compress_file_range can fail to compress either because of resource or alignment constraints or because the data is incompressible. In the latter case the inode is marked so that compression isn't tried again. Currently that check is based on the condition that the pages array has been allocated which is rather cryptic. Use a separate label to clearly distinguish this case. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8307d2a3083a..db0dc223c4c6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -950,7 +950,7 @@ again:
mapping, start, pages, &nr_pages, &total_in,
&total_compressed);
if (ret)
- goto cleanup_and_bail_uncompressed;
+ goto mark_incompressible;
/*
* Zero the tail end of the last page, as we might be sending it down
@@ -1026,7 +1026,7 @@ again:
*/
total_in = round_up(total_in, fs_info->sectorsize);
if (total_compressed + blocksize > total_in)
- goto cleanup_and_bail_uncompressed;
+ goto mark_incompressible;
/*
* The async work queues will take care of doing actual allocation on
@@ -1041,6 +1041,9 @@ again:
}
return;
+mark_incompressible:
+ if (!btrfs_test_opt(fs_info, FORCE_COMPRESS) && !inode->prop_compress)
+ inode->flags |= BTRFS_INODE_NOCOMPRESS;
cleanup_and_bail_uncompressed:
if (pages) {
/*
@@ -1055,12 +1058,6 @@ cleanup_and_bail_uncompressed:
pages = NULL;
total_compressed = 0;
nr_pages = 0;
-
- /* flag the file so we don't compress in the future */
- if (!btrfs_test_opt(fs_info, FORCE_COMPRESS) &&
- !(inode->prop_compress)) {
- inode->flags |= BTRFS_INODE_NOCOMPRESS;
- }
}
/*