#include "journal_reclaim.h"
#include "journal_seq_blacklist.h"
#include "super-io.h"
+#include "trace.h"
#include <linux/sched/mm.h>
-#include <trace/events/bcachefs.h>
void bch2_btree_node_io_unlock(struct btree *b)
{
vpfree(p, size);
}
-static void *_btree_bounce_alloc(struct bch_fs *c, size_t size,
- bool *used_mempool)
+static void *btree_bounce_alloc(struct bch_fs *c, size_t size,
+ bool *used_mempool)
{
unsigned flags = memalloc_nofs_save();
void *p;
BUG_ON(size > btree_bytes(c));
*used_mempool = false;
- p = _vpmalloc(size, __GFP_NOWARN|GFP_NOWAIT);
+ p = vpmalloc(size, __GFP_NOWARN|GFP_NOWAIT);
if (!p) {
*used_mempool = true;
- p = mempool_alloc(&c->btree_bounce_pool, GFP_NOIO);
+ p = mempool_alloc(&c->btree_bounce_pool, GFP_NOFS);
}
memalloc_nofs_restore(flags);
return p;
}
-#define btree_bounce_alloc(_c, _size, _used_mempool) \
- alloc_hooks(_btree_bounce_alloc(_c, _size, _used_mempool), void *, NULL)
static void sort_bkey_ptrs(const struct btree *bt,
struct bkey_packed **ptrs, unsigned nr)
struct btree_node_entry *bne;
bool reinit_iter = false;
- EBUG_ON(!(b->c.lock.state.seq & 1));
+ EBUG_ON(!six_lock_counts(&b->c.lock).n[SIX_LOCK_write]);
BUG_ON(bset_written(b, bset(b, &b->set[1])));
BUG_ON(btree_node_just_written(b));
/* We might get called multiple times on read retry: */
b->written = 0;
- iter = mempool_alloc(&c->fill_iter, GFP_NOIO);
+ iter = mempool_alloc(&c->fill_iter, GFP_NOFS);
sort_iter_init(iter, b);
iter->size = (btree_blocks(c) + 1) * 2;
bio = bio_alloc_bioset(NULL,
buf_pages(b->data, btree_bytes(c)),
REQ_OP_READ|REQ_SYNC|REQ_META,
- GFP_NOIO,
+ GFP_NOFS,
&c->btree_bio);
rb = container_of(bio, struct btree_read_bio, bio);
rb->c = c;
struct bch_fs *c = wbio->wbio.c;
struct btree *b = wbio->wbio.bio.bi_private;
struct bch_extent_ptr *ptr;
- int ret;
+ int ret = 0;
btree_bounce_free(c,
wbio->data_bytes,
return;
err:
set_btree_node_noevict(b);
- bch2_fs_fatal_error(c, "fatal error writing btree node");
+ if (!bch2_err_matches(ret, EROFS))
+ bch2_fs_fatal_error(c, "fatal error writing btree node");
goto out;
}
wbio = container_of(bio_alloc_bioset(NULL,
buf_pages(data, sectors_to_write << 9),
REQ_OP_WRITE|REQ_META,
- GFP_NOIO,
+ GFP_NOFS,
&c->btree_bio),
struct btree_write_bio, wbio.bio);
wbio_init(&wbio->wbio.bio);