Commit 7dbc6ae6 authored by Bob Peterson's avatar Bob Peterson Committed by Andreas Gruenbacher

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: default avatarBob Peterson <rpeterso@redhat.com>
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent 3932e507
...@@ -473,6 +473,20 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd, ...@@ -473,6 +473,20 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd,
return 1; return 1;
} }
static int qd_bh_get_or_undo(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd)
{
int error;
error = bh_get(qd);
if (!error)
return 0;
clear_bit(QDF_LOCKED, &qd->qd_flags);
slot_put(qd);
qd_put(qd);
return error;
}
static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
{ {
struct gfs2_quota_data *qd = NULL, *iter; struct gfs2_quota_data *qd = NULL, *iter;
...@@ -495,16 +509,11 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) ...@@ -495,16 +509,11 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
spin_unlock(&qd_lock); spin_unlock(&qd_lock);
if (qd) { if (qd) {
error = bh_get(qd); error = qd_bh_get_or_undo(sdp, qd);
if (error) { if (error)
clear_bit(QDF_LOCKED, &qd->qd_flags);
slot_put(qd);
qd_put(qd);
return error; return error;
}
}
*qdp = qd; *qdp = qd;
}
return 0; return 0;
} }
...@@ -1164,14 +1173,7 @@ void gfs2_quota_unlock(struct gfs2_inode *ip) ...@@ -1164,14 +1173,7 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
if (!found) if (!found)
continue; continue;
gfs2_assert_warn(sdp, qd->qd_change_sync); if (!qd_bh_get_or_undo(sdp, qd))
if (bh_get(qd)) {
clear_bit(QDF_LOCKED, &qd->qd_flags);
slot_put(qd);
qd_put(qd);
continue;
}
qda[count++] = qd; qda[count++] = qd;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment