]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/btrfs/ordered-data.c
objtool: Add entry UNRET validation
[mirror_ubuntu-jammy-kernel.git] / fs / btrfs / ordered-data.c
index edb65abf0393a98d17bb79c374c0c597589da61c..6b51fd2ec5ac53fdb255db69c68a34cf4a77f569 100644 (file)
@@ -1049,6 +1049,7 @@ static int clone_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pos,
                                u64 len)
 {
        struct inode *inode = ordered->inode;
+       struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
        u64 file_offset = ordered->file_offset + pos;
        u64 disk_bytenr = ordered->disk_bytenr + pos;
        u64 num_bytes = len;
@@ -1066,6 +1067,13 @@ static int clone_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pos,
        else
                type = __ffs(flags_masked);
 
+       /*
+        * The splitting extent is already counted and will be added again
+        * in btrfs_add_ordered_extent_*(). Subtract num_bytes to avoid
+        * double counting.
+        */
+       percpu_counter_add_batch(&fs_info->ordered_bytes, -num_bytes,
+                                fs_info->delalloc_batch);
        if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered->flags)) {
                WARN_ON_ONCE(1);
                ret = btrfs_add_ordered_extent_compress(BTRFS_I(inode),