]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Btrfs: fix leak of subvolume writers counter
authorRobbie Ko <robbieko@synology.com>
Fri, 7 Oct 2016 02:01:29 +0000 (10:01 +0800)
committerFilipe Manana <fdmanana@suse.com>
Fri, 24 Feb 2017 00:38:01 +0000 (00:38 +0000)
When falling back from a nocow write to a regular cow write, we were
leaking the subvolume writers counter in 2 situations, preventing
snapshot creation from ever completing in the future, as it waits
for that counter to go down to zero before the snapshot creation
starts.

Signed-off-by: Robbie Ko <robbieko@synology.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
[Improved changelog and subject]
Signed-off-by: Filipe Manana <fdmanana@suse.com>
fs/btrfs/inode.c

index c38391e948d97e3a8bd9c08bf76f0ca75a858325..4efe9d82944c1bb117d2945dc7eb67c733356faa 100644 (file)
@@ -1331,10 +1331,16 @@ next_slot:
                         * either valid or do not exist.
                         */
                        if (csum_exist_in_range(fs_info, disk_bytenr,
-                                               num_bytes))
+                                               num_bytes)) {
+                               if (!nolock)
+                                       btrfs_end_write_no_snapshoting(root);
                                goto out_check;
-                       if (!btrfs_inc_nocow_writers(fs_info, disk_bytenr))
+                       }
+                       if (!btrfs_inc_nocow_writers(fs_info, disk_bytenr)) {
+                               if (!nolock)
+                                       btrfs_end_write_no_snapshoting(root);
                                goto out_check;
+                       }
                        nocow = 1;
                } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
                        extent_end = found_key.offset +