diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-06-30 18:09:05 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-07-01 19:33:49 -0400 |
commit | d21b00f6a4820d0dd53230d860b41da4a57071e6 (patch) | |
tree | 8ffda0a7e8eb5e34b96c7dfbf83d1a153c4505cd | |
parent | c755e29dc3ba7a7fd37497c34bf12aa0878fddcd (diff) |
bcachefs: opts.large_journal
By default the maximum per-device journal is 8GB (and this should
probably be revised for large memory machines).
When debugging we often want as much history as possible so that we can
reconstruct a full sequence of events: enabling this option raises the
limit to 32GB, at the expense of slower recovery from unclean shutdown.
Users with mixed ssd/hdd setups may want to ensure that only the ssds
are used for journalling, via the data_allowed option (note that we
don't yet have an easy way to remove a journal from an existing device).
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/journal.c | 14 | ||||
-rw-r--r-- | fs/bcachefs/opts.h | 6 |
2 files changed, 14 insertions, 6 deletions
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index f22b05e02c1e..ce5340611de6 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -1376,7 +1376,6 @@ int bch2_dev_journal_alloc(struct bch_dev *ca, bool new_fs) return bch_err_throw(c, erofs_filesystem_full); } - unsigned nr; int ret; if (dynamic_fault("bcachefs:add:journal_alloc")) { @@ -1385,16 +1384,19 @@ int bch2_dev_journal_alloc(struct bch_dev *ca, bool new_fs) } /* 1/128th of the device by default: */ - nr = ca->mi.nbuckets >> 7; + unsigned nr = ca->mi.nbuckets >> 7; /* - * clamp journal size to 8192 buckets or 8GB (in sectors), whichever - * is smaller: + * clamp journal size to 8GB, or 32GB with large_journal option: */ + unsigned max_sectors = 1 << 24; + + if (c->opts.large_journal) + max_sectors *= 4; + nr = clamp_t(unsigned, nr, BCH_JOURNAL_BUCKETS_MIN, - min(1 << 13, - (1 << 24) / ca->mi.bucket_size)); + max_sectors / ca->mi.bucket_size); ret = bch2_set_nr_journal_buckets_loop(c, ca, nr, new_fs); err: diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h index d6c4abd316ba..4a7a60588c10 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -343,6 +343,12 @@ enum fsck_err_opts { OPT_UINT(0, U32_MAX), \ BCH_SB_JOURNAL_RECLAIM_DELAY, 100, \ NULL, "Delay in milliseconds before automatic journal reclaim")\ + x(large_journal, bool, \ + OPT_FS|OPT_MOUNT|OPT_FORMAT, \ + OPT_BOOL(), \ + BCH2_NO_SB_OPT, false, \ + NULL, "Allocate a bigger than normal journal: recovery from unclean "\ + "shutdown will be slower, but more info will be available for debugging")\ x(move_bytes_in_flight, u32, \ OPT_HUMAN_READABLE|OPT_FS|OPT_MOUNT|OPT_RUNTIME, \ OPT_UINT(1024, U32_MAX), \ |