btrfs: remove warnings superseded by refcount_t usage
David Sterba
maintainerPATCH 1/1 btrfs: remove warnings superseded by refcount_t usage
There are several WARN_ON calls that catch incrorrect reference counter updates, but this is what the refcount_t does already:
* refcount_inc from 0 will warn
* refcount_dec_and_test from 0 will warn
--- fs/btrfs/delayed-ref.h | 1 - fs/btrfs/extent_map.c | 2 +- fs/btrfs/transaction.c | 1 - fs/btrfs/volumes.c | 1 - 4 files changed, 1 insertion(+), 4 deletions(-)
fs/btrfs/delayed-ref.h +0 -1
@@ -210,7 +210,6 @@ btrfs_free_delayed_extent_op(struct btrfs_delayed_extent_op *op)static inline void btrfs_put_delayed_ref (struct btrfs_delayed_ref_node *ref) { -WARN_ON (refcount_read (&ref->refs) ==0 );if (refcount_dec_and_test (&ref->refs)) {WARN_ON (ref->in_tree);switch (ref->type) {
fs/btrfs/extent_map.c +1 -1
@@ -72,7 +72,7 @@ void free_extent_map(struct extent_map *em) {if (!em)return ; -WARN_ON (refcount_read (&em->refs) ==0 ); +if (refcount_dec_and_test (&em->refs)) {WARN_ON (extent_map_in_tree (em));WARN_ON (!list_empty (&em->list));
fs/btrfs/transaction.c +0 -1
@@ -41,7 +41,6 @@ static const unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {void btrfs_put_transaction (struct btrfs_transaction *transaction) { -WARN_ON (refcount_read (&transaction->use_count) ==0 );if (refcount_dec_and_test (&transaction->use_count)) {BUG_ON (!list_empty (&transaction->list));WARN_ON (!RB_EMPTY_ROOT (&transaction->delayed_refs.href_root));
fs/btrfs/volumes.c +0 -1
@@ -5330,7 +5330,6 @@ static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes)void btrfs_get_bbio (struct btrfs_bio *bbio) { -WARN_ON (!refcount_read (&bbio->refs));refcount_inc (&bbio->refs); }
Signature · 1 line
2.17.0
Quoted 6 lines · David Sterba
There are several
WARN_ONcalls that catch incrorrect reference counter updates, but this is what therefcount_tdoes already:*
refcount_incfrom 0 will warn
*refcount_dec_and_testfrom 0 will warn
But these warnings are only going to be triggered in the case of CONFIG_REFCOUNT_FULL otherwise refcount falls back to plain atomic operations.
Quoted 58 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/delayed-ref.h | 1 - fs/btrfs/extent_map.c | 2 +- fs/btrfs/transaction.c | 1 - fs/btrfs/volumes.c | 1 - 4 files changed, 1 insertion(+), 4 deletions(-)fs/btrfs/delayed-ref.h +0
-1@@ -210,7 +210,6 @@ btrfs_free_delayed_extent_op(struct btrfs_delayed_extent_op *op)static inline void btrfs_put_delayed_ref (struct btrfs_delayed_ref_node *ref) { -WARN_ON (refcount_read (&ref->refs) ==0 );if (refcount_dec_and_test (&ref->refs)) {WARN_ON (ref->in_tree);switch (ref->type) {fs/btrfs/extent_map.c +1
-1@@ -72,7 +72,7 @@ void free_extent_map(struct extent_map *em) {if (!em)return ; -WARN_ON (refcount_read (&em->refs) ==0 ); +if (refcount_dec_and_test (&em->refs)) {WARN_ON (extent_map_in_tree (em));WARN_ON (!list_empty (&em->list));fs/btrfs/transaction.c +0
-1@@ -41,7 +41,6 @@ static const unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {void btrfs_put_transaction (struct btrfs_transaction *transaction) { -WARN_ON (refcount_read (&transaction->use_count) ==0 );if (refcount_dec_and_test (&transaction->use_count)) {BUG_ON (!list_empty (&transaction->list));WARN_ON (!RB_EMPTY_ROOT (&transaction->delayed_refs.href_root));fs/btrfs/volumes.c +0
-1@@ -5330,7 +5330,6 @@ static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes)void btrfs_get_bbio (struct btrfs_bio *bbio) { -WARN_ON (!refcount_read (&bbio->refs));refcount_inc (&bbio->refs); }
Quoted 11 lines · Nikolay Borisov
Quoted 6 lines · David Sterba
There are several
WARN_ONcalls that catch incrorrect reference counter updates, but this is what therefcount_tdoes already:*
refcount_incfrom 0 will warn
*refcount_dec_and_testfrom 0 will warnBut these warnings are only going to be triggered in the case of
CONFIG_REFCOUNT_FULLotherwise refcount falls back to plain atomic operations.
Right, I'm for REFCOUNT_FULL on by default obviously, but we need to take handle the case where it's not. And there isn't a refcount type with the full semantics.
Quoted 9 lines · David Sterba
Quoted 8 lines · Nikolay Borisov
Quoted 6 lines · David Sterba
There are several
WARN_ONcalls that catch incrorrect reference counter updates, but this is what therefcount_tdoes already:*
refcount_incfrom 0 will warn
*refcount_dec_and_testfrom 0 will warn
Quoted 7 lines
Quoted 3 lines
But these warnings are only going to be triggered in the case of
CONFIG_REFCOUNT_FULLotherwise refcount falls back to plain atomic operations.Right, I'm for
REFCOUNT_FULLon by default obviously, but we need to take handle the case where it's not. And there isn't a refcount type with the full semantics.
There refcount helpers will be extended to allow the full check semantics so I'll use them and drop the WARN_ONs once the patch gets merged.