Skip to content

Commit 06aa6fd

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
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 <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 36a7409 commit 06aa6fd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

fs/gfs2/quota.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,24 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
12941294
}
12951295
}
12961296

1297+
static bool qd_changed(struct gfs2_sbd *sdp)
1298+
{
1299+
struct gfs2_quota_data *qd;
1300+
bool changed = false;
1301+
1302+
spin_lock(&qd_lock);
1303+
list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) {
1304+
if (test_bit(QDF_LOCKED, &qd->qd_flags) ||
1305+
!test_bit(QDF_CHANGE, &qd->qd_flags))
1306+
continue;
1307+
1308+
changed = true;
1309+
break;
1310+
}
1311+
spin_unlock(&qd_lock);
1312+
return changed;
1313+
}
1314+
12971315
int gfs2_quota_sync(struct super_block *sb, int type)
12981316
{
12991317
struct gfs2_sbd *sdp = sb->s_fs_info;
@@ -1303,6 +1321,9 @@ int gfs2_quota_sync(struct super_block *sb, int type)
13031321
unsigned int x;
13041322
int error = 0;
13051323

1324+
if (!qd_changed(sdp))
1325+
return 0;
1326+
13061327
qda = kcalloc(max_qd, sizeof(struct gfs2_quota_data *), GFP_KERNEL);
13071328
if (!qda)
13081329
return -ENOMEM;

0 commit comments

Comments
 (0)