Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1530382
| From | Dan Streetman <ddstreet@ieee.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/3] z3fold: don't fail kernel build if z3fold_header is too big |
| Date | 2016-11-25 17:10 +0100 |
| Message-ID | <sHrex-2Lj-11@gated-at.bofh.it> (permalink) |
| References | <sDOjn-6QT-11@gated-at.bofh.it> <sDOt3-7aO-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Nov 15, 2016 at 11:00 AM, Vitaly Wool <vitalywool@gmail.com> wrote:
> Currently the whole kernel build will be stopped if the size of
> struct z3fold_header is greater than the size of one chunk, which
> is 64 bytes by default. This may stand in the way of automated
> test/debug builds so let's remove that and just fail the z3fold
> initialization in such case instead.
>
> Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
> ---
> mm/z3fold.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 7ad70fa..ffd9353 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -870,10 +870,15 @@ MODULE_ALIAS("zpool-z3fold");
>
> static int __init init_z3fold(void)
> {
> - /* Make sure the z3fold header will fit in one chunk */
> - BUILD_BUG_ON(sizeof(struct z3fold_header) > ZHDR_SIZE_ALIGNED);
Nak. this is the wrong way to handle this. The build bug is there to
indicate to you that your patch makes the header too large, not as a
runtime check to disable everything.
The right way to handle it is to change the hardcoded assumption that
the header fits into a single chunk; e.g.:
#define ZHDR_SIZE_ALIGNED round_up(sizeof(struct z3fold_header), CHUNK_SIZE)
#define ZHDR_CHUNKS (ZHDR_SIZE_ALIGNED >> CHUNK_SHIFT)
then use ZHDR_CHUNKS in all places where it's currently assumed the
header is 1 chunk, e.g. in num_free_chunks:
if (zhdr->middle_chunks != 0) {
int nfree_before = zhdr->first_chunks ?
- 0 : zhdr->start_middle - 1;
+ 0 : zhdr->start_middle - ZHDR_CHUNKS;
after changing all needed places like that, the build bug isn't needed
anymore (unless we want to make sure the header isn't larger than some
arbitrary number N chunks)
> - zpool_register_driver(&z3fold_zpool_driver);
> + /* Fail the initialization if z3fold header won't fit in one chunk */
> + if (sizeof(struct z3fold_header) > ZHDR_SIZE_ALIGNED) {
> + pr_err("z3fold: z3fold_header size (%d) is bigger than "
> + "the chunk size (%d), can't proceed\n",
> + sizeof(struct z3fold_header) , ZHDR_SIZE_ALIGNED);
> + return -E2BIG;
> + }
>
> + zpool_register_driver(&z3fold_zpool_driver);
> return 0;
> }
>
> --
> 2.4.2
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] z3fold: per-page spinlock and other smaller optimizations Vitaly Wool <vitalywool@gmail.com> - 2016-11-15 17:00 +0100
[PATCH 2/3] z3fold: don't fail kernel build if z3fold_header is too big Vitaly Wool <vitalywool@gmail.com> - 2016-11-15 17:10 +0100
Re: [PATCH 2/3] z3fold: don't fail kernel build if z3fold_header is too big Dan Streetman <ddstreet@ieee.org> - 2016-11-25 17:10 +0100
Re: [PATCH 2/3] z3fold: don't fail kernel build if z3fold_header is too big Vitaly Wool <vitalywool@gmail.com> - 2016-11-25 17:40 +0100
Re: [PATCH 2/3] z3fold: don't fail kernel build if z3fold_header is too big Dan Streetman <ddstreet@ieee.org> - 2016-11-25 19:40 +0100
Re: [PATCH 2/3] z3fold: don't fail kernel build if z3fold_header is too big Vitaly Wool <vitalywool@gmail.com> - 2016-11-26 10:20 +0100
[PATCH 1/3] z3fold: use per-page spinlock Vitaly Wool <vitalywool@gmail.com> - 2016-11-15 17:10 +0100
Re: [PATCH 1/3] z3fold: use per-page spinlock Dan Streetman <ddstreet@ieee.org> - 2016-11-25 17:30 +0100
[PATCH 3/3] z3fold: discourage use of pages that weren't compacted Vitaly Wool <vitalywool@gmail.com> - 2016-11-15 17:10 +0100
Re: [PATCH 3/3] z3fold: discourage use of pages that weren't compacted Dan Streetman <ddstreet@ieee.org> - 2016-11-25 19:30 +0100
Re: [PATCH 3/3] z3fold: discourage use of pages that weren't compacted Vitaly Wool <vitalywool@gmail.com> - 2016-11-28 15:20 +0100
Re: [PATCH 3/3] z3fold: discourage use of pages that weren't compacted Dan Streetman <ddstreet@ieee.org> - 2016-11-29 23:30 +0100
csiph-web