Skip to content

Commit 94f5648

Browse files
author
Andreas Gruenbacher
committed
gfs2: Clean up quotad timeout handling
Instead of tracking the remaining time, track the deadline of each of the timeouts. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent dff1fb6 commit 94f5648

1 file changed

Lines changed: 27 additions & 31 deletions

File tree

fs/gfs2/quota.c

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,20 +1558,6 @@ static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error)
15581558
}
15591559
}
15601560

1561-
static void quotad_check_timeo(struct gfs2_sbd *sdp, const char *msg,
1562-
int (*fxn)(struct super_block *sb, int type),
1563-
unsigned long t, unsigned long *timeo,
1564-
unsigned int *new_timeo)
1565-
{
1566-
if (t >= *timeo) {
1567-
int error = fxn(sdp->sd_vfs, 0);
1568-
quotad_error(sdp, msg, error);
1569-
*timeo = gfs2_tune_get_i(&sdp->sd_tune, new_timeo) * HZ;
1570-
} else {
1571-
*timeo -= t;
1572-
}
1573-
}
1574-
15751561
void gfs2_wake_up_statfs(struct gfs2_sbd *sdp) {
15761562
if (!sdp->sd_statfs_force_sync) {
15771563
sdp->sd_statfs_force_sync = 1;
@@ -1589,34 +1575,44 @@ void gfs2_wake_up_statfs(struct gfs2_sbd *sdp) {
15891575
int gfs2_quotad(void *data)
15901576
{
15911577
struct gfs2_sbd *sdp = data;
1592-
struct gfs2_tune *tune = &sdp->sd_tune;
1593-
unsigned long statfs_timeo = 0;
1594-
unsigned long quotad_timeo = 0;
1595-
unsigned long t = 0;
1578+
unsigned long now = jiffies;
1579+
unsigned long statfs_deadline = now;
1580+
unsigned long quotad_deadline = now;
15961581

15971582
set_freezable();
15981583
while (!kthread_should_stop()) {
1584+
unsigned long t;
1585+
15991586
if (gfs2_withdrawing_or_withdrawn(sdp))
16001587
break;
16011588

1602-
/* Update the master statfs file */
1603-
if (sdp->sd_statfs_force_sync) {
1604-
int error = gfs2_statfs_sync(sdp->sd_vfs, 0);
1589+
now = jiffies;
1590+
if (sdp->sd_statfs_force_sync ||
1591+
time_after(now, statfs_deadline)) {
1592+
unsigned int quantum;
1593+
int error;
1594+
1595+
/* Update the master statfs file */
1596+
error = gfs2_statfs_sync(sdp->sd_vfs, 0);
16051597
quotad_error(sdp, "statfs", error);
1606-
statfs_timeo = gfs2_tune_get(sdp, gt_statfs_quantum) * HZ;
1598+
1599+
quantum = gfs2_tune_get(sdp, gt_statfs_quantum);
1600+
statfs_deadline = now + quantum * HZ;
16071601
}
1608-
else
1609-
quotad_check_timeo(sdp, "statfs", gfs2_statfs_sync, t,
1610-
&statfs_timeo,
1611-
&tune->gt_statfs_quantum);
1602+
if (time_after(now, quotad_deadline)) {
1603+
unsigned int quantum;
1604+
int error;
16121605

1613-
/* Update quota file */
1614-
quotad_check_timeo(sdp, "sync", gfs2_quota_sync, t,
1615-
&quotad_timeo, &tune->gt_quota_quantum);
1606+
/* Update the quota file */
1607+
error = gfs2_quota_sync(sdp->sd_vfs, 0);
1608+
quotad_error(sdp, "sync", error);
16161609

1617-
t = min(quotad_timeo, statfs_timeo);
1610+
quantum = gfs2_tune_get(sdp, gt_quota_quantum);
1611+
quotad_deadline = now + quantum * HZ;
1612+
}
16181613

1619-
t -= wait_event_freezable_timeout(sdp->sd_quota_wait,
1614+
t = min(statfs_deadline - now, quotad_deadline - now);
1615+
wait_event_freezable_timeout(sdp->sd_quota_wait,
16201616
sdp->sd_statfs_force_sync ||
16211617
gfs2_withdrawing_or_withdrawn(sdp) ||
16221618
kthread_should_stop(),

0 commit comments

Comments
 (0)