From: alex Date: Wed, 28 Jul 2004 21:22:30 +0000 (+0000) Subject: b=3825 X-Git-Tag: v1_7_100~2021 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f37aa946d055d3fa5018de6ce9a1cab5cd36f031 b=3825 r=robert landed on HEAD --- diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 2e18afe..8f5bd37 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -1042,6 +1042,10 @@ struct llog_log_hdr { struct llog_rec_tail llh_tail; } __attribute__((packed)); +#define LLOG_BITMAP_SIZE(llh) ((llh->llh_hdr.lrh_len - \ + llh->llh_bitmap_offset - \ + sizeof(llh->llh_tail)) * 8) + /* log cookies are used to reference a specific log file and a record therein */ struct llog_cookie { struct llog_logid lgc_lgl; diff --git a/lustre/lvfs/llog_cat.c b/lustre/lvfs/llog_cat.c index 3837b4d..901a4a2 100644 --- a/lustre/lvfs/llog_cat.c +++ b/lustre/lvfs/llog_cat.c @@ -56,7 +56,7 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle, ENTRY; llh = cathandle->lgh_hdr; - bitmap_size = sizeof(llh->llh_bitmap) * 8; + bitmap_size = LLOG_BITMAP_SIZE(llh); index = (cathandle->lgh_last_idx + 1) % bitmap_size; @@ -223,13 +223,15 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, loghandle = cathandle->u.chd.chd_current_log; if (loghandle) { struct llog_log_hdr *llh = loghandle->lgh_hdr; - if (loghandle->lgh_last_idx < (sizeof(llh->llh_bitmap)*8) - 1 && + down_write(&loghandle->lgh_lock); + if (loghandle->lgh_last_idx < (LLOG_BITMAP_SIZE(llh) - 1) && (!logcookie || !(llog_cookie_get_flags(logcookie) & LLOG_COOKIE_REPLAY) || EQ_LOGID(loghandle->lgh_id, logcookie->lgc_lgl))) { - down_write(&loghandle->lgh_lock); up_read(&cathandle->lgh_lock); RETURN(loghandle); + } else { + up_write(&loghandle->lgh_lock); } } @@ -252,13 +254,15 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, loghandle = cathandle->u.chd.chd_current_log; if (loghandle) { struct llog_log_hdr *llh = loghandle->lgh_hdr; - if (loghandle->lgh_last_idx < (sizeof(llh->llh_bitmap)*8) - 1 && + down_write(&loghandle->lgh_lock); + if (loghandle->lgh_last_idx < (LLOG_BITMAP_SIZE(llh) - 1) && (!logcookie || !(llog_cookie_get_flags(logcookie) & LLOG_COOKIE_REPLAY) || EQ_LOGID(loghandle->lgh_id, logcookie->lgc_lgl))) { - down_write(&loghandle->lgh_lock); up_write(&cathandle->lgh_lock); RETURN(loghandle); + } else { + down_write(&loghandle->lgh_lock); } } @@ -485,7 +489,7 @@ int llog_cat_set_first_idx(struct llog_handle *cathandle, int index) int i, bitmap_size, idx; ENTRY; - bitmap_size = sizeof(llh->llh_bitmap) * 8; + bitmap_size = LLOG_BITMAP_SIZE(llh); if (llh->llh_cat_idx == cpu_to_le32(index - 1)) { idx = le32_to_cpu(llh->llh_cat_idx) + 1; llh->llh_cat_idx = cpu_to_le32(idx); diff --git a/lustre/lvfs/llog_lvfs.c b/lustre/lvfs/llog_lvfs.c index 5f57b64..3b1b548 100644 --- a/lustre/lvfs/llog_lvfs.c +++ b/lustre/lvfs/llog_lvfs.c @@ -246,6 +246,9 @@ static int llog_lvfs_write_rec(struct llog_handle *loghandle, rc = llog_lvfs_pad(ctxt, file, left, loghandle->lgh_last_idx); 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++;