Skip to content

Commit 138a12d

Browse files
josefbacikkdave
authored andcommitted
btrfs: rip out btrfs_space_info::total_bytes_pinned
We used this in may_commit_transaction() in order to determine if we needed to commit the transaction. However we no longer have that logic and thus have no use of this counter anymore, so delete it. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3ffad69 commit 138a12d

File tree

7 files changed

+0
-97
lines changed

7 files changed

+0
-97
lines changed

fs/btrfs/block-group.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,6 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
13991399
btrfs_space_info_update_bytes_pinned(fs_info, space_info,
14001400
-block_group->pinned);
14011401
space_info->bytes_readonly += block_group->pinned;
1402-
__btrfs_mod_total_bytes_pinned(space_info, -block_group->pinned);
14031402
block_group->pinned = 0;
14041403

14051404
spin_unlock(&block_group->lock);
@@ -3068,8 +3067,6 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
30683067
spin_unlock(&cache->lock);
30693068
spin_unlock(&cache->space_info->lock);
30703069

3071-
__btrfs_mod_total_bytes_pinned(cache->space_info,
3072-
num_bytes);
30733070
set_extent_dirty(&trans->transaction->pinned_extents,
30743071
bytenr, bytenr + num_bytes - 1,
30753072
GFP_NOFS | __GFP_NOFAIL);

fs/btrfs/delayed-ref.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,6 @@ static noinline void update_existing_head_ref(struct btrfs_trans_handle *trans,
641641
struct btrfs_delayed_ref_root *delayed_refs =
642642
&trans->transaction->delayed_refs;
643643
struct btrfs_fs_info *fs_info = trans->fs_info;
644-
u64 flags = btrfs_ref_head_to_space_flags(existing);
645644
int old_ref_mod;
646645

647646
BUG_ON(existing->is_data != update->is_data);
@@ -711,26 +710,6 @@ static noinline void update_existing_head_ref(struct btrfs_trans_handle *trans,
711710
}
712711
}
713712

714-
/*
715-
* This handles the following conditions:
716-
*
717-
* 1. We had a ref mod of 0 or more and went negative, indicating that
718-
* we may be freeing space, so add our space to the
719-
* total_bytes_pinned counter.
720-
* 2. We were negative and went to 0 or positive, so no longer can say
721-
* that the space would be pinned, decrement our counter from the
722-
* total_bytes_pinned counter.
723-
* 3. We are now at 0 and have ->must_insert_reserved set, which means
724-
* this was a new allocation and then we dropped it, and thus must
725-
* add our space to the total_bytes_pinned counter.
726-
*/
727-
if (existing->total_ref_mod < 0 && old_ref_mod >= 0)
728-
btrfs_mod_total_bytes_pinned(fs_info, flags, existing->num_bytes);
729-
else if (existing->total_ref_mod >= 0 && old_ref_mod < 0)
730-
btrfs_mod_total_bytes_pinned(fs_info, flags, -existing->num_bytes);
731-
else if (existing->total_ref_mod == 0 && existing->must_insert_reserved)
732-
btrfs_mod_total_bytes_pinned(fs_info, flags, existing->num_bytes);
733-
734713
spin_unlock(&existing->lock);
735714
}
736715

@@ -835,17 +814,12 @@ add_delayed_ref_head(struct btrfs_trans_handle *trans,
835814
kmem_cache_free(btrfs_delayed_ref_head_cachep, head_ref);
836815
head_ref = existing;
837816
} else {
838-
u64 flags = btrfs_ref_head_to_space_flags(head_ref);
839-
840817
if (head_ref->is_data && head_ref->ref_mod < 0) {
841818
delayed_refs->pending_csums += head_ref->num_bytes;
842819
trans->delayed_ref_updates +=
843820
btrfs_csum_bytes_to_leaves(trans->fs_info,
844821
head_ref->num_bytes);
845822
}
846-
if (head_ref->ref_mod < 0)
847-
btrfs_mod_total_bytes_pinned(trans->fs_info, flags,
848-
head_ref->num_bytes);
849823
delayed_refs->num_heads++;
850824
delayed_refs->num_heads_ready++;
851825
atomic_inc(&delayed_refs->num_entries);

fs/btrfs/disk-io.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4680,9 +4680,6 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
46804680
cache->space_info->bytes_reserved -= head->num_bytes;
46814681
spin_unlock(&cache->lock);
46824682
spin_unlock(&cache->space_info->lock);
4683-
percpu_counter_add_batch(
4684-
&cache->space_info->total_bytes_pinned,
4685-
head->num_bytes, BTRFS_TOTAL_BYTES_PINNED_BATCH);
46864683

46874684
btrfs_put_block_group(cache);
46884685

fs/btrfs/extent-tree.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,19 +1804,6 @@ void btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info,
18041804
nr_items += btrfs_csum_bytes_to_leaves(fs_info, head->num_bytes);
18051805
}
18061806

1807-
/*
1808-
* We were dropping refs, or had a new ref and dropped it, and thus must
1809-
* adjust down our total_bytes_pinned, the space may or may not have
1810-
* been pinned and so is accounted for properly in the pinned space by
1811-
* now.
1812-
*/
1813-
if (head->total_ref_mod < 0 ||
1814-
(head->total_ref_mod == 0 && head->must_insert_reserved)) {
1815-
u64 flags = btrfs_ref_head_to_space_flags(head);
1816-
1817-
btrfs_mod_total_bytes_pinned(fs_info, flags, -head->num_bytes);
1818-
}
1819-
18201807
btrfs_delayed_refs_rsv_release(fs_info, nr_items);
18211808
}
18221809

@@ -2551,7 +2538,6 @@ static int pin_down_extent(struct btrfs_trans_handle *trans,
25512538
spin_unlock(&cache->lock);
25522539
spin_unlock(&cache->space_info->lock);
25532540

2554-
__btrfs_mod_total_bytes_pinned(cache->space_info, num_bytes);
25552541
set_extent_dirty(&trans->transaction->pinned_extents, bytenr,
25562542
bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
25572543
return 0;
@@ -2762,7 +2748,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
27622748
cache->pinned -= len;
27632749
btrfs_space_info_update_bytes_pinned(fs_info, space_info, -len);
27642750
space_info->max_extent_size = 0;
2765-
__btrfs_mod_total_bytes_pinned(space_info, -len);
27662751
if (cache->ro) {
27672752
space_info->bytes_readonly += len;
27682753
readonly = true;

fs/btrfs/space-info.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,6 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
192192
if (!space_info)
193193
return -ENOMEM;
194194

195-
ret = percpu_counter_init(&space_info->total_bytes_pinned, 0,
196-
GFP_KERNEL);
197-
if (ret) {
198-
kfree(space_info);
199-
return ret;
200-
}
201-
202195
for (i = 0; i < BTRFS_NR_RAID_TYPES; i++)
203196
INIT_LIST_HEAD(&space_info->block_groups[i]);
204197
init_rwsem(&space_info->groups_sem);

fs/btrfs/space-info.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ struct btrfs_space_info {
4343

4444
u64 flags;
4545

46-
/*
47-
* bytes_pinned is kept in line with what is actually pinned, as in
48-
* we've called update_block_group and dropped the bytes_used counter
49-
* and increased the bytes_pinned counter. However this means that
50-
* bytes_pinned does not reflect the bytes that will be pinned once the
51-
* delayed refs are flushed, so this counter is inc'ed every time we
52-
* call btrfs_free_extent so it is a realtime count of what will be
53-
* freed once the transaction is committed. It will be zeroed every
54-
* time the transaction commits.
55-
*/
56-
struct percpu_counter total_bytes_pinned;
57-
5846
struct list_head list;
5947
/* Protected by the spinlock 'lock'. */
6048
struct list_head ro_bgs;
@@ -157,22 +145,4 @@ static inline void btrfs_space_info_free_bytes_may_use(
157145
}
158146
int btrfs_reserve_data_bytes(struct btrfs_fs_info *fs_info, u64 bytes,
159147
enum btrfs_reserve_flush_enum flush);
160-
161-
static inline void __btrfs_mod_total_bytes_pinned(
162-
struct btrfs_space_info *space_info,
163-
s64 mod)
164-
{
165-
percpu_counter_add_batch(&space_info->total_bytes_pinned, mod,
166-
BTRFS_TOTAL_BYTES_PINNED_BATCH);
167-
}
168-
169-
static inline void btrfs_mod_total_bytes_pinned(struct btrfs_fs_info *fs_info,
170-
u64 flags, s64 mod)
171-
{
172-
struct btrfs_space_info *space_info = btrfs_find_space_info(fs_info, flags);
173-
174-
ASSERT(space_info);
175-
__btrfs_mod_total_bytes_pinned(space_info, mod);
176-
}
177-
178148
#endif /* BTRFS_SPACE_INFO_H */

fs/btrfs/sysfs.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -665,15 +665,6 @@ static ssize_t btrfs_space_info_show_##field(struct kobject *kobj, \
665665
} \
666666
BTRFS_ATTR(space_info, field, btrfs_space_info_show_##field)
667667

668-
static ssize_t btrfs_space_info_show_total_bytes_pinned(struct kobject *kobj,
669-
struct kobj_attribute *a,
670-
char *buf)
671-
{
672-
struct btrfs_space_info *sinfo = to_space_info(kobj);
673-
s64 val = percpu_counter_sum(&sinfo->total_bytes_pinned);
674-
return scnprintf(buf, PAGE_SIZE, "%lld\n", val);
675-
}
676-
677668
SPACE_INFO_ATTR(flags);
678669
SPACE_INFO_ATTR(total_bytes);
679670
SPACE_INFO_ATTR(bytes_used);
@@ -684,8 +675,6 @@ SPACE_INFO_ATTR(bytes_readonly);
684675
SPACE_INFO_ATTR(bytes_zone_unusable);
685676
SPACE_INFO_ATTR(disk_used);
686677
SPACE_INFO_ATTR(disk_total);
687-
BTRFS_ATTR(space_info, total_bytes_pinned,
688-
btrfs_space_info_show_total_bytes_pinned);
689678

690679
static struct attribute *space_info_attrs[] = {
691680
BTRFS_ATTR_PTR(space_info, flags),
@@ -698,15 +687,13 @@ static struct attribute *space_info_attrs[] = {
698687
BTRFS_ATTR_PTR(space_info, bytes_zone_unusable),
699688
BTRFS_ATTR_PTR(space_info, disk_used),
700689
BTRFS_ATTR_PTR(space_info, disk_total),
701-
BTRFS_ATTR_PTR(space_info, total_bytes_pinned),
702690
NULL,
703691
};
704692
ATTRIBUTE_GROUPS(space_info);
705693

706694
static void space_info_release(struct kobject *kobj)
707695
{
708696
struct btrfs_space_info *sinfo = to_space_info(kobj);
709-
percpu_counter_destroy(&sinfo->total_bytes_pinned);
710697
kfree(sinfo);
711698
}
712699

0 commit comments

Comments
 (0)