Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: iamhswang@gmail.com
To: linux-btrfs@vger.kernel.org
Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, wqu@suse.com,
	boris@bur.io, linux-kernel@vger.kernel.org, iamhswang@gmail.com,
	Haisu Wang <haisuwang@tencent.com>
Subject: [PATCH 1/2] btrfs: fix the length of reserved qgroup to free
Date: Fri, 25 Oct 2024 14:54:40 +0800	[thread overview]
Message-ID: <20241025065448.3231672-2-haisuwang@tencent.com> (raw)
In-Reply-To: <20241025065448.3231672-1-haisuwang@tencent.com>

From: Haisu Wang <haisuwang@tencent.com>

The dealloc flag may be cleared and the extent won't reach the disk
in cow_file_range when errors path. The reserved qgroup space is
freed in commit 30479f31d44d ("btrfs: fix qgroup reserve leaks in
cow_file_range"). However, the length of untouched region to free
need to be adjusted with the region size.

Fixes: 30479f31d44d ("btrfs: fix qgroup reserve leaks in cow_file_range")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Haisu Wang <haisuwang@tencent.com>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5618ca02934a..3646734a7e59 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1618,7 +1618,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
 		clear_bits |= EXTENT_CLEAR_DATA_RESV;
 		extent_clear_unlock_delalloc(inode, start, end, locked_folio,
 					     &cached, clear_bits, page_ops);
-		btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL);
+		btrfs_qgroup_free_data(inode, NULL, start, end - start + 1, NULL);
 	}
 	return ret;
 }
-- 
2.43.5


  reply	other threads:[~2024-10-25  6:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25  6:54 [PATCH v2 0/2] btrfs: fix the length of reserved qgroup to free iamhswang
2024-10-25  6:54 ` iamhswang [this message]
2024-10-25  6:54 ` [PATCH 2/2] btrfs: simplify regions mark and keep start unchanged in err handling iamhswang
2024-10-30  3:01   ` Qu Wenruo
2024-10-30  3:22     ` hs wang
2024-10-30 15:28     ` David Sterba
2024-10-30 22:01       ` Qu Wenruo
2024-10-30  0:13 ` [PATCH v2 0/2] btrfs: fix the length of reserved qgroup to free David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241025065448.3231672-2-haisuwang@tencent.com \
    --to=iamhswang@gmail.com \
    --cc=boris@bur.io \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=haisuwang@tencent.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox