From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:59234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437355AbeKXGQw (ORCPT ); Sat, 24 Nov 2018 01:16:52 -0500 Date: Fri, 23 Nov 2018 14:31:12 -0500 From: Sasha Levin To: Qu Wenruo Cc: stable@vger.kernel.org, David Sterba Subject: Re: [PATCH 2/2] btrfs: Ensure btrfs_trim_fs can trim the whole filesystem Message-ID: <20181123193112.GH1917@sasha-vm> References: <20181120022637.31746-1-wqu@suse.com> <20181120022637.31746-2-wqu@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20181120022637.31746-2-wqu@suse.com> Sender: stable-owner@vger.kernel.org List-ID: 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 >Fixes: f4c697e6406d ("btrfs: return EINVAL if start > total_bytes in fitrim ioctl") >CC: # v4.9 >Signed-off-by: Qu Wenruo >Reviewed-by: Nikolay Borisov >Reviewed-by: David Sterba >Signed-off-by: David Sterba >[ change parameter from @fs_info to @fs_info->root for older kernel ] Queued both for 4.9, thank you. -- Thanks, Sasha