Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(t) avoid recalculating pool free #2386

Closed
phillxnet opened this issue Jun 28, 2022 · 1 comment
Closed

(t) avoid recalculating pool free #2386

phillxnet opened this issue Jun 28, 2022 · 1 comment
Assignees

Comments

@phillxnet
Copy link
Member

(t) = testing branch. While working on #2384 and revising mocking of such things as pool free space, we see a redundant re-calculation of the same in our PUT (remove) pool command when the exact same calculation has already been made via an earlier Pool object @Property instantiation still held.

Pool "free" property definition:

@property
def free(self, *args, **kwargs):
# Why do we compute pool usage on the fly like this and not like
# share usage as part of state refresh? This is a lot simpler and
# less code. For share usage, this type of logic could slow things
# down quite a bit because there can be 100's of Shares, but number
# of Pools even on a large instance is usually no more than a few.
return self.size - pool_usage(self.mnt_pt_var)

storageadmin.views.pool.PoolDetailView -put()

usage = pool_usage("/{}/{}".format(settings.MNT_PT, pool.name))
size_cut = 0
for d in disks: # to be removed
size_cut += d.allocated
available_free = pool.size - usage
if size_cut >= available_free:

This is obviously redundant. And given the second in-transaction re-use/repeat-call is the only other user of fs.btrfs.pool_usage() we can improve/ease our traceability and mocking by centralising this methods use.

@phillxnet phillxnet self-assigned this Jun 28, 2022
phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Jun 28, 2022
Remove a redundant re-calculation of pool.free in PUT (remove) pool command when the
exact same calculation has already been made via an earlier and current Pool object
@Property instantiation.
phillxnet added a commit that referenced this issue Jun 28, 2022
…pool_free

(t) avoid recalculating pool free #2386
@FroggyFlox
Copy link
Member

Closing as fixed by #2387 .

phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Jun 29, 2022
…2386

Simplify mocking of pool_usage in line with recent tested code
changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants