From d85ab6ca52ba26205c32e6ffcea939698908e2c3c3c824a01b34a2a2e87dce55 Mon Sep 17 00:00:00 2001 From: Guillaume GARDET Date: Mon, 19 Apr 2021 08:17:23 +0000 Subject: [PATCH] Accepting request 886585 from hardware:boot:staging OBS-URL: https://build.opensuse.org/request/show/886585 OBS-URL: https://build.opensuse.org/package/show/hardware:boot/u-boot?expand=0&rev=142 --- ...-fs-btrfs-fix-the-false-alert-of-dec.patch | 72 +++++++++++++++++++ u-boot.changes | 7 ++ u-boot.spec | 1 + 3 files changed, 80 insertions(+) create mode 100644 0014-fs-btrfs-fix-the-false-alert-of-dec.patch diff --git a/0014-fs-btrfs-fix-the-false-alert-of-dec.patch b/0014-fs-btrfs-fix-the-false-alert-of-dec.patch new file mode 100644 index 0000000..704751b --- /dev/null +++ b/0014-fs-btrfs-fix-the-false-alert-of-dec.patch @@ -0,0 +1,72 @@ +From 95067913a0d90d37decce6835bababa0f3739275 Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Sat, 17 Apr 2021 20:52:13 +0800 +Subject: [PATCH] fs: btrfs: fix the false alert of decompression failure + +There are some cases where decompressed sectors can have padding zeros. + +In kernel code, we have lines to address such situation: + + /* + * btrfs_getblock is doing a zero on the tail of the page too, + * but this will cover anything missing from the decompressed + * data. + */ + if (bytes < destlen) + memset(kaddr+bytes, 0, destlen-bytes); + kunmap_local(kaddr); + +But not in U-boot code, thus we have some reports of U-boot failed to +read compressed files in btrfs. + +Fix it by doing the same thing of the kernel, for both inline and +regular compressed extents. + +Reported-by: Matwey Kornilov +Link: https://bugzilla.suse.com/show_bug.cgi?id=1183717 +Fixes: a26a6bedafcf ("fs: btrfs: Introduce btrfs_read_extent_inline() and btrfs_read_extent_reg()") +Signed-off-by: Qu Wenruo +--- + fs/btrfs/inode.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c +index 019d532a1a..2c2379303d 100644 +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -390,10 +390,16 @@ int btrfs_read_extent_inline(struct btrfs_path *path, + csize); + ret = btrfs_decompress(btrfs_file_extent_compression(leaf, fi), + cbuf, csize, dbuf, dsize); +- if (ret < 0 || ret != dsize) { ++ if (ret == (u32)-1) { + ret = -EIO; + goto out; + } ++ /* ++ * The compressed part ends before sector boundary, the remaining needs ++ * to be zeroed out. ++ */ ++ if (ret < dsize) ++ memset(dbuf + ret, 0, dsize - ret); + memcpy(dest, dbuf, dsize); + ret = dsize; + out: +@@ -494,10 +500,16 @@ int btrfs_read_extent_reg(struct btrfs_path *path, + + ret = btrfs_decompress(btrfs_file_extent_compression(leaf, fi), cbuf, + csize, dbuf, dsize); +- if (ret != dsize) { ++ if (ret == (u32)-1) { + ret = -EIO; + goto out; + } ++ /* ++ * The compressed part ends before sector boundary, the remaining needs ++ * to be zeroed out. ++ */ ++ if (ret < dsize) ++ memset(dbuf + ret, 0, dsize - ret); + /* Then copy the needed part */ + memcpy(dest, dbuf + btrfs_file_extent_offset(leaf, fi), len); + ret = len; diff --git a/u-boot.changes b/u-boot.changes index e05ddf2..e9bd9e9 100644 --- a/u-boot.changes +++ b/u-boot.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Apr 19 07:18:23 UTC 2021 - Guillaume GARDET + +Patch queue updated from https://github.com/openSUSE/u-boot.git tumbleweed-2021.04 +* Patches added: + 0014-fs-btrfs-fix-the-false-alert-of-dec.patch - boo#1183717 + ------------------------------------------------------------------- Fri Apr 9 12:43:13 UTC 2021 - Matthias Brugger diff --git a/u-boot.spec b/u-boot.spec index 4f1ecfe..ff3c738 100644 --- a/u-boot.spec +++ b/u-boot.spec @@ -233,6 +233,7 @@ Patch0010: 0010-sunxi-Enable-SPI-support-on-Orange-.patch Patch0011: 0011-Disable-CONFIG_CMD_BTRFS-in-xilinx_.patch Patch0012: 0012-smbios-Fix-table-when-no-string-is-.patch Patch0013: 0013-configs-rpi-Enable-SMBIOS-sysinfo-d.patch +Patch0014: 0014-fs-btrfs-fix-the-false-alert-of-dec.patch # Patches: end BuildRequires: bc BuildRequires: bison