mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 09:31:26 +00:00
fb3f57bb11
This adds a new btree, rebalance_work, to eliminate scanning required for finding extents that need work done on them in the background - i.e. for the background_target and background_compression options. rebalance_work is a bitset btree, where a KEY_TYPE_set corresponds to an extent in the extents or reflink btree at the same pos. A new extent field is added, bch_extent_rebalance, which indicates that this extent has work that needs to be done in the background - and which options to use. This allows per-inode options to be propagated to indirect extents - at least in some circumstances. In this patch, changing IO options on a file will not propagate the new options to indirect extents pointed to by that file. Updating (setting/clearing) the rebalance_work btree is done by the extent trigger, which looks at the bch_extent_rebalance field. Scanning is still requrired after changing IO path options - either just for a given inode, or for the whole filesystem. We indicate that scanning is required by adding a KEY_TYPE_cookie key to the rebalance_work btree: the cookie counter is so that we can detect that scanning is still required when an option has been flipped mid-way through an existing scan. Future possible work: - Propagate options to indirect extents when being changed - Add other IO path options - nr_replicas, ec, to rebalance_work so they can be applied in the background when they change - Add a counter, for bcachefs fs usage output, showing the pending amount of rebalance work: we'll probably want to do this after the disk space accounting rewrite (moving it to a new btree) Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
28 lines
679 B
C
28 lines
679 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _BCACHEFS_REBALANCE_H
|
|
#define _BCACHEFS_REBALANCE_H
|
|
|
|
#include "rebalance_types.h"
|
|
|
|
int bch2_set_rebalance_needs_scan(struct bch_fs *, u64 inum);
|
|
int bch2_set_fs_needs_rebalance(struct bch_fs *);
|
|
|
|
static inline void rebalance_wakeup(struct bch_fs *c)
|
|
{
|
|
struct task_struct *p;
|
|
|
|
rcu_read_lock();
|
|
p = rcu_dereference(c->rebalance.thread);
|
|
if (p)
|
|
wake_up_process(p);
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
void bch2_rebalance_status_to_text(struct printbuf *, struct bch_fs *);
|
|
|
|
void bch2_rebalance_stop(struct bch_fs *);
|
|
int bch2_rebalance_start(struct bch_fs *);
|
|
void bch2_fs_rebalance_init(struct bch_fs *);
|
|
|
|
#endif /* _BCACHEFS_REBALANCE_H */
|