Skip to content

Commit

Permalink
sanitize uninitialized values
Browse files Browse the repository at this point in the history
bcachefs fsck reports a lot of unitialized values, which is a bad thing.
before the kernel sources are fixed, a temporary workaround is to clear a number of allocations,
to avoid unexpected results.
This patch improves stabilization, but has a severe performance impact

Signed-off-by: Janpieter Sollie <[email protected]>
  • Loading branch information
jpsollie committed Jul 22, 2024
1 parent 60ff4f2 commit 1fb9b67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libbcachefs/btree_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ static int btree_node_data_alloc(struct bch_fs *c, struct btree *b, gfp_t gfp)
BUG_ON(b->data || b->aux_data);

b->data = kvmalloc(btree_buf_bytes(b), gfp);
#ifdef CLEAR_PAGES_IN_ADVANCE
memset(b->data, 0, btree_buf_bytes(b));
#endif
if (!b->data)
return -BCH_ERR_ENOMEM_btree_node_mem_alloc;
#ifdef __KERNEL__
Expand Down
3 changes: 3 additions & 0 deletions libbcachefs/btree_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ static void *btree_bounce_alloc(struct bch_fs *c, size_t size,

*used_mempool = false;
p = kvmalloc(size, __GFP_NOWARN|GFP_NOWAIT);
#ifdef CLEAR_PAGES_IN_ADVANCE
memset(p, 0, size);
#endif
if (!p) {
*used_mempool = true;
p = mempool_alloc(&c->btree_bounce_pool, GFP_NOFS);
Expand Down
4 changes: 4 additions & 0 deletions libbcachefs/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#undef TRACE_SYSTEM
#define TRACE_SYSTEM bcachefs

#ifndef CLEAR_PAGES_IN_ADVANCE
#define CLEAR_PAGES_IN_ADVANCE 1
#endif

#if !defined(_TRACE_BCACHEFS_H) || defined(TRACE_HEADER_MULTI_READ)

#include <linux/tracepoint.h>
Expand Down

0 comments on commit 1fb9b67

Please sign in to comment.