Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Dennis Zhou <dennis@kernel.org>, David Sterba <dsterba@suse.com>,
	Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	Omar Sandoval <osandov@osandov.com>
Cc: kernel-team@fb.com, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: discard before adding to the free space cache
Date: Mon, 9 Dec 2019 22:01:20 +0200
Message-ID: <c4db5cf3-8978-b431-bd9b-1a41759fe794@suse.com> (raw)
In-Reply-To: <20191209193846.18162-1-dennis@kernel.org>



On 9.12.19 г. 21:38 ч., Dennis Zhou wrote:
> Returning free space to the free space cache lets it immediately be
> reused. So discard before returning the free space otherwise we can race
> here.
> 
> Fixes: 55e734b728c0 ("btrfs: Don't discard unwritten extents")
> Cc: Nikolay Borisov <nborisov@suse.com>
> Cc: Omar Sandoval <osandov@osandov.com>
> Signed-off-by: Dennis Zhou <dennis@kernel.org>

Fair point.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>


> ---
>  fs/btrfs/inode.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 625439875299..1ab13943cdf0 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3250,13 +3250,14 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
>  		    clear_reserved_extent &&
>  		    !test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) &&
>  		    !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) {
> -			btrfs_free_reserved_extent(fs_info,
> -						   ordered_extent->start,
> -						   ordered_extent->disk_len, 1);
>  			if (ret && btrfs_test_opt(fs_info, DISCARD))
>  				btrfs_discard_extent(fs_info,
>  						ordered_extent->start,
>  						ordered_extent->disk_len, NULL);
> +
> +			btrfs_free_reserved_extent(fs_info,
> +						   ordered_extent->start,
> +						   ordered_extent->disk_len, 1);
>  		}
>  	}
>  
> 

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 19:38 Dennis Zhou
2019-12-09 20:01 ` Nikolay Borisov [this message]
2019-12-11  8:58 ` Johannes Thumshirn
2020-01-02 14:44 ` 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=c4db5cf3-8978-b431-bd9b-1a41759fe794@suse.com \
    --to=nborisov@suse.com \
    --cc=clm@fb.com \
    --cc=dennis@kernel.org \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=osandov@osandov.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

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git