Skip to content

Commit 1f42a03

Browse files
author
Kent Overstreet
committed
bcachefs: sysfs trigger_emergency_read_only
Signed-off-by: Kent Overstreet <[email protected]>
1 parent 5802caf commit 1f42a03

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/bcachefs/sysfs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "disk_groups.h"
2727
#include "ec.h"
2828
#include "enumerated_ref.h"
29+
#include "error.h"
2930
#include "inode.h"
3031
#include "journal.h"
3132
#include "journal_reclaim.h"
@@ -152,6 +153,7 @@ write_attribute(trigger_btree_updates);
152153
write_attribute(trigger_freelist_wakeup);
153154
write_attribute(trigger_recalc_capacity);
154155
write_attribute(trigger_delete_dead_snapshots);
156+
write_attribute(trigger_emergency_read_only);
155157
read_attribute(gc_gens_pos);
156158

157159
read_attribute(uuid);
@@ -453,6 +455,16 @@ STORE(bch2_fs)
453455
if (attr == &sysfs_trigger_delete_dead_snapshots)
454456
__bch2_delete_dead_snapshots(c);
455457

458+
if (attr == &sysfs_trigger_emergency_read_only) {
459+
struct printbuf buf = PRINTBUF;
460+
bch2_log_msg_start(c, &buf);
461+
462+
prt_printf(&buf, "shutdown by sysfs\n");
463+
bch2_fs_emergency_read_only2(c, &buf);
464+
bch2_print_str(c, KERN_ERR, buf.buf);
465+
printbuf_exit(&buf);
466+
}
467+
456468
#ifdef CONFIG_BCACHEFS_TESTS
457469
if (attr == &sysfs_perf_test) {
458470
char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
@@ -585,6 +597,7 @@ struct attribute *bch2_fs_internal_files[] = {
585597
&sysfs_trigger_freelist_wakeup,
586598
&sysfs_trigger_recalc_capacity,
587599
&sysfs_trigger_delete_dead_snapshots,
600+
&sysfs_trigger_emergency_read_only,
588601

589602
&sysfs_gc_gens_pos,
590603

0 commit comments

Comments
 (0)