public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Qu Wenruo <wqu@suse.com>
Cc: stable@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH 2/2] btrfs: Ensure btrfs_trim_fs can trim the whole filesystem
Date: Fri, 23 Nov 2018 14:31:12 -0500	[thread overview]
Message-ID: <20181123193112.GH1917@sasha-vm> (raw)
In-Reply-To: <20181120022637.31746-2-wqu@suse.com>

On Tue, Nov 20, 2018 at 10:26:37AM +0800, Qu Wenruo wrote:
>Commit 6ba9fc8e628becf0e3ec94083450d089b0dec5f5 upstream.
>
>[BUG]
>fstrim on some btrfs only trims the unallocated space, not trimming any
>space in existing block groups.
>
>[CAUSE]
>Before fstrim_range passed to btrfs_trim_fs(), it gets truncated to
>range [0, super->total_bytes).  So later btrfs_trim_fs() will only be
>able to trim block groups in range [0, super->total_bytes).
>
>While for btrfs, any bytenr aligned to sectorsize is valid, since btrfs
>uses its logical address space, there is nothing limiting the location
>where we put block groups.
>
>For filesystem with frequent balance, it's quite easy to relocate all
>block groups and bytenr of block groups will start beyond
>super->total_bytes.
>
>In that case, btrfs will not trim existing block groups.
>
>[FIX]
>Just remove the truncation in btrfs_ioctl_fitrim(), so btrfs_trim_fs()
>can get the unmodified range, which is normally set to [0, U64_MAX].
>
>Reported-by: Chris Murphy <lists@colorremedies.com>
>Fixes: f4c697e6406d ("btrfs: return EINVAL if start > total_bytes in fitrim ioctl")
>CC: <stable@vger.kernel.org> # v4.9
>Signed-off-by: Qu Wenruo <wqu@suse.com>
>Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>Reviewed-by: David Sterba <dsterba@suse.com>
>Signed-off-by: David Sterba <dsterba@suse.com>
>[ change parameter from @fs_info to @fs_info->root for older kernel ]

Queued both for 4.9, thank you.

--
Thanks,
Sasha

  reply	other threads:[~2018-11-24  6:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20  2:26 [PATCH 1/2] btrfs: Enhance btrfs_trim_fs function to handle error better Qu Wenruo
2018-11-20  2:26 ` [PATCH 2/2] btrfs: Ensure btrfs_trim_fs can trim the whole filesystem Qu Wenruo
2018-11-23 19:31   ` Sasha Levin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-11-12  0:32 [PATCH 1/2] btrfs: Enhance btrfs_trim_fs function to handle error better Qu Wenruo
2018-11-12  0:32 ` [PATCH 2/2] btrfs: Ensure btrfs_trim_fs can trim the whole filesystem Qu Wenruo

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=20181123193112.GH1917@sasha-vm \
    --to=sashal@kernel.org \
    --cc=dsterba@suse.com \
    --cc=stable@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