diff mbox series

btrfs: remove BTRFS_REF_LAST from btrfs_ref_type

Message ID 20250415083808.893050-1-frank.li@vivo.com (mailing list archive)
State New
Headers show
Series btrfs: remove BTRFS_REF_LAST from btrfs_ref_type | expand

Commit Message

李扬韬 April 15, 2025, 8:38 a.m. UTC
It seems that it has never been used, so remove it.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/btrfs/delayed-ref.h | 1 -
 1 file changed, 1 deletion(-)

Comments

Qu Wenruo April 15, 2025, 8:43 a.m. UTC | #1
在 2025/4/15 18:08, Yangtao Li 写道:
> It seems that it has never been used, so remove it.

History please.

> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/btrfs/delayed-ref.h | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
> index f5ae880308d3..78cc23837610 100644
> --- a/fs/btrfs/delayed-ref.h
> +++ b/fs/btrfs/delayed-ref.h
> @@ -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.

>   } __packed;
>   
>   struct btrfs_ref {
李扬韬 April 15, 2025, 8:56 a.m. UTC | #2
> 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.

> 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.

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

I'm just looking at this code.

Thx,
Yangtao
Qu Wenruo April 15, 2025, 9:16 a.m. UTC | #3
在 2025/4/15 18:26, 李扬韬 写道:
>> 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.

>
>> 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.
>
>> And if this exposed by some automatic tools, please also mention it.
>
> I'm just looking at this code.
>
> Thx,
> Yangtao
Sun YangKai April 15, 2025, 3:46 p.m. UTC | #4
> >> 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.
> 
> >> 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.
> > 
> >> And if this exposed by some automatic tools, please also mention it.
> > 
> > I'm just looking at this code.
> > 
> > Thx,
> > Yangtao
David Sterba April 15, 2025, 4:05 p.m. UTC | #5
On Tue, Apr 15, 2025 at 06:46:48PM +0930, Qu Wenruo wrote:
> 
> 
> 在 2025/4/15 18:26, 李扬韬 写道:
> >> 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.

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.
diff mbox series

Patch

diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index f5ae880308d3..78cc23837610 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -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 {