journal.c (aaccf3c97418f169afdbb5855e9cbcbda34e90fd) journal.c (0f843e65d9eef4936929bb036c5f771fb261eea4)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * bcache journalling code, for btree insertions
4 *
5 * Copyright 2012 Google, Inc.
6 */
7
8#include "bcache.h"

--- 471 unchanged lines hidden (view full) ---

480 bio->bi_iter.bi_sector = bucket_to_sector(ca->set,
481 ca->sb.d[ja->discard_idx]);
482 bio_set_dev(bio, ca->bdev);
483 bio->bi_iter.bi_size = bucket_bytes(ca);
484 bio->bi_end_io = journal_discard_endio;
485
486 closure_get(&ca->set->cl);
487 INIT_WORK(&ja->discard_work, journal_discard_work);
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * bcache journalling code, for btree insertions
4 *
5 * Copyright 2012 Google, Inc.
6 */
7
8#include "bcache.h"

--- 471 unchanged lines hidden (view full) ---

480 bio->bi_iter.bi_sector = bucket_to_sector(ca->set,
481 ca->sb.d[ja->discard_idx]);
482 bio_set_dev(bio, ca->bdev);
483 bio->bi_iter.bi_size = bucket_bytes(ca);
484 bio->bi_end_io = journal_discard_endio;
485
486 closure_get(&ca->set->cl);
487 INIT_WORK(&ja->discard_work, journal_discard_work);
488 schedule_work(&ja->discard_work);
488 queue_work(bch_journal_wq, &ja->discard_work);
489 }
490}
491
492static void journal_reclaim(struct cache_set *c)
493{
494 struct bkey *k = &c->journal.key;
495 struct cache *ca;
496 uint64_t last_seq;

--- 90 unchanged lines hidden (view full) ---

587static void journal_write_done(struct closure *cl)
588{
589 struct journal *j = container_of(cl, struct journal, io);
590 struct journal_write *w = (j->cur == j->w)
591 ? &j->w[1]
592 : &j->w[0];
593
594 __closure_wake_up(&w->wait);
489 }
490}
491
492static void journal_reclaim(struct cache_set *c)
493{
494 struct bkey *k = &c->journal.key;
495 struct cache *ca;
496 uint64_t last_seq;

--- 90 unchanged lines hidden (view full) ---

587static void journal_write_done(struct closure *cl)
588{
589 struct journal *j = container_of(cl, struct journal, io);
590 struct journal_write *w = (j->cur == j->w)
591 ? &j->w[1]
592 : &j->w[0];
593
594 __closure_wake_up(&w->wait);
595 continue_at_nobarrier(cl, journal_write, system_wq);
595 continue_at_nobarrier(cl, journal_write, bch_journal_wq);
596}
597
598static void journal_write_unlock(struct closure *cl)
599 __releases(&c->journal.lock)
600{
601 struct cache_set *c = container_of(cl, struct cache_set, journal.io);
602
603 c->journal.io_in_flight = 0;

--- 18 unchanged lines hidden (view full) ---

622 if (!w->need_write) {
623 closure_return_with_destructor(cl, journal_write_unlock);
624 return;
625 } else if (journal_full(&c->journal)) {
626 journal_reclaim(c);
627 spin_unlock(&c->journal.lock);
628
629 btree_flush_write(c);
596}
597
598static void journal_write_unlock(struct closure *cl)
599 __releases(&c->journal.lock)
600{
601 struct cache_set *c = container_of(cl, struct cache_set, journal.io);
602
603 c->journal.io_in_flight = 0;

--- 18 unchanged lines hidden (view full) ---

622 if (!w->need_write) {
623 closure_return_with_destructor(cl, journal_write_unlock);
624 return;
625 } else if (journal_full(&c->journal)) {
626 journal_reclaim(c);
627 spin_unlock(&c->journal.lock);
628
629 btree_flush_write(c);
630 continue_at(cl, journal_write, system_wq);
630 continue_at(cl, journal_write, bch_journal_wq);
631 return;
632 }
633
634 c->journal.blocks_free -= set_blocks(w->data, block_bytes(c));
635
636 w->data->btree_level = c->root->level;
637
638 bkey_copy(&w->data->btree_root, &c->root->key);

--- 218 unchanged lines hidden ---
631 return;
632 }
633
634 c->journal.blocks_free -= set_blocks(w->data, block_bytes(c));
635
636 w->data->btree_level = c->root->level;
637
638 bkey_copy(&w->data->btree_root, &c->root->key);

--- 218 unchanged lines hidden ---