handle->lgh_hdr->llh_flags |= (flags & LLOG_F_EXT_MASK);
handle->lgh_last_idx = LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_index;
+ handle->lgh_write_offset = lgi->lgi_attr.la_size;
RETURN(0);
}
struct dt_object *o;
__u32 chunk_size;
size_t left;
-
+ __u32 orig_last_idx;
+ __u64 orig_write_offset;
ENTRY;
LASSERT(env);
RETURN(-ENOSPC);
LASSERT(lgi->lgi_attr.la_valid & LA_SIZE);
+ orig_last_idx = loghandle->lgh_last_idx;
+ orig_write_offset = loghandle->lgh_write_offset;
lgi->lgi_off = lgi->lgi_attr.la_size;
left = chunk_size - (lgi->lgi_off & (chunk_size - 1));
/* NOTE: padding is a record, but no bit is set */
rc = llog_osd_pad(env, o, &lgi->lgi_off, left, index, th);
if (rc)
RETURN(rc);
+
+ if (dt_object_remote(o))
+ loghandle->lgh_write_offset = lgi->lgi_off;
+
loghandle->lgh_last_idx++; /* for pad rec */
}
/* if it's the last idx in log file, then return -ENOSPC
* records. This also allows to handle Catalog wrap around case */
if (llh->llh_flags & LLOG_F_IS_FIXSIZE) {
lgi->lgi_off = llh->llh_hdr.lrh_len + (index - 1) * reclen;
+ } else if (dt_object_remote(o)) {
+ lgi->lgi_off = max_t(__u64, loghandle->lgh_write_offset,
+ lgi->lgi_off);
} else {
rc = dt_attr_get(env, o, &lgi->lgi_attr);
if (rc)
if (rc < 0)
GOTO(out, rc);
- CDEBUG(D_OTHER, "added record "DOSTID": idx: %u, %u off"LPU64"\n",
- POSTID(&loghandle->lgh_id.lgl_oi), index, rec->lrh_len,
+ if (dt_object_remote(o))
+ loghandle->lgh_write_offset = lgi->lgi_off;
+
+ CDEBUG(D_HA, "added record "DFID": idx: %u, %u off"LPU64"\n",
+ PFID(lu_object_fid(&o->do_lu)), index, rec->lrh_len,
lgi->lgi_off);
if (reccookie != NULL) {
reccookie->lgc_lgl = loghandle->lgh_id;
mutex_unlock(&loghandle->lgh_hdr_mutex);
/* restore llog last_idx */
- if (--loghandle->lgh_last_idx == 0 &&
+ if (dt_object_remote(o)) {
+ loghandle->lgh_last_idx = orig_last_idx;
+ loghandle->lgh_write_offset = orig_write_offset;
+ } else if (--loghandle->lgh_last_idx == 0 &&
(llh->llh_flags & LLOG_F_IS_CAT) && llh->llh_cat_idx != 0) {
/* catalog had just wrap-around case */
loghandle->lgh_last_idx = LLOG_HDR_BITMAP_SIZE(llh) - 1;
}
+
LLOG_HDR_TAIL(llh)->lrt_index = loghandle->lgh_last_idx;
RETURN(rc);
if (len == 0 || len & (chunk_size - 1))
RETURN(-EINVAL);
- CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n",
- next_idx, *cur_idx, *cur_offset);
-
LASSERT(loghandle);
LASSERT(loghandle->lgh_ctxt);
if (rc)
GOTO(out, rc);
+ CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off"
+ LPU64"), size %llu\n", next_idx, *cur_idx,
+ *cur_offset, lgi->lgi_attr.la_size);
+
while (*cur_offset < lgi->lgi_attr.la_size) {
struct llog_rec_hdr *rec, *last_rec;
struct llog_rec_tail *tail;
if (LLOG_REC_HDR_NEEDS_SWABBING(last_rec))
lustre_swab_llog_rec(last_rec);
- LASSERT(last_rec->lrh_index == tail->lrt_index);
+
+ if (last_rec->lrh_index != tail->lrt_index) {
+ CERROR("%s: invalid llog tail at log id "DOSTID"/%u "
+ "offset "LPU64" last_rec idx %u tail idx %u\n",
+ o->do_lu.lo_dev->ld_obd->obd_name,
+ POSTID(&loghandle->lgh_id.lgl_oi),
+ loghandle->lgh_id.lgl_ogen, *cur_offset,
+ last_rec->lrh_index, tail->lrt_index);
+ GOTO(out, rc = -EINVAL);
+ }
*cur_idx = tail->lrt_index;