summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2008-01-10 14:49:43 +0000
committerSteven Whitehouse <swhiteho@redhat.com>2008-01-25 08:18:03 +0000
commitac39aadd0440ae696e6dacaa8006ce1737b17008 (patch)
treed2a6784809c6bec674879dc865de4150e8b0fb01 /fs
parent9656b2c14c6ee0806c90a6be41dec71117fc8f50 (diff)
downloadlinux-ac39aadd0440ae696e6dacaa8006ce1737b17008.tar.gz
linux-ac39aadd0440ae696e6dacaa8006ce1737b17008.tar.bz2
linux-ac39aadd0440ae696e6dacaa8006ce1737b17008.zip
[GFS2] Fix assert in log code
Although the values were all being calculated correctly, there was a race in the assert due to the way it was using atomic variables. This changes the value we assert on so that we get the same effect by testing a different variable. This prevents the assert triggering when it shouldn't. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/log.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 91645259e135..161ab6f2058e 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -757,7 +757,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
{
unsigned int reserved;
- unsigned int old;
+ unsigned int unused;
gfs2_log_lock(sdp);
@@ -769,14 +769,11 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm;
gfs2_assert_withdraw(sdp, ((int)sdp->sd_log_commited_revoke) >= 0);
reserved = calc_reserved(sdp);
- old = atomic_read(&sdp->sd_log_blks_free);
- atomic_add(tr->tr_reserved - (reserved - sdp->sd_log_blks_reserved),
- &sdp->sd_log_blks_free);
-
- gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) >= old);
+ unused = sdp->sd_log_blks_reserved - reserved + tr->tr_reserved;
+ gfs2_assert_withdraw(sdp, unused >= 0);
+ atomic_add(unused, &sdp->sd_log_blks_free);
gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <=
sdp->sd_jdesc->jd_blocks);
-
sdp->sd_log_blks_reserved = reserved;
gfs2_log_unlock(sdp);