]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: do more graceful error/warning for 32bit kernel
authorQu Wenruo <wqu@suse.com>
Thu, 25 Feb 2021 01:18:14 +0000 (09:18 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 6 Apr 2021 19:08:27 +0000 (21:08 +0200)
commit56cec53374278bc93f932894cdf15fda39d7c772
tree3a83453b351512f2c99598f6ca0f77336fe8ec52
parentf1abd22b911096b542528082fa597c940b359868
btrfs: do more graceful error/warning for 32bit kernel

Due to the pagecache limit of 32bit systems, btrfs can't access metadata
at or beyond (ULONG_MAX + 1) << PAGE_SHIFT.
This is 16T for 4K page size while 256T for 64K page size.

And unlike other fses, btrfs uses internally mapped u64 address space for
all of its metadata, this is more tricky than other fses.

Users can have a fs which doesn't have metadata beyond the boundary at
mount time, but later balance can cause btrfs to create metadata beyond
the boundary.

And modification to MM layer is unrealistic just for such minor use
case.

To address such problem, this patch will introduce the following checks:

- Mount time rejection
  This will reject any fs which has metadata chunk at or beyond the
  boundary.

- Mount time early warning
  If there is any metadata chunk beyond 5/8 of the boundary, we do an
  early warning and hope the end user will see it.

- Runtime extent buffer rejection
  If we're going to allocate an extent buffer at or beyond the boundary,
  reject such request with -EOVERFLOW.
  This is definitely going to cause problems like transaction abort, but
  we have no better ways.

- Runtime extent buffer early warning
  If an extent buffer beyond 5/8 of the max file size is allocated, do
  an early warning.

Above error/warning message will only be outputted once for each fs to
reduce dmesg flood.

Reported-by: Erik Jensen <erikjensen@rkjnsn.net>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent_io.c
fs/btrfs/super.c
fs/btrfs/volumes.c