Skip to contentSkip to conversation

btrfs: remove BTRFS_REF_LAST from btrfs_ref_type

PATCH Superseded Yangtao Li 4 participants 8 messages Apr 15, 2025 – Apr 16, 2025 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 btrfs: remove BTRFS_REF_LAST from btrfs_ref_type

It seems that it has never been used, so remove it.

---
 fs/btrfs/delayed-ref.h | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/delayed-ref.h +0 -1
index f5ae880308d3..78cc23837610 100644
@@ -262,7 +262,6 @@ enum btrfs_ref_type {
 	BTRFS_REF_NOT_SET,
 	BTRFS_REF_DATA,
 	BTRFS_REF_METADATA,
-	BTRFS_REF_LAST,
 } __packed;
 
 struct btrfs_ref {
Signature · 1 line
2.39.0
#1 lore raw
Quoted 1 line · Yangtao Li

It seems that it has never been used, so remove it.

History please.

Quoted 11 lines
---
  fs/btrfs/delayed-ref.h | 1 -
  1 file changed, 1 deletion(-)
fs/btrfs/delayed-ref.h +0 -0
index f5ae880308d3..78cc23837610 100644

fs/btrfs/delayed-ref.h enum btrfs_ref_type { · line 265

Quoted 4 lines
fs/btrfs/delayed-ref.h +0 -1
@@ -262,7 +262,6 @@ enum btrfs_ref_type {
  	BTRFS_REF_NOT_SET,
  	BTRFS_REF_DATA,
  	BTRFS_REF_METADATA,
-	BTRFS_REF_LAST,

The _LAST or _NR suffix can be utilized to do sanity checks, and this is not part of the on-disk format.

And if this exposed by some automatic tools, please also mention it.

Quoted 3 lines
fs/btrfs/delayed-ref.h +0 -0
  } __packed;
 
  struct btrfs_ref {
author
#2 lore raw
Quoted 1 line

History please.

Did you mean change commit msg to below?

Commit b28b1f0ce44c ("btrfs: delayed-ref: Introduce better documented delayed ref structures") introduce BTRFS_REF_LAST but never use it, So let's remove it.

Quoted 1 line

The _LAST or _NR suffix can be utilized to do sanity checks, and this is not part of the on-disk format.

IIRC, delayed ref belongs to the extent tree memory kv cache.

Quoted 1 line

And if this exposed by some automatic tools, please also mention it.

I'm just looking at this code.

Thx,
Yangtao

#3 lore raw
Quoted 6 lines · 李扬韬
Quoted 1 line

History please.

Did you mean change commit msg to below?

Commit b28b1f0ce44c ("btrfs: delayed-ref: Introduce better documented delayed ref structures") introduce BTRFS_REF_LAST but never use it, So let's remove it.

It's the common practice to leave a last entry for sanity checks.

But since it's not utilized for anything, I'm fine to remove it.

Quoted 11 lines
Quoted 2 lines

The _LAST or _NR suffix can be utilized to do sanity checks, and this is not part of the on-disk format.

IIRC, delayed ref belongs to the extent tree memory kv cache.

Quoted 1 line

And if this exposed by some automatic tools, please also mention it.

I'm just looking at this code.

Thx,
Yangtao

#4 lore raw
Quoted 5 lines · Qu Wenruo
Quoted 2 lines · 李扬韬
Quoted 1 line

History please.

Quoted 8 lines
Quoted 4 lines

Did you mean change commit msg to below?

Commit b28b1f0ce44c ("btrfs: delayed-ref: Introduce better documented delayed ref structures") introduce BTRFS_REF_LAST but never use it, So let's remove it.

It's the common practice to leave a last entry for sanity checks.

But since it's not utilized for anything, I'm fine to remove it.

I think in this case it's ok to remove it, although I agree that we have the _LAST or _NR elsewhere. In btrfs_ref_type() tere's an assertion

  ASSERT(ref->type == BTRFS_REF_DATA || ref->type == BTRFS_REF_METADATA);

which is validating the values. There's no enumeration or switch that could utilize the upper bound.

author
#5 lore raw
Quoted 5 lines

I think in this case it's ok to remove it, although I agree that we have the _LAST or _NR elsewhere. In btrfs_ref_type() tere's an assertion

ASSERT(ref->type == BTRFS_REF_DATA || ref->type == BTRFS_REF_METADATA);

which is validating the values. There's no enumeration or switch that could utilize the upper bound.

Do I need to modify the submission information and resend this patch?

Thx,
Yangtao

#6 lore raw
Quoted 7 lines · 李扬韬
Quoted 5 lines

I think in this case it's ok to remove it, although I agree that we have the _LAST or _NR elsewhere. In btrfs_ref_type() tere's an assertion

ASSERT(ref->type == BTRFS_REF_DATA || ref->type == BTRFS_REF_METADATA);

which is validating the values. There's no enumeration or switch that could utilize the upper bound.

Do I need to modify the submission information and resend this patch?

Yes please, the reasoning was missing from the original patch, we've come to a conclusion in the discussion so this should be summarized in v2.

#7 lore raw
In reply to Qu Wenruo
Quoted 11 lines
Quoted 7 lines
Quoted 1 line

History please.

Did you mean change commit msg to below?

Commit b28b1f0ce44c ("btrfs: delayed-ref: Introduce better documented delayed ref structures") introduce BTRFS_REF_LAST but never use it, So let's remove it.

It's the common practice to leave a last entry for sanity checks.

But since it's not utilized for anything, I'm fine to remove it.

We can also add comments for all this kind of codes,
so that further readers will understand this common practice better.

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

The _LAST or _NR suffix can be utilized to do sanity checks, and this is not part of the on-disk format.> >

IIRC, delayed ref belongs to the extent tree memory kv cache.

Quoted 1 line

And if this exposed by some automatic tools, please also mention it.

I'm just looking at this code.

Thx,
Yangtao