linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Justin Maggard <jmaggard10@gmail.com>, linux-btrfs@vger.kernel.org
Cc: Justin Maggard <jmaggard@netgear.com>
Subject: Re: [PATCH] btrfs: Fix quota reservation leak on preallocated files
Date: Tue, 31 Oct 2017 07:39:50 +0800	[thread overview]
Message-ID: <7dd25dd1-d7e1-0e47-5d5d-79c1ea335aa0@suse.com> (raw)
In-Reply-To: <20171030222910.21722-1-jmaggard@netgear.com>


[-- Attachment #1.1: Type: text/plain, Size: 1735 bytes --]



On 2017年10月31日 06:29, Justin Maggard wrote:
> Commit c6887cd11149 (Btrfs: don't do nocow check unless we have to)
> changed the behavior of __btrfs_buffered_write() so that it first tries
> to get a data space reservation, and then skips the relatively expensive
> nocow check if the reservation succeeded.
> 
> If we have quotas enabled, the data space reservation also includes a
> quota reservation.  But in the rewrite case, the space has already been
> accounted for in qgroups.  So btrfs_check_data_free_space() increases the
> quota reservation, but it never gets decreased when the data actually
> gets written and overwrites the pre-existing data.  So we're left with
> both the qgroup and qgroup reservation accounting for the same space.
> 
> This commit adds the missing btrfs_qgroup_free_data() call in the case of
> BTRFS_ORDERED_PREALLOC extents.
> 
> Signed-off-by: Justin Maggard <jmaggard@netgear.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/inode.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d94e3f68b9b1..d7881ccf5310 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3006,6 +3006,8 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
>  		compress_type = ordered_extent->compress_type;
>  	if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) {
>  		BUG_ON(compress_type);
> +		btrfs_qgroup_free_data(inode, NULL, ordered_extent->file_offset,
> +				       ordered_extent->len);
>  		ret = btrfs_mark_extent_written(trans, BTRFS_I(inode),
>  						ordered_extent->file_offset,
>  						ordered_extent->file_offset +
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 504 bytes --]

      reply	other threads:[~2017-10-30 23:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30 22:29 [PATCH] btrfs: Fix quota reservation leak on preallocated files Justin Maggard
2017-10-30 23:39 ` Qu Wenruo [this message]

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=7dd25dd1-d7e1-0e47-5d5d-79c1ea335aa0@suse.com \
    --to=wqu@suse.com \
    --cc=jmaggard10@gmail.com \
    --cc=jmaggard@netgear.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).