linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix leak of subvolume writers counter
@ 2017-01-28  6:06 fdmanana
  2017-01-30 20:21 ` Liu Bo
  0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2017-01-28  6:06 UTC (permalink / raw)
  To: linux-btrfs

From: Robbie Ko <robbieko@synology.com>

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.

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

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 | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a713d9d..7221d66 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1404,10 +1404,16 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 			 * 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 +
-- 
2.7.0.rc3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: fix leak of subvolume writers counter
  2017-01-28  6:06 [PATCH] Btrfs: fix leak of subvolume writers counter fdmanana
@ 2017-01-30 20:21 ` Liu Bo
  0 siblings, 0 replies; 2+ messages in thread
From: Liu Bo @ 2017-01-30 20:21 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Sat, Jan 28, 2017 at 06:06:54AM +0000, fdmanana@kernel.org wrote:
> From: Robbie Ko <robbieko@synology.com>
> 
> 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.
> 
> In run_delalloc_nocow, maybe not release subv_writers conter,
> will lead to create snapshot hang.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo
> 
> 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 | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index a713d9d..7221d66 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -1404,10 +1404,16 @@ static noinline int run_delalloc_nocow(struct inode *inode,
>  			 * 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 +
> -- 
> 2.7.0.rc3
> 
> --
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-30 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-28  6:06 [PATCH] Btrfs: fix leak of subvolume writers counter fdmanana
2017-01-30 20:21 ` Liu Bo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).