]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
Btrfs: do not allow trimming when a fs is mounted with the nologreplay option
authorFilipe Manana <fdmanana@suse.com>
Tue, 26 Mar 2019 10:49:56 +0000 (10:49 +0000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commitcb3fbf21c129994fd7f1b5d9faf1f93200b8958e
tree708820b2909035b8cc2fa6fa502d75e7d95109f5
parent49a49f5a13211f7e4fbf07c3dbdfb921ff727564
Btrfs: do not allow trimming when a fs is mounted with the nologreplay option

BugLink: https://bugs.launchpad.net/bugs/1838116
commit f35f06c35560a86e841631f0243b83a984dc11a9 upstream.

Whan a filesystem is mounted with the nologreplay mount option, which
requires it to be mounted in RO mode as well, we can not allow discard on
free space inside block groups, because log trees refer to extents that
are not pinned in a block group's free space cache (pinning the extents is
precisely the first phase of replaying a log tree).

So do not allow the fitrim ioctl to do anything when the filesystem is
mounted with the nologreplay option, because later it can be mounted RW
without that option, which causes log replay to happen and result in
either a failure to replay the log trees (leading to a mount failure), a
crash or some silent corruption.

Reported-by: Darrick J. Wong <darrick.wong@oracle.com>
Fixes: 96da09192cda ("btrfs: Introduce new mount option to disable tree log replay")
CC: stable@vger.kernel.org # 4.9+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/ioctl.c