Btrfs: fix leak subvol subv_writers conter
diff mbox

Message ID 1475805689-9989-1-git-send-email-robbieko@synology.com
State New
Headers show

Commit Message

robbieko Oct. 7, 2016, 2:01 a.m. UTC
From: Robbie Ko <robbieko@synology.com>

In run_delalloc_nocow, maybe not release subv_writers conter,
will lead to create snapshot hang.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/inode.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Filipe Manana Jan. 30, 2017, 7:56 p.m. UTC | #1
On Fri, Oct 7, 2016 at 3:01 AM, robbieko <robbieko@synology.com> wrote:
> From: Robbie Ko <robbieko@synology.com>
>
> In run_delalloc_nocow, maybe not release subv_writers conter,
> will lead to create snapshot hang.
>
> Signed-off-by: Robbie Ko <robbieko@synology.com>

I've picked this into my integration branch for 4.11 and rewrote the
changelog and subject.

Thanks.

> ---
>  fs/btrfs/inode.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e6811c4..9722554 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -1386,11 +1386,17 @@ next_slot:
>                          * this ensure that csum for a given extent are
>                          * either valid or do not exist.
>                          */
> -                       if (csum_exist_in_range(root, disk_bytenr, num_bytes))
> +                       if (csum_exist_in_range(root, disk_bytenr, num_bytes)) {
> +                               if (!nolock)
> +                                       btrfs_end_write_no_snapshoting(root);
>                                 goto out_check;
> +                       }
>                         if (!btrfs_inc_nocow_writers(root->fs_info,
> -                                                    disk_bytenr))
> +                                                    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 +
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e6811c4..9722554 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1386,11 +1386,17 @@  next_slot:
 			 * this ensure that csum for a given extent are
 			 * either valid or do not exist.
 			 */
-			if (csum_exist_in_range(root, disk_bytenr, num_bytes))
+			if (csum_exist_in_range(root, disk_bytenr, num_bytes)) {
+				if (!nolock)
+					btrfs_end_write_no_snapshoting(root);
 				goto out_check;
+			}
 			if (!btrfs_inc_nocow_writers(root->fs_info,
-						     disk_bytenr))
+						     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 +