All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jthumshirn@suse.de>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 02/15] btrfs: switch compression callbacks to direct calls
Date: Thu, 17 Oct 2019 11:42:53 +0200	[thread overview]
Message-ID: <0f4ddb93-5295-87a6-c7ff-4a45b9b75b24@suse.de> (raw)
In-Reply-To: <e8b9ace10f2df3e902158fa8f2ed2976993a759b.1571054758.git.dsterba@suse.com>

On 14/10/2019 14:22, David Sterba wrote:
> +static int compression_decompress_bio(int type, struct list_head *ws,
> +		struct compressed_bio *cb)
> +{
> +	switch (type) {
> +	case BTRFS_COMPRESS_ZLIB: return zlib_decompress_bio(ws, cb);
> +	case BTRFS_COMPRESS_LZO:  return lzo_decompress_bio(ws, cb);
> +	case BTRFS_COMPRESS_ZSTD: return zstd_decompress_bio(ws, cb);
> +	case BTRFS_COMPRESS_NONE:
> +	default:
> +		/*
> +		 * This can't happen, the type is validated several times
> +		 * before we get here.
> +		 */
> +		BUG();
> +	}
> +}
> +
> +static int compression_decompress(int type, struct list_head *ws,
> +               unsigned char *data_in, struct page *dest_page,
> +               unsigned long start_byte, size_t srclen, size_t destlen)
> +{
> +	switch (type) {
> +	case BTRFS_COMPRESS_ZLIB: return zlib_decompress(ws, data_in, dest_page,
> +						start_byte, srclen, destlen);
> +	case BTRFS_COMPRESS_LZO:  return lzo_decompress(ws, data_in, dest_page,
> +						start_byte, srclen, destlen);
> +	case BTRFS_COMPRESS_ZSTD: return zstd_decompress(ws, data_in, dest_page,
> +						start_byte, srclen, destlen);
> +	case BTRFS_COMPRESS_NONE:
> +	default:
> +		/*
> +		 * This can't happen, the type is validated several times
> +		 * before we get here.
> +		 */
> +		BUG();
> +	}
> +}

Hmm should we really BUG() here? Maybe throw in an ASSERT(), so we can
catch it in debug builds but not halt the machine (even if it
theoretically can't happen).

-- 
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn@suse.de                                +49 911 74053 689
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

  reply	other threads:[~2019-10-17  9:42 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:22 [PATCH 00/15] Remove callback indirections in compression code David Sterba
2019-10-14 12:22 ` [PATCH 01/15] btrfs: export compression and decompression callbacks David Sterba
2019-10-17  9:39   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 02/15] btrfs: switch compression callbacks to direct calls David Sterba
2019-10-17  9:42   ` Johannes Thumshirn [this message]
2019-10-17 11:24     ` David Sterba
2019-10-14 12:22 ` [PATCH 03/15] btrfs: compression: attach workspace manager to the ops David Sterba
2019-10-17 11:08   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 04/15] btrfs: compression: let workspace manager init take only the type David Sterba
2019-10-17 11:03   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 05/15] btrfs: compression: inline init_workspace_manager David Sterba
2019-10-17 11:06   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 06/15] btrfs: compression: let workspace manager cleanup take only the type David Sterba
2019-10-17 11:10   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 07/15] btrfs: compression: inline cleanup_workspace_manager David Sterba
2019-10-17 11:31   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 08/15] btrfs: compression: export alloc/free/get/put callbacks of all algos David Sterba
2019-10-17 11:44   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 09/15] btrfs: compression: inline get_workspace David Sterba
2019-10-17 11:46   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 10/15] btrfs: compression: inline put_workspace David Sterba
2019-10-17 11:49   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 11/15] btrfs: compression: pass type to btrfs_get_workspace David Sterba
2019-10-17 11:53   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 12/15] btrfs: compression: inline alloc_workspace David Sterba
2019-10-17 11:56   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 13/15] btrfs: compression: pass type to btrfs_put_workspace David Sterba
2019-10-17 11:57   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 14/15] btrfs: compression: inline free_workspace David Sterba
2019-10-17 11:58   ` Johannes Thumshirn
2019-10-14 12:22 ` [PATCH 15/15] btrfs: compression: remove ops pointer from workspace_manager David Sterba
2019-10-17 11:59   ` Johannes Thumshirn
2019-10-17 15:02 ` [PATCH 00/15] Remove callback indirections in compression code Nikolay Borisov
2019-10-17 18:19 ` David Sterba

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=0f4ddb93-5295-87a6-c7ff-4a45b9b75b24@suse.de \
    --to=jthumshirn@suse.de \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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.