All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <dkiper@net-space.pl>
To: Nick Terrell <terrelln@fb.com>
Cc: David Sterba <dsterba@suse.cz>,
	kernel-team@fb.com, linux-btrfs@vger.kernel.org,
	grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Subject: Re: [PATCH v4 2/2] btrfs: Add zstd support to grub btrfs
Date: Tue, 6 Nov 2018 16:06:34 +0100	[thread overview]
Message-ID: <20181106150634.GB9907@router-fw-old.i.net-space.pl> (raw)
In-Reply-To: <20181031175617.230241-3-terrelln@fb.com>

On Wed, Oct 31, 2018 at 10:56:17AM -0700, Nick Terrell wrote:
> Adds zstd support to the btrfs module.
>
> Tested on Ubuntu-18.04 with a btrfs /boot partition with and without zstd
> compression. A test case was also added to the test suite that fails before
> the patch, and passes after.
>
> Signed-off-by: Nick Terrell <terrelln@fb.com>
> ---
> v1 -> v2:
> - Fix comments from Daniel Kiper.
>
> v2 -> v3:
> - Use grub_error() to set grub_errno in grub_btrfs_zstd_decompress().
> - Fix style and formatting comments.
>
> v3 -> v4:
> - Use attribute unused.
>
>  Makefile.util.def            |  10 +++-
>  grub-core/Makefile.core.def  |   2 +-
>  grub-core/fs/btrfs.c         | 108 ++++++++++++++++++++++++++++++++++-
>  tests/btrfs_test.in          |   1 +
>  tests/util/grub-fs-tester.in |   2 +-
>  5 files changed, 119 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile.util.def b/Makefile.util.def
> index 9ae45f351..3ce9388ae 100644
> --- a/Makefile.util.def
> +++ b/Makefile.util.def
> @@ -54,7 +54,7 @@ library = {
>  library = {
>    name = libgrubmods.a;
>    cflags = '-fno-builtin -Wno-undef';
> -  cppflags = '-I$(top_srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -DMINILZO_HAVE_CONFIG_H';
> +  cppflags = '-I$(srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -I$(srcdir)/grub-core/lib/zstd -DMINILZO_HAVE_CONFIG_H';

I am not strongly against s/top_srcdir/srcdir/ here. However, if you do
such things I will ask you to add a blurb why to the commit message.

[...]

> +static grub_ssize_t
> +grub_btrfs_zstd_decompress (char *ibuf, grub_size_t isize, grub_off_t off,
> +			    char *obuf, grub_size_t osize)
> +{
> +	void *allocated = NULL;
> +	char *otmpbuf = obuf;
> +	grub_size_t otmpsize = osize;
> +	ZSTD_DCtx *dctx = NULL;
> +	grub_size_t zstd_ret;
> +	grub_ssize_t ret = -1;
> +
> +	/*
> +	 * Zstd will fail if it can't fit the entire output in the destination
> +	 * buffer, so if osize isn't large enough, allocate a temporary buffer.
> +	 */
> +	if (otmpsize < ZSTD_BTRFS_MAX_INPUT) {
> +		allocated = grub_malloc (ZSTD_BTRFS_MAX_INPUT);
> +		if (!allocated) {
> +			goto err;

Hmmm... You fail silently. Should not you say something here?

> +		}

If above is OK then drop this curly brackets.

> +		otmpbuf = (char*)allocated;
> +		otmpsize = ZSTD_BTRFS_MAX_INPUT;
> +	}
> +
> +	/* Create the ZSTD_DCtx. */
> +	dctx = ZSTD_createDCtx_advanced (grub_zstd_allocator ());
> +	if (!dctx) {
> +		grub_error (GRUB_ERR_OUT_OF_MEMORY, "zstd out of memory");

...and here you complain. OK, but why GRUB_ERR_OUT_OF_MEMORY?
This probably applies to grub_zstd_allocator() but maybe not to
ZSTD_createDCtx_advanced(). AIUI both functions may return
different errors.

Daniel

      reply	other threads:[~2018-11-06 15:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 17:56 [PATCH v4 0/2] btrfs: Add zstd support to grub btrfs Nick Terrell
2018-10-31 17:56 ` [PATCH v4 1/2] Import upstream zstd-1.3.6 Nick Terrell
2018-11-06 14:48   ` Daniel Kiper
2018-11-06 19:43     ` Nick Terrell
2018-11-07 11:08       ` Daniel Kiper
2018-10-31 17:56 ` [PATCH v4 2/2] btrfs: Add zstd support to grub btrfs Nick Terrell
2018-11-06 15:06   ` Daniel Kiper [this message]

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=20181106150634.GB9907@router-fw-old.i.net-space.pl \
    --to=dkiper@net-space.pl \
    --cc=dsterba@suse.cz \
    --cc=grub-devel@gnu.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --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.