diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2024-06-06 05:37:02 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2024-06-08 02:35:16 +0200 |
commit | b510af07aaa4d8a7095bc0368020d8bdba5af942 (patch) | |
tree | acb9b2b36c2212f8f468be7bd75e33fe75829925 /fs/gfs2 | |
parent | 7da4d6e178f405d7abdfc42ea7ac0074e9a6aa45 (diff) | |
download | lwn-b510af07aaa4d8a7095bc0368020d8bdba5af942.tar.gz lwn-b510af07aaa4d8a7095bc0368020d8bdba5af942.zip |
gfs2: quota need_sync cleanup
Rename variable 'value' to 'change' as it stores a change in value.
Add new 'value' and 'limit' variables for the current value and limit.
Only fetch the tuning parameters when we need them.
Get rid of unnecessary nesting.
No change in functionality.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/quota.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 29a69756cc32..11bd16d8f81c 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1117,34 +1117,32 @@ static bool need_sync(struct gfs2_quota_data *qd) { struct gfs2_sbd *sdp = qd->qd_sbd; struct gfs2_tune *gt = &sdp->sd_tune; - s64 value; + s64 value, change, limit; unsigned int num, den; if (!qd->qd_qb.qb_limit) return false; spin_lock(&qd_lock); - value = qd->qd_change; + change = qd->qd_change; spin_unlock(&qd_lock); + if (change <= 0) + return false; + value = (s64)be64_to_cpu(qd->qd_qb.qb_value); + limit = (s64)be64_to_cpu(qd->qd_qb.qb_limit); + if (value >= limit) + return false; + spin_lock(>->gt_spin); num = gt->gt_quota_scale_num; den = gt->gt_quota_scale_den; spin_unlock(>->gt_spin); - if (value <= 0) - return false; - else if ((s64)be64_to_cpu(qd->qd_qb.qb_value) >= - (s64)be64_to_cpu(qd->qd_qb.qb_limit)) + change *= gfs2_jindex_size(sdp) * num; + change = div_s64(change, den); + if (value + change < limit) return false; - else { - value *= gfs2_jindex_size(sdp) * num; - value = div_s64(value, den); - value += (s64)be64_to_cpu(qd->qd_qb.qb_value); - if (value < (s64)be64_to_cpu(qd->qd_qb.qb_limit)) - return false; - } - return true; } |