diff options
author | Bob Peterson | 2023-06-08 12:30:16 -0500 |
---|---|---|
committer | Andreas Gruenbacher | 2023-09-05 15:58:18 +0200 |
commit | 06aa6fd31a5f402b055e12ea53bb7b086359d3c8 (patch) | |
tree | f1ce148e26fac7f09582b08c30a678bde73847dd /fs/gfs2 | |
parent | 36a740916a94ea0efa0c5c2ddcd9dcdce56c9a40 (diff) |
gfs2: check for no eligible quota changes
Before this patch, function gfs2_quota_sync would always allocate a page
full of memory and increment its quota sync generation number. This
happened even when the system was completely idle or if no blocks were
allocated or quota changes made. This patch adds function qd_changed
to determine if any changes have been made that qualify for a
quota sync. If not, it avoids the memory allocation and bumping the
generation number, along with all the additional work it would do.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/quota.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 678d2e749db8..6f6e3493b5fa 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1294,6 +1294,24 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change, } } +static bool qd_changed(struct gfs2_sbd *sdp) +{ + struct gfs2_quota_data *qd; + bool changed = false; + + spin_lock(&qd_lock); + list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { + if (test_bit(QDF_LOCKED, &qd->qd_flags) || + !test_bit(QDF_CHANGE, &qd->qd_flags)) + continue; + + changed = true; + break; + } + spin_unlock(&qd_lock); + return changed; +} + int gfs2_quota_sync(struct super_block *sb, int type) { struct gfs2_sbd *sdp = sb->s_fs_info; @@ -1303,6 +1321,9 @@ int gfs2_quota_sync(struct super_block *sb, int type) unsigned int x; int error = 0; + if (!qd_changed(sdp)) + return 0; + qda = kcalloc(max_qd, sizeof(struct gfs2_quota_data *), GFP_KERNEL); if (!qda) return -ENOMEM; |