Commit bdae2a7e authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: sysfs internal/trigger_journal_flush

Add a sysfs knob for immediately flushing the entire journal.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e879389f
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ec.h" #include "ec.h"
#include "inode.h" #include "inode.h"
#include "journal.h" #include "journal.h"
#include "journal_reclaim.h"
#include "keylist.h" #include "keylist.h"
#include "move.h" #include "move.h"
#include "movinggc.h" #include "movinggc.h"
...@@ -138,6 +139,7 @@ do { \ ...@@ -138,6 +139,7 @@ do { \
write_attribute(trigger_gc); write_attribute(trigger_gc);
write_attribute(trigger_discards); write_attribute(trigger_discards);
write_attribute(trigger_invalidates); write_attribute(trigger_invalidates);
write_attribute(trigger_journal_flush);
write_attribute(prune_cache); write_attribute(prune_cache);
write_attribute(btree_wakeup); write_attribute(btree_wakeup);
rw_attribute(btree_gc_periodic); rw_attribute(btree_gc_periodic);
...@@ -500,7 +502,7 @@ STORE(bch2_fs) ...@@ -500,7 +502,7 @@ STORE(bch2_fs)
/* Debugging: */ /* Debugging: */
if (!test_bit(BCH_FS_rw, &c->flags)) if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_sysfs))
return -EROFS; return -EROFS;
if (attr == &sysfs_prune_cache) { if (attr == &sysfs_prune_cache) {
...@@ -533,6 +535,11 @@ STORE(bch2_fs) ...@@ -533,6 +535,11 @@ STORE(bch2_fs)
if (attr == &sysfs_trigger_invalidates) if (attr == &sysfs_trigger_invalidates)
bch2_do_invalidates(c); bch2_do_invalidates(c);
if (attr == &sysfs_trigger_journal_flush) {
bch2_journal_flush_all_pins(&c->journal);
bch2_journal_meta(&c->journal);
}
#ifdef CONFIG_BCACHEFS_TESTS #ifdef CONFIG_BCACHEFS_TESTS
if (attr == &sysfs_perf_test) { if (attr == &sysfs_perf_test) {
char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp; char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
...@@ -553,6 +560,7 @@ STORE(bch2_fs) ...@@ -553,6 +560,7 @@ STORE(bch2_fs)
size = ret; size = ret;
} }
#endif #endif
bch2_write_ref_put(c, BCH_WRITE_REF_sysfs);
return size; return size;
} }
SYSFS_OPS(bch2_fs); SYSFS_OPS(bch2_fs);
...@@ -651,6 +659,7 @@ struct attribute *bch2_fs_internal_files[] = { ...@@ -651,6 +659,7 @@ struct attribute *bch2_fs_internal_files[] = {
&sysfs_trigger_gc, &sysfs_trigger_gc,
&sysfs_trigger_discards, &sysfs_trigger_discards,
&sysfs_trigger_invalidates, &sysfs_trigger_invalidates,
&sysfs_trigger_journal_flush,
&sysfs_prune_cache, &sysfs_prune_cache,
&sysfs_btree_wakeup, &sysfs_btree_wakeup,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment