Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: sawara04.o@gmail.com
To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
Cc: Kyoji Ogasawara <sawara04.o@gmail.com>, linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: Implement warning for commit values exceeding 300
Date: Mon, 28 Apr 2025 13:46:21 +0900	[thread overview]
Message-ID: <20250428044626.2371987-1-sawara04.o@gmail.com> (raw)

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

The Btrfs documentation states that if the commit value is greater than 300
a warning should be issued. This commit implements that functionality.
For more details, visit:
https://btrfs.readthedocs.io/en/latest/Administration.html#btrfs-specific-mount-options

Signed-off-by: Kyoji Ogasawara <sawara04.o@gmail.com>
---
 fs/btrfs/fs.h    | 1 +
 fs/btrfs/super.c | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
index b572d6b9730b..f46fba127caa 100644
--- a/fs/btrfs/fs.h
+++ b/fs/btrfs/fs.h
@@ -285,6 +285,7 @@ enum {
 #define BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR		0ULL
 
 #define BTRFS_DEFAULT_COMMIT_INTERVAL	(30)
+#define BTRFS_WARNING_COMMIT_INTERVAL	(300)
 #define BTRFS_DEFAULT_MAX_INLINE	(2048)
 
 struct btrfs_dev_replace {
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index dc4fee519ca6..c6911e9f17f2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -569,6 +569,12 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		break;
 	case Opt_commit_interval:
 		ctx->commit_interval = result.uint_32;
+		if (ctx->commit_interval > BTRFS_WARNING_COMMIT_INTERVAL) {
+			btrfs_warn(NULL,
+"commit=%u is considerably high (> %u). Large amount of data can be lost when the system crashes.",
+				ctx->commit_interval,
+				BTRFS_WARNING_COMMIT_INTERVAL);
+		}
 		if (ctx->commit_interval == 0)
 			ctx->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
 		break;
-- 
2.47.0


             reply	other threads:[~2025-04-28  4:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28  4:46 sawara04.o [this message]
2025-04-28  5:36 ` [PATCH] btrfs: Implement warning for commit values exceeding 300 Qu Wenruo
2025-04-28 15:12   ` David Sterba
     [not found]     ` <CAKNDObASvhXH3F4jRBHQ2EA6CN+-L-qgg92D2GKAorMu2g9Aig@mail.gmail.com>
2025-04-28 22:19       ` Qu Wenruo
2025-04-30 15:33         ` 小笠原 共志
2025-04-30 16:40           ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250428044626.2371987-1-sawara04.o@gmail.com \
    --to=sawara04.o@gmail.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox