Skip to content

Commit 7dbc6ae

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: introduce qd_bh_get_or_undo
This patch is an attempt to force some consistency in quota sync processing. Two functions (qd_fish and gfs2_quota_unlock) called qd_check_sync, after which they both called bh_get, and if that failed, they took the same steps to undo the actions of qd_check_sync. This patch introduces a new function, qd_bh_get_or_undo, which performs the same steps, reducing code redundancy. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 3932e50 commit 7dbc6ae

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

fs/gfs2/quota.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,20 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd,
473473
return 1;
474474
}
475475

476+
static int qd_bh_get_or_undo(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd)
477+
{
478+
int error;
479+
480+
error = bh_get(qd);
481+
if (!error)
482+
return 0;
483+
484+
clear_bit(QDF_LOCKED, &qd->qd_flags);
485+
slot_put(qd);
486+
qd_put(qd);
487+
return error;
488+
}
489+
476490
static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
477491
{
478492
struct gfs2_quota_data *qd = NULL, *iter;
@@ -495,17 +509,12 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
495509
spin_unlock(&qd_lock);
496510

497511
if (qd) {
498-
error = bh_get(qd);
499-
if (error) {
500-
clear_bit(QDF_LOCKED, &qd->qd_flags);
501-
slot_put(qd);
502-
qd_put(qd);
512+
error = qd_bh_get_or_undo(sdp, qd);
513+
if (error)
503514
return error;
504-
}
515+
*qdp = qd;
505516
}
506517

507-
*qdp = qd;
508-
509518
return 0;
510519
}
511520

@@ -1164,15 +1173,8 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
11641173
if (!found)
11651174
continue;
11661175

1167-
gfs2_assert_warn(sdp, qd->qd_change_sync);
1168-
if (bh_get(qd)) {
1169-
clear_bit(QDF_LOCKED, &qd->qd_flags);
1170-
slot_put(qd);
1171-
qd_put(qd);
1172-
continue;
1173-
}
1174-
1175-
qda[count++] = qd;
1176+
if (!qd_bh_get_or_undo(sdp, qd))
1177+
qda[count++] = qd;
11761178
}
11771179

11781180
if (count) {

0 commit comments

Comments
 (0)