All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <dkiper@net-space.pl>
To: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Cc: The development of GNU GRUB <grub-devel@gnu.org>,
	dave@jikos.cz, mchang@suse.com, pmenzel@molgen.mpg.de,
	terrelln@fb.com
Subject: Re: [PATCH] btrfs: disable zstd support for i386-pc
Date: Thu, 7 Nov 2019 12:52:35 +0100	[thread overview]
Message-ID: <20191107115235.pxkvffcohbsho443@tomti.i.net-space.pl> (raw)
In-Reply-To: <CAEaD8JOP8haYS3_ZatzNNGwfvKbHRq08kM1MmX2h4oSAMO_Wtg@mail.gmail.com>

On Wed, Nov 06, 2019 at 11:15:04AM -0800, Vladimir 'phcoder' Serbinenko wrote:
> Please don't do it this way. The right solution is to move it to separate
> module and include zstd module when needed. Not everybody uses btrfs
> embedded area. I recommend not to use it. Using mbr gap or BBP is the
> recommended way.

I will put the cat among the pigeons. Maybe we should finally stop
pretending that the GRUB supports small MBR gaps. Otherwise we will
be fighting with such issues endlessly.

Daniel

> On Tue, 5 Nov 2019, 01:25 Michael Chang, <MChang@suse.com> wrote:
>
> > The zstd support in btrfs has dependenciy to zstd module and core.img
> > grows its size significantly to 75KB on my system. The resulted image
> > cannot be installed into btrfs bootloader area in the size of 64KB and
> > eventually fails with following message.
> >
> > /usr/sbin/grub-install: warning: your core.img is unusually large.  It
> > won't fit in the embedding area.
> > /usr/sbin/grub-install: error: filesystem `btrfs' doesn't support
> > blocklists.
> >
> > The patch disabled the zstd support of btrfs in pc-bios platform to
> > avoid the regression. The resulting size is 56KB, albeit a bit too close
> > to the 64KB but works. This is simple workaround until a proper fix
> > landed upstream.
> >
> > Signed-off-by: Michael Chang <mchang@suse.com>
> > ---
> >  grub-core/fs/btrfs.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
> > index 48bd3d04a..8f98892d3 100644
> > --- a/grub-core/fs/btrfs.c
> > +++ b/grub-core/fs/btrfs.c
> > @@ -17,6 +17,7 @@
> >   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
> >   */
> >
> > +#ifndef GRUB_MACHINE_PCBIOS
> >  /*
> >   * Tell zstd to expose functions that aren't part of the stable API, which
> >   * aren't safe to use when linking against a dynamic library. We vendor
> > in a
> > @@ -24,6 +25,7 @@
> >   * functions to provide our own allocator, which uses grub_malloc(), to
> > zstd.
> >   */
> >  #define ZSTD_STATIC_LINKING_ONLY
> > +#endif
> >
> >  #include <grub/err.h>
> >  #include <grub/file.h>
> > @@ -35,7 +37,9 @@
> >  #include <grub/lib/crc.h>
> >  #include <grub/deflate.h>
> >  #include <minilzo.h>
> > +#ifndef GRUB_MACHINE_PCBIOS
> >  #include <zstd.h>
> > +#endif
> >  #include <grub/i18n.h>
> >  #include <grub/btrfs.h>
> >  #include <grub/crypto.h>
> > @@ -56,8 +60,10 @@ GRUB_MOD_LICENSE ("GPLv3+");
> >  #define GRUB_BTRFS_LZO_BLOCK_MAX_CSIZE (GRUB_BTRFS_LZO_BLOCK_SIZE + \
> >                                      (GRUB_BTRFS_LZO_BLOCK_SIZE / 16) + 64
> > + 3)
> >
> > +#ifndef GRUB_MACHINE_PCBIOS
> >  #define ZSTD_BTRFS_MAX_WINDOWLOG 17
> >  #define ZSTD_BTRFS_MAX_INPUT     (1 << ZSTD_BTRFS_MAX_WINDOWLOG)
> > +#endif
> >
> >  typedef grub_uint8_t grub_btrfs_checksum_t[0x20];
> >  typedef grub_uint16_t grub_btrfs_uuid_t[8];
> > @@ -229,7 +235,9 @@ struct grub_btrfs_extent_data
> >  #define GRUB_BTRFS_COMPRESSION_NONE 0
> >  #define GRUB_BTRFS_COMPRESSION_ZLIB 1
> >  #define GRUB_BTRFS_COMPRESSION_LZO  2
> > +#ifndef GRUB_MACHINE_PCBIOS
> >  #define GRUB_BTRFS_COMPRESSION_ZSTD 3
> > +#endif
> >
> >  #define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100
> >
> > @@ -1229,6 +1237,7 @@ grub_btrfs_read_inode (struct grub_btrfs_data *data,
> >    return grub_btrfs_read_logical (data, elemaddr, inode, sizeof (*inode),
> > 0);
> >  }
> >
> > +#ifndef GRUB_MACHINE_PCBIOS
> >  static void *grub_zstd_malloc (void *state __attribute__((unused)),
> > size_t size)
> >  {
> >    return grub_malloc (size);
> > @@ -1318,6 +1327,7 @@ err:
> >
> >    return ret;
> >  }
> > +#endif
> >
> >  static grub_ssize_t
> >  grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
> > @@ -1494,8 +1504,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data
> > *data,
> >
> >        if (data->extent->compression != GRUB_BTRFS_COMPRESSION_NONE
> >           && data->extent->compression != GRUB_BTRFS_COMPRESSION_ZLIB
> > +#ifndef GRUB_MACHINE_PCBIOS
> >           && data->extent->compression != GRUB_BTRFS_COMPRESSION_LZO
> >           && data->extent->compression != GRUB_BTRFS_COMPRESSION_ZSTD)
> > +#else
> > +         && data->extent->compression != GRUB_BTRFS_COMPRESSION_LZO)
> > +#endif
> >         {
> >           grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
> >                       "compression type 0x%x not supported",
> > @@ -1535,6 +1549,7 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
> >                   != (grub_ssize_t) csize)
> >                 return -1;
> >             }
> > +#ifndef GRUB_MACHINE_PCBIOS
> >           else if (data->extent->compression ==
> > GRUB_BTRFS_COMPRESSION_ZSTD)
> >             {
> >               if (grub_btrfs_zstd_decompress (data->extent->inl,
> > data->extsize -
> > @@ -1544,6 +1559,7 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
> >                   != (grub_ssize_t) csize)
> >                 return -1;
> >             }
> > +#endif
> >           else
> >             grub_memcpy (buf, data->extent->inl + extoff, csize);
> >           break;
> > @@ -1581,10 +1597,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data
> > *data,
> >                 ret = grub_btrfs_lzo_decompress (tmp, zsize, extoff
> >                                     + grub_le_to_cpu64
> > (data->extent->offset),
> >                                     buf, csize);
> > +#ifndef GRUB_MACHINE_PCBIOS
> >               else if (data->extent->compression ==
> > GRUB_BTRFS_COMPRESSION_ZSTD)
> >                 ret = grub_btrfs_zstd_decompress (tmp, zsize, extoff
> >                                     + grub_le_to_cpu64
> > (data->extent->offset),
> >                                     buf, csize);
> > +#endif
> >               else
> >                 ret = -1;
> >
> > --
> > 2.16.4


  parent reply	other threads:[~2019-11-07 12:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  9:19 [PATCH] btrfs: disable zstd support for i386-pc Michael Chang
2019-11-05 10:52 ` Paul Menzel
2019-11-07  4:22   ` Michael Chang
2019-11-06 12:40 ` David Sterba
2019-11-06 18:53   ` Nick Terrell
2019-11-07  6:34   ` Michael Chang
2019-11-06 19:15 ` Vladimir 'phcoder' Serbinenko
2019-11-07  4:55   ` Michael Chang
2019-11-07  5:08     ` Vladimir 'phcoder' Serbinenko
2019-11-07  6:59       ` Michael Chang
2020-06-11 22:58       ` Eli Schwartz
2020-06-21 18:26         ` Mike Gilbert
2020-06-21 18:56           ` Eli Schwartz
2020-06-23  1:59             ` Mike Gilbert
2020-06-23  2:16             ` Mike Gilbert
2020-06-23  6:32               ` Michael Chang
2020-06-23 17:50                 ` Mike Gilbert
2019-11-07 11:52   ` Daniel Kiper [this message]
2019-11-13 11:00     ` Daniel Kiper
2019-11-14  9:53       ` Michael Chang
2019-11-15 11:42         ` Daniel Kiper
2019-11-19  8:34           ` Michael Chang
2020-03-03 16:59             ` Daniel Kiper
2020-03-04  7:58               ` Michael Chang

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=20191107115235.pxkvffcohbsho443@tomti.i.net-space.pl \
    --to=dkiper@net-space.pl \
    --cc=dave@jikos.cz \
    --cc=grub-devel@gnu.org \
    --cc=mchang@suse.com \
    --cc=phcoder@gmail.com \
    --cc=pmenzel@molgen.mpg.de \
    --cc=terrelln@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.