[PATCH 1/2] btrfs: Raise nobarrier log level to warn

sawara04.o
2025-05-21T03:27:53Z

From: Kyoji Ogasawara <sawara04.o@gmail.com>

The nobarrier option disables barriers, improving performance at the cost
of potential data loss during crashes or power failures especially on devices
without reliable write-back caching.
To better reflect this risk, the log level has been raised to warn.

Signed-off-by: Kyoji Ogasawara <sawara04.o@gmail.com>
---
fs/btrfs/super.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7310e2fa8526..012b63a07ab1 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -407,10 +407,12 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
}
break;
case Opt_barrier:
- if (result.negated)
+ if (result.negated) {
btrfs_set_opt(ctx->mount_opt, NOBARRIER);
- else
+ btrfs_warn(NULL, "turning off barriers, use with care");
+ } else {
btrfs_clear_opt(ctx->mount_opt, NOBARRIER);
+ }
break;
case Opt_thread_pool:
if (result.uint_32 == 0) {
@@ -1439,7 +1441,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");
btrfs_info_if_set(info, old, SSD, "enabling ssd optimizations");
btrfs_info_if_set(info, old, SSD_SPREAD, "using spread ssd allocation scheme");
- btrfs_info_if_set(info, old, NOBARRIER, "turning off barriers");
btrfs_info_if_set(info, old, NOTREELOG, "disabling tree log");
btrfs_info_if_set(info, old, NOLOGREPLAY, "disabling log replay at mount time");
btrfs_info_if_set(info, old, FLUSHONCOMMIT, "turning on flush-on-commit");
--
2.49.0