From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 2/2] btrfs: compression: replace set_level callbacks by a common helper
Date: Wed, 21 Aug 2019 12:53:09 +0200 [thread overview]
Message-ID: <20190821105309.GV24086@twin.jikos.cz> (raw)
In-Reply-To: <adfb48ec-8cc8-2d0a-bce8-fda730e2f919@oracle.com>
On Wed, Aug 21, 2019 at 06:16:27PM +0800, Anand Jain wrote:
> On 21/8/19 12:17 AM, David Sterba wrote:
> > The set_level callbacks do not do anything special and can be replaced
> > by a helper that uses the levels defined in the tables.
> >
> > Signed-off-by: David Sterba <dsterba@suse.com>
> > ---
> > fs/btrfs/compression.c | 20 ++++++++++++++++++--
> > fs/btrfs/compression.h | 9 ++-------
> > fs/btrfs/lzo.c | 6 ------
> > fs/btrfs/zlib.c | 9 ---------
> > fs/btrfs/zstd.c | 9 ---------
> > 5 files changed, 20 insertions(+), 33 deletions(-)
> >
> > diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> > index 60c47b417a4b..53376c640f61 100644
> > --- a/fs/btrfs/compression.c
> > +++ b/fs/btrfs/compression.c
> > @@ -1039,7 +1039,7 @@ int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
> > struct list_head *workspace;
> > int ret;
> >
> > - level = btrfs_compress_op[type]->set_level(level);
> > + level = btrfs_compress_set_level(type, level);
> > workspace = get_workspace(type, level);
> > ret = btrfs_compress_op[type]->compress_pages(workspace, mapping,
> > start, pages,
> > @@ -1611,7 +1611,23 @@ unsigned int btrfs_compress_str2level(unsigned int type, const char *str)
> > level = 0;
> > }
> >
> > - level = btrfs_compress_op[type]->set_level(level);
> > + level = btrfs_compress_set_level(type, level);
> > +
> > + return level;
> > +}
> > +
> > +/*
> > + * Adjust @level according to the limits of the compression algorithm or
> > + * fallback to default
> > + */
> > +unsigned int btrfs_compress_get_level(int type, unsigned level)
> > +{
> > + const struct btrfs_compress_op *ops = btrfs_compress_op[type];
> > +
> > + if (level == 0)
> > + level = ops->default_level;
> > + else
> > + level = min(level, ops->max_level);
> >
> > return level;
> > }
> > diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
> > index cffd689adb6e..4cb8be9ff88b 100644
> > --- a/fs/btrfs/compression.h
> > +++ b/fs/btrfs/compression.h
> > @@ -156,13 +156,6 @@ struct btrfs_compress_op {
> > unsigned long start_byte,
> > size_t srclen, size_t destlen);
> >
> > - /*
> > - * This bounds the level set by the user to be within range of a
> > - * particular compression type. It returns the level that will be used
> > - * if the level is out of bounds or the default if 0 is passed in.
> > - */
> > - unsigned int (*set_level)(unsigned int level);
> > -
> > /* Maximum level supported by the compression algorithm */
> > unsigned int max_level;
> > unsigned int default_level;
> > @@ -179,6 +172,8 @@ extern const struct btrfs_compress_op btrfs_zstd_compress;
> > const char* btrfs_compress_type2str(enum btrfs_compression_type type);
> > bool btrfs_compress_is_valid_type(const char *str, size_t len);
> >
> > +unsigned int btrfs_compress_set_level(int type, unsigned level);
> > +
>
> btrfs_compress_set_level() is undefined.
Indeed, by some mistake the function is named btrfs_compress_get_level
and my compiler does not care to fail the build.
next prev parent reply other threads:[~2019-08-21 10:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 16:17 [PATCH v2 0/2] Compression level API cleanups David Sterba
2019-08-20 16:17 ` [PATCH v2 1/2] btrfs: define compression levels statically David Sterba
2019-08-21 10:55 ` Anand Jain
2019-08-20 16:17 ` [PATCH v2 2/2] btrfs: compression: replace set_level callbacks by a common helper David Sterba
2019-08-21 10:16 ` Anand Jain
2019-08-21 10:53 ` David Sterba [this message]
2019-08-21 6:52 ` [PATCH v2 0/2] Compression level API cleanups Nikolay Borisov
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=20190821105309.GV24086@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).