|
26 | 26 | #include "disk_groups.h"
|
27 | 27 | #include "ec.h"
|
28 | 28 | #include "enumerated_ref.h"
|
| 29 | +#include "error.h" |
29 | 30 | #include "inode.h"
|
30 | 31 | #include "journal.h"
|
31 | 32 | #include "journal_reclaim.h"
|
@@ -152,6 +153,7 @@ write_attribute(trigger_btree_updates);
|
152 | 153 | write_attribute(trigger_freelist_wakeup);
|
153 | 154 | write_attribute(trigger_recalc_capacity);
|
154 | 155 | write_attribute(trigger_delete_dead_snapshots);
|
| 156 | +write_attribute(trigger_emergency_read_only); |
155 | 157 | read_attribute(gc_gens_pos);
|
156 | 158 |
|
157 | 159 | read_attribute(uuid);
|
@@ -453,6 +455,16 @@ STORE(bch2_fs)
|
453 | 455 | if (attr == &sysfs_trigger_delete_dead_snapshots)
|
454 | 456 | __bch2_delete_dead_snapshots(c);
|
455 | 457 |
|
| 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 | + |
456 | 468 | #ifdef CONFIG_BCACHEFS_TESTS
|
457 | 469 | if (attr == &sysfs_perf_test) {
|
458 | 470 | char *tmp = kstrdup(buf, GFP_KERNEL), *p = tmp;
|
@@ -585,6 +597,7 @@ struct attribute *bch2_fs_internal_files[] = {
|
585 | 597 | &sysfs_trigger_freelist_wakeup,
|
586 | 598 | &sysfs_trigger_recalc_capacity,
|
587 | 599 | &sysfs_trigger_delete_dead_snapshots,
|
| 600 | + &sysfs_trigger_emergency_read_only, |
588 | 601 |
|
589 | 602 | &sysfs_gc_gens_pos,
|
590 | 603 |
|
|
0 commit comments