* in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
/* 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);
- 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);
- }
-
+ index = loghandle->lgh_last_idx + 1;
+ rc = llog_lvfs_pad(obd, file, left, index);
+ if (rc)
+ RETURN(rc);
+ loghandle->lgh_last_idx++; /*for pad rec*/
+ }
+ /* 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++;
index = loghandle->lgh_last_idx;
LASSERT(index < LLOG_BITMAP_SIZE(llh));
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 */
if (rc)
RETURN(rc);
- CDEBUG(D_RPCTRACE, "added record "LPX64": idx: %u, %u bytes\n",
+ CDEBUG(D_RPCTRACE, "added record "LPX64": idx: %u, %u \n",
loghandle->lgh_id.lgl_oid, index, rec->lrh_len);
if (rc == 0 && reccookie) {
reccookie->lgc_lgl = loghandle->lgh_id;