Skip to contentSkip to conversation

btrfs: Implement warning for commit values exceeding 300

PATCH Superseded [email protected] 3 participants 6 messages Apr 28, 2025 – Apr 30, 2025 1 message not in the archive Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Implement warning for commit values exceeding 300

From: Kyoji Ogasawara <[email protected]>

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

---
 fs/btrfs/fs.h    | 1 +
 fs/btrfs/super.c | 6 ++++++
 2 files changed, 7 insertions(+)
fs/btrfs/fs.h +1 -0
index b572d6b9730b..f46fba127caa 100644
@@ -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 {
fs/btrfs/super.c +6 -0
index dc4fee519ca6..c6911e9f17f2 100644
@@ -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;
Signature · 1 line
2.47.0
#1 lore raw
Quoted 30 lines · 在 2025/4/28 14:16, [email protected] 写道:

From: Kyoji Ogasawara <[email protected]>

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

---
  fs/btrfs/fs.h    | 1 +
  fs/btrfs/super.c | 6 ++++++
  2 files changed, 7 insertions(+)
fs/btrfs/fs.h +1 -0
index b572d6b9730b..f46fba127caa 100644
@@ -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 {
fs/btrfs/super.c +0 -0
index dc4fee519ca6..c6911e9f17f2 100644

fs/btrfs/super.c static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param) · line 574

Quoted 6 lines
fs/btrfs/super.c +3 -0
@@ -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.",

I'd say the large commit value is not really going to cause a lot of data on crash.
It's really depending on the workload, e.g. if there no fs activity at all for over 300s, there will be no data loss at all.

Furthermore, we do not really to scare users to use a super low value, which will cause tons of unnecessary transactions and fragments the filesystem with too many small extents (if data cow is enabled).

Another thing is, we do not even warn about more dangerous mount options, like nobarrier, thus I'm not sure if we really want such a warning.

At least I'd prefer a less scary warning, maybe just "Use with care"?

Thanks,
Qu

Quoted 6 lines
fs/btrfs/super.c +3 -0
+				ctx->commit_interval,
+				BTRFS_WARNING_COMMIT_INTERVAL);
+		}
  		if (ctx->commit_interval == 0)
  			ctx->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
  		break;
#2 lore raw
Quoted 47 lines · Qu Wenruo
Quoted 30 lines · 在 2025/4/28 14:16, [email protected] 写道:

From: Kyoji Ogasawara <[email protected]>

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

---
  fs/btrfs/fs.h    | 1 +
  fs/btrfs/super.c | 6 ++++++
  2 files changed, 7 insertions(+)
fs/btrfs/fs.h +1 -0
index b572d6b9730b..f46fba127caa 100644
@@ -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 {
fs/btrfs/super.c +0 -0
index dc4fee519ca6..c6911e9f17f2 100644

fs/btrfs/super.c static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param) · line 574

Quoted 6 lines
fs/btrfs/super.c +3 -0
@@ -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.",

I'd say the large commit value is not really going to cause a lot of data on crash.
It's really depending on the workload, e.g. if there no fs activity at all for over 300s, there will be no data loss at all.

Furthermore, we do not really to scare users to use a super low value, which will cause tons of unnecessary transactions and fragments the filesystem with too many small extents (if data cow is enabled).

Quoted 5 lines

Another thing is, we do not even warn about more dangerous mount options, like nobarrier, thus I'm not sure if we really want such a warning.

At least I'd prefer a less scary warning, maybe just "Use with care"?

We used to have the warning there before the 6.8 mount option parser rewrite and it got removed in 6941823cc87812 ("btrfs: remove old mount API code") without being properly implemented in the new API.

The wording of the message was not alarming or scarying, "excessive commit interval %u". The consequences of the large interval could be data loss but this may not be suitable for the error message as this is a corner case. I agree that 'use with care' (and read documentation) would be reasonable.

Regarding nobarrier, there's a message "turning off barriers" printed in btrfs_emit_options(), we can possibly enhance that too.

A message that is not in the archive (sent off-list or not yet received): CAKNDObASvhXH3F4jRBHQ2EA6CN+-L-qgg92D2GKAorMu2g9Aig@mail.gmail.com

#4 lore raw
Quoted 5 lines · 小笠原 共志

Thank you very much for your review and the helpful feedback.

I will revise the patch according to your suggestions, replacing the warning message with something less alarming such as "Use with care."

Additionally, would it be okay if I also update the "nobarrier" message to make it more informative?

Sure, that sounds good to me.

Thanks,
Qu

Quoted 84 lines

2025年4月29日(火) 0:13 David Sterba <[email protected] <mailto:[email protected]>>:

On Mon, Apr 28, 2025 at 03:06:14PM +0930, Qu Wenruo wrote:
> 在 2025/4/28 14:16, [email protected]
<mailto:[email protected]> 写道:
> > From: Kyoji Ogasawara <[email protected]
<mailto:[email protected]>>
> >
> > 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 <https://
btrfs.readthedocs.io/en/latest/Administration.html#btrfs-specific- mount-options>
> >
> > Signed-off-by: Kyoji Ogasawara <[email protected]
<mailto:[email protected]>>
> > ---
> >   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.",
>
> I'd say the large commit value is not really going to cause a lot of > data on crash.
> It's really depending on the workload, e.g. if there no fs
activity at
> all for over 300s, there will be no data loss at all.
>
> Furthermore, we do not really to scare users to use a super low
value,
> which will cause tons of unnecessary transactions and fragments the > filesystem with too many small extents (if data cow is enabled). >
> Another thing is, we do not even warn about more dangerous mount > options, like nobarrier, thus I'm not sure if we really want such
a warning.
>
>
> At least I'd prefer a less scary warning, maybe just "Use with care"?

We used to have the warning there before the 6.8 mount option parser rewrite and it got removed in 6941823cc87812 ("btrfs: remove old mount API code") without being properly implemented in the new API.

The wording of the message was not alarming or scarying, "excessive commit interval %u". The consequences of the large interval could be data loss but this may not be suitable for the error message as this is a corner case. I agree that 'use with care' (and read documentation) would be reasonable.

Regarding nobarrier, there's a message "turning off barriers" printed in btrfs_emit_options(), we can possibly enhance that too.

#5 lore raw
Quoted 1 line

Sure, that sounds good to me.

Thank you.

I would like to confirm whether the warning message "excessive commit interval %u, use with care" is acceptable. Please let me know if you have any concerns or suggestions for improvement.

2025年4月29日(火) 7:19 Qu Wenruo <[email protected]>:

Quoted 103 lines · 小笠原 共志
Quoted 7 lines

Thank you very much for your review and the helpful feedback.

I will revise the patch according to your suggestions, replacing the warning message with something less alarming such as "Use with care."

Additionally, would it be okay if I also update the "nobarrier" message to make it more informative?

Sure, that sounds good to me.

Thanks,
Qu

Quoted 85 lines

2025年4月29日(火) 0:13 David Sterba <[email protected]
<mailto:[email protected]>>:

On Mon, Apr 28, 2025 at 03:06:14PM +0930, Qu Wenruo wrote:
> 在 2025/4/28 14:16, [email protected]
<mailto:[email protected]> 写道:
> > From: Kyoji Ogasawara <[email protected]
<mailto:[email protected]>>
> >
> > 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 <https://
btrfs.readthedocs.io/en/latest/Administration.html#btrfs-specific- mount-options>
> >
> > Signed-off-by: Kyoji Ogasawara <[email protected]
<mailto:[email protected]>>
> > ---
> > 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.",
>
> I'd say the large commit value is not really going to cause a lot of > data on crash.
> It's really depending on the workload, e.g. if there no fs
activity at
> all for over 300s, there will be no data loss at all.
>
> Furthermore, we do not really to scare users to use a super low
value,
> which will cause tons of unnecessary transactions and fragments the > filesystem with too many small extents (if data cow is enabled). >
> Another thing is, we do not even warn about more dangerous mount > options, like nobarrier, thus I'm not sure if we really want such
a warning.
>
>
> At least I'd prefer a less scary warning, maybe just "Use with care"?

We used to have the warning there before the 6.8 mount option parser rewrite and it got removed in 6941823cc87812 ("btrfs: remove old mount API code") without being properly implemented in the new API.

The wording of the message was not alarming or scarying, "excessive commit interval %u". The consequences of the large interval could be data loss but this may not be suitable for the error message as this is a corner case. I agree that 'use with care' (and read documentation) would be reasonable.

Regarding nobarrier, there's a message "turning off barriers" printed in btrfs_emit_options(), we can possibly enhance that too.

#6 lore raw
Quoted 8 lines · 小笠原 共志
Quoted 1 line

Sure, that sounds good to me.

Thank you.

I would like to confirm whether the warning message "excessive commit interval %u, use with care" is acceptable. Please let me know if you have any concerns or suggestions for improvement.

Yes, this is OK, thanks.