mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-08 14:23:19 +00:00
bcachefs: Ratelimiting for writeback IOs
Writeback throttling is a kernel config option and not always enabled. When it's not enabled we need a fallback, to avoid unbounded memory pinning and work item backlogs. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
ed34341189
commit
ef1b20924b
@ -191,6 +191,7 @@
|
||||
#include <linux/percpu-rwsem.h>
|
||||
#include <linux/rhashtable.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/seqlock.h>
|
||||
#include <linux/shrinker.h>
|
||||
#include <linux/srcu.h>
|
||||
@ -746,6 +747,7 @@ struct bch_fs {
|
||||
struct rw_semaphore gc_lock;
|
||||
|
||||
/* IO PATH */
|
||||
struct semaphore io_in_flight;
|
||||
struct bio_set bio_read;
|
||||
struct bio_set bio_read_split;
|
||||
struct bio_set bio_write;
|
||||
|
@ -997,6 +997,8 @@ static void bch2_writepage_io_done(struct closure *cl)
|
||||
struct bio_vec *bvec;
|
||||
unsigned i;
|
||||
|
||||
up(&io->op.c->io_in_flight);
|
||||
|
||||
if (io->op.error) {
|
||||
set_bit(EI_INODE_ERROR, &io->inode->ei_flags);
|
||||
|
||||
@ -1059,6 +1061,8 @@ static void bch2_writepage_do_io(struct bch_writepage_state *w)
|
||||
{
|
||||
struct bch_writepage_io *io = w->io;
|
||||
|
||||
down(&io->op.c->io_in_flight);
|
||||
|
||||
w->io = NULL;
|
||||
closure_call(&io->op.cl, bch2_write, NULL, &io->cl);
|
||||
continue_at(&io->cl, bch2_writepage_io_done, NULL);
|
||||
|
@ -717,6 +717,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
||||
|
||||
seqcount_init(&c->usage_lock);
|
||||
|
||||
sema_init(&c->io_in_flight, 128);
|
||||
|
||||
c->copy_gc_enabled = 1;
|
||||
c->rebalance.enabled = 1;
|
||||
c->promote_whole_extents = true;
|
||||
|
Loading…
Reference in New Issue
Block a user