From 94e85e96bf01609b00735a407dde44348181e27b Mon Sep 17 00:00:00 2001 From: wangdi Date: Fri, 5 Sep 2008 10:11:00 +0000 Subject: [PATCH] Branch: b1_8_gate b=16717 fix lbug when conf log is full i=nathan,umka --- lustre/obdclass/llog_lvfs.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lustre/obdclass/llog_lvfs.c b/lustre/obdclass/llog_lvfs.c index 4042bb5..20b2012 100644 --- a/lustre/obdclass/llog_lvfs.c +++ b/lustre/obdclass/llog_lvfs.c @@ -323,18 +323,16 @@ static int llog_lvfs_write_rec(struct llog_handle *loghandle, /* NOTE: padding is a record, but no bit is set */ if (left != 0 && left != reclen && left < (reclen + LLOG_MIN_REC_SIZE)) { - loghandle->lgh_last_idx++; - rc = llog_lvfs_pad(obd, file, left, loghandle->lgh_last_idx); + index = loghandle->lgh_last_idx + 1; + rc = llog_lvfs_pad(obd, file, left, index); if (rc) RETURN(rc); - /* if it's the last idx in log file, then return -ENOSPC */ - if (loghandle->lgh_last_idx == LLOG_BITMAP_SIZE(llh) - 1) - RETURN(-ENOSPC); + loghandle->lgh_last_idx++; /*for pad rec*/ } - - loghandle->lgh_last_idx++; - index = loghandle->lgh_last_idx; - LASSERT(index < LLOG_BITMAP_SIZE(llh)); + /* if it's the last idx in log file, then return -ENOSPC */ + if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1) + RETURN(-ENOSPC); + index = ++loghandle->lgh_last_idx; rec->lrh_index = index; if (buf == NULL) { lrt = (struct llog_rec_tail *) @@ -342,6 +340,9 @@ static int llog_lvfs_write_rec(struct llog_handle *loghandle, lrt->lrt_len = rec->lrh_len; lrt->lrt_index = rec->lrh_index; } + /*The caller should make sure only 1 process access the lgh_last_idx, + *Otherwise it might hit the assert.*/ + LASSERT(index < LLOG_BITMAP_SIZE(llh)); if (ext2_set_bit(index, llh->llh_bitmap)) { CERROR("argh, index %u already set in log bitmap?\n", index); LBUG(); /* should never happen */ -- 1.8.3.1